]> sourceware.org Git - newlib-cygwin.git/commitdiff
* libc/stdio/vfprintf.c: Include ../stdlib/local.h. Replace call to
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 18 Nov 2009 09:49:57 +0000 (09:49 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 18 Nov 2009 09:49:57 +0000 (09:49 +0000)
_mbtowc_r with direct call to __mbtowc.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdlib/btowc.c: Include local.h.  Replace call to _mbtowc_r
with direct call to __mbtowc.
* libc/stdlib/mblen.c: Ditto.
* libc/stdlib/mblen_r.c: Ditto.
* libc/stdlib/mbrtowc.c: Ditto.
* libc/stdlib/mbstowcs_r.c: Ditto.
* libc/stdlib/mbtowc.c: Ditto.
* libc/stdlib/wcrtomb.c: Include local.h.  Replace call to _wctomb_r
with direct call to __wctomb.
* libc/stdlib/wcsnrtombs.c: Ditto.
(_wcsnrtombs_r): Ditto.
* libc/stdlib/wcstombs_r.c: Ditto.
* libc/stdlib/wctob.c: Ditto.
* libc/stdlib/wctomb.c: Ditto.

* libc/stdlib/mbrtowc.c (mbrtowc): Implement independently from
_mbrtowc_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
defined.
* libc/stdlib/wcrtomb.c (wcrtomb): Implement independently from
_wcrtomb_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
defined.

* libc/stdlib/mbtowc_r.c (__utf8_mbtowc): Drop unnecessary test for
ch >= 0.

15 files changed:
newlib/ChangeLog
newlib/libc/stdio/vfprintf.c
newlib/libc/stdio/vfscanf.c
newlib/libc/stdlib/btowc.c
newlib/libc/stdlib/mblen.c
newlib/libc/stdlib/mblen_r.c
newlib/libc/stdlib/mbrtowc.c
newlib/libc/stdlib/mbstowcs_r.c
newlib/libc/stdlib/mbtowc.c
newlib/libc/stdlib/mbtowc_r.c
newlib/libc/stdlib/wcrtomb.c
newlib/libc/stdlib/wcsnrtombs.c
newlib/libc/stdlib/wcstombs_r.c
newlib/libc/stdlib/wctob.c
newlib/libc/stdlib/wctomb.c

index 8e8244328bc9042f717e0d5222197a129a71c0f8..74495ad2cf0e93c0ba52d88f53f1302c2191a211 100644 (file)
@@ -1,3 +1,33 @@
+2009-11-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * libc/stdio/vfprintf.c: Include ../stdlib/local.h.  Replace call to
+       _mbtowc_r with direct call to __mbtowc.
+       * libc/stdio/vfscanf.c: Ditto.
+       * libc/stdlib/btowc.c: Include local.h.  Replace call to _mbtowc_r
+       with direct call to __mbtowc.
+       * libc/stdlib/mblen.c: Ditto.
+       * libc/stdlib/mblen_r.c: Ditto.
+       * libc/stdlib/mbrtowc.c: Ditto.
+       * libc/stdlib/mbstowcs_r.c: Ditto.
+       * libc/stdlib/mbtowc.c: Ditto.
+       * libc/stdlib/wcrtomb.c: Include local.h.  Replace call to _wctomb_r
+       with direct call to __wctomb.
+       * libc/stdlib/wcsnrtombs.c: Ditto.
+       (_wcsnrtombs_r): Ditto.
+       * libc/stdlib/wcstombs_r.c: Ditto.
+       * libc/stdlib/wctob.c: Ditto.
+       * libc/stdlib/wctomb.c: Ditto.
+
+       * libc/stdlib/mbrtowc.c (mbrtowc): Implement independently from
+       _mbrtowc_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
+       defined.
+       * libc/stdlib/wcrtomb.c (wcrtomb): Implement independently from
+       _wcrtomb_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
+       defined.
+
+       * libc/stdlib/mbtowc_r.c (__utf8_mbtowc): Drop unnecessary test for
+       ch >= 0.
+
 2009-11-17  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
 
        * libm/common/fdlibm.h (logb, logbf): Move decls from here...
index 1d3119b4d9fa29c51f609958825df7149b34b4f7..773485885b564746eabcb9ea71a4344f8402689f 100644 (file)
@@ -159,6 +159,7 @@ static char *rcsid = "$Id$";
 #include <sys/lock.h>
 #include <stdarg.h>
 #include "local.h"
+#include "../stdlib/local.h"
 #include "fvwrite.h"
 #include "vfieeefp.h"
 
@@ -722,7 +723,8 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
        for (;;) {
                cp = fmt;
 #ifdef _MB_CAPABLE
-               while ((n = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
+               while ((n = __mbtowc (data, &wc, fmt, MB_CUR_MAX,
+                                     __locale_charset (), &state)) > 0) {
                     if (wc == '%')
                         break;
                     fmt += n;
@@ -1794,7 +1796,8 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt),
   while (*fmt && n >= numargs)
     {
 # ifdef _MB_CAPABLE
-      while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
+      while ((nbytes = __mbtowc (data, &wc, fmt, MB_CUR_MAX,
+                                __locale_charset (), &wc_state)) > 0)
        {
          fmt += nbytes;
          if (wc == '%')
index b24c9fb84400a75f03a99e342ab9a08561161bd0..065dc3e899194ed5b4f13e8eda71109f57e480ac 100644 (file)
@@ -122,6 +122,7 @@ Supporting OS subroutines required:
 #include <stdarg.h>
 #include <errno.h>
 #include "local.h"
+#include "../stdlib/local.h"
 
 #ifdef INTEGER_ONLY
 #define VFSCANF vfiscanf
@@ -506,7 +507,8 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
       wc = *fmt;
 #else
       memset (&state, '\0', sizeof (state));
-      nbytes = _mbtowc_r (rptr, &wc, fmt, MB_CUR_MAX, &state);
+      nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (),
+                        &state);
 #endif
       fmt += nbytes;
       if (wc == 0)
index 847d7ce1aa923940e753a83ba3f3f997feec2eee..f5ef4624a46cedfe226ad6dc9792ebbc71772fe1 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <reent.h>
 #include <string.h>
+#include "local.h"
 
 wint_t
 btowc (int c)
@@ -19,7 +20,7 @@ btowc (int c)
 
   _REENT_CHECK_MISC(_REENT);
 
-  retval = _mbtowc_r (_REENT, &pwc, &b, 1, &mbs);
+  retval = __mbtowc (_REENT, &pwc, &b, 1, __locale_charset (), &mbs);
 
   if (c == EOF || retval != 1)
     return WEOF;
index 6df27b93a097813c3cd01a4f21d582e99626c0ed..ace23889b192b2182416f19c8066894e9a535d8e 100644 (file)
@@ -46,6 +46,7 @@ effects vary with the locale.
 #include <newlib.h>
 #include <stdlib.h>
 #include <wchar.h>
+#include "local.h"
 
 int
 _DEFUN (mblen, (s, n), 
@@ -58,7 +59,7 @@ _DEFUN (mblen, (s, n),
   
   _REENT_CHECK_MISC(_REENT);
   state = &(_REENT_MBLEN_STATE(_REENT));
-  retval = _mbtowc_r (_REENT, NULL, s, n, state);
+  retval = __mbtowc (_REENT, NULL, s, n, __locale_charset (), state);
   if (retval < 0)
     {
       state->__count = 0;
index 9361f65733cf95da0dd5b032f4f0fce18d0fa836..c3b5964438c72e1b627ed6a2bc668013f193792b 100644 (file)
@@ -46,6 +46,7 @@ effects vary with the locale.
 #include <newlib.h>
 #include <stdlib.h>
 #include <wchar.h>
+#include "local.h"
 
 int
 _DEFUN (_mblen_r, (r, s, n, state), 
@@ -56,7 +57,7 @@ _DEFUN (_mblen_r, (r, s, n, state),
 {
 #ifdef _MB_CAPABLE
   int retval;
-  retval = _mbtowc_r (r, NULL, s, n, state);
+  retval = __mbtowc (r, NULL, s, n, __locale_charset (), state);
 
   if (retval < 0)
     {
index c5e700dc99f4df27ae3791cf4f0634dae0092649..e191e1158c7129129855404dbf905db25da5edff 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include "local.h"
 
 size_t
 _DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps),
@@ -25,9 +26,9 @@ _DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps),
 #endif
 
   if (s == NULL)
-    retval = _mbtowc_r (ptr, NULL, "", 1, ps);
+    retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps);
   else
-    retval = _mbtowc_r (ptr, pwc, s, n, ps);
+    retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps);
 
   if (retval == -1)
     {
@@ -47,6 +48,32 @@ _DEFUN (mbrtowc, (pwc, s, n, ps),
        size_t n _AND
        mbstate_t *ps)
 {
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
   return _mbrtowc_r (_REENT, pwc, s, n, ps);
+#else
+  int retval = 0;
+
+#ifdef _MB_CAPABLE
+  if (ps == NULL)
+    {
+      _REENT_CHECK_MISC(_REENT);
+      ps = &(_REENT_MBRTOWC_STATE(_REENT));
+    }
+#endif
+
+  if (s == NULL)
+    retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps);
+  else
+    retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
+
+  if (retval == -1)
+    {
+      ps->__count = 0;
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+#endif /* not PREFER_SIZE_OVER_SPEED */
 }
 #endif /* !_REENT_ONLY */
index 3dd73e42c975354749e6395d9276ea594d11ec94..3ba8677112dbb0e7c5329f7f72422c8f09370473 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <wchar.h>
+#include "local.h"
 
 size_t
 _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
@@ -17,7 +18,7 @@ _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
     n = (size_t) 1; /* Value doesn't matter as long as it's not 0. */
   while (n > 0)
     {
-      bytes = _mbtowc_r (r, pwcs, t, MB_CUR_MAX, state);
+      bytes = __mbtowc (r, pwcs, t, MB_CUR_MAX, __locale_charset (), state);
       if (bytes < 0)
        {
          state->__count = 0;
index 3f34b8a28d252d0b1d6d8741dcb09a6926814b9f..83b6a0edac3acfe0c1cdce4faea94a84c9f24827 100644 (file)
@@ -54,6 +54,7 @@ effects vary with the locale.
 #include <newlib.h>
 #include <stdlib.h>
 #include <wchar.h>
+#include "local.h"
 
 int
 _DEFUN (mbtowc, (pwc, s, n),
@@ -68,7 +69,7 @@ _DEFUN (mbtowc, (pwc, s, n),
   _REENT_CHECK_MISC(_REENT);
   ps = &(_REENT_MBTOWC_STATE(_REENT));
   
-  retval = _mbtowc_r (_REENT, pwc, s, n, ps);
+  retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
   
   if (retval < 0)
     {
index 0fa57fafdfa875d4f8338277e7c967591b2c34ac..863404fcb56ff7f2fa6c547d5ff098621f64a905 100644 (file)
@@ -221,7 +221,7 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
       return 0; /* s points to the null character */
     }
 
-  if (ch >= 0x0 && ch <= 0x7f)
+  if (ch <= 0x7f)
     {
       /* single-byte sequence */
       state->__count = 0;
index 06e487471ca42cc4c895b53d2a31c49d57b85646..60e0d89c8b1fcd97cb46179dac306887e7591c4a 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include "local.h"
 
 size_t
 _DEFUN (_wcrtomb_r, (ptr, s, wc, ps),
@@ -24,9 +25,9 @@ _DEFUN (_wcrtomb_r, (ptr, s, wc, ps),
 #endif
 
   if (s == NULL)
-    retval = _wctomb_r (ptr, buf, L'\0', ps);
+    retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps);
   else
-    retval = _wctomb_r (ptr, s, wc, ps);
+    retval = __wctomb (ptr, s, wc, __locale_charset (), ps);
 
   if (retval == -1)
     {
@@ -45,6 +46,33 @@ _DEFUN (wcrtomb, (s, wc, ps),
        wchar_t wc _AND
        mbstate_t *ps)
 {
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
   return _wcrtomb_r (_REENT, s, wc, ps);
+#else
+  int retval = 0;
+  char buf[10];
+
+#ifdef _MB_CAPABLE
+  if (ps == NULL)
+    {
+      _REENT_CHECK_MISC(_REENT);
+      ps = &(_REENT_WCRTOMB_STATE(_REENT));
+    }
+#endif
+
+  if (s == NULL)
+    retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps);
+  else
+    retval = __wctomb (_REENT, s, wc, __locale_charset (), ps);
+
+  if (retval == -1)
+    {
+      ps->__count = 0;
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+#endif /* not PREFER_SIZE_OVER_SPEED */
 }
 #endif /* !_REENT_ONLY */
index a8e6901a3db73c5b57c3cd5753ccb2b01fac9438..5f885a454ca17f6770470b15b100d86c810053b1 100644 (file)
@@ -99,6 +99,7 @@ PORTABILITY
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include "local.h"
 
 size_t
 _DEFUN (_wcsnrtombs_r, (r, dst, src, nwc, len, ps),
@@ -134,7 +135,7 @@ _DEFUN (_wcsnrtombs_r, (r, dst, src, nwc, len, ps),
     {
       int count = ps->__count;
       wint_t wch = ps->__value.__wch;
-      int bytes = _wcrtomb_r (r, buff, *pwcs, ps);
+      int bytes = __wctomb (r, buff, *pwcs, __locale_charset (), ps);
       if (bytes == -1)
        {
          r->_errno = EILSEQ;
@@ -160,7 +161,7 @@ _DEFUN (_wcsnrtombs_r, (r, dst, src, nwc, len, ps),
        }
       else
        {
-         /* not enough room, we must back up state to before _wctomb_r call */
+         /* not enough room, we must back up state to before __wctomb call */
          ps->__count = count;
          ps->__value.__wch = wch;
           len = 0;
index dd82bd38357187d97bb409524426eaddc10d1fb9..7017a10b1d8bb806a565525e2befe18f0bfe6e72 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <wchar.h>
+#include "local.h"
 
 size_t
 _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
@@ -18,14 +19,14 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
     {
       size_t num_bytes = 0;
       while (*pwcs != 0)
-         num_bytes += _wctomb_r (r, buff, *pwcs++, state);
+         num_bytes += __wctomb (r, buff, *pwcs++, __locale_charset (), state);
       return num_bytes;
     }
   else
     {
       while (n > 0)
         {
-          int bytes = _wctomb_r (r, buff, *pwcs, state);
+          int bytes = __wctomb (r, buff, *pwcs, __locale_charset (), state);
           if (bytes == -1)
             return -1;
           num_to_copy = (n > bytes ? bytes : (int)n);
index 37f7f953f965f17b6113e3cbb9c573c5115b29c9..927c1a7a83c5b151f751f7576d930937e48eaaad 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "local.h"
 
 int
 wctob (wint_t c)
@@ -16,7 +17,7 @@ wctob (wint_t c)
 
   _REENT_CHECK_MISC(_REENT);
 
-  retval = _wctomb_r (_REENT, &pwc, c, &mbs);
+  retval = __wctomb (_REENT, &pwc, c, __locale_charset (), &mbs);
 
   if (c == EOF || retval != 1)
     return WEOF;
index 2ab7b0339880f2dc4838c81971103ab9a588870f..9e82eaaba02abc38f8b1580f8dbf80044716b2c3 100644 (file)
@@ -49,6 +49,7 @@ effects vary with the locale.
 #include <newlib.h>
 #include <stdlib.h>
 #include <errno.h>
+#include "local.h"
 
 int
 _DEFUN (wctomb, (s, wchar),
@@ -58,7 +59,8 @@ _DEFUN (wctomb, (s, wchar),
 #ifdef _MB_CAPABLE
         _REENT_CHECK_MISC(_REENT);
 
-        return _wctomb_r (_REENT, s, wchar, &(_REENT_WCTOMB_STATE(_REENT)));
+        return __wctomb (_REENT, s, wchar, __locale_charset (),
+                        &(_REENT_WCTOMB_STATE(_REENT)));
 #else /* not _MB_CAPABLE */
         if (s == NULL)
                 return 0;
This page took 0.066724 seconds and 5 git commands to generate.