Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2002-08-23 05:56:05 +0400
committerThomas Fitzsimmons <fitzsim@redhat.com>2002-08-23 05:56:05 +0400
commit8d9112f2f3ac7c0aa656ceb8da7b4248df228833 (patch)
tree237c3983e83fb5bd0ccbfff91a30844b7906afd3 /newlib/libc/stdlib/mbtowc_r.c
parent1c5dcf3b0a42efcc8a7fcac148e2714d9766b871 (diff)
* libc/include/langinfo.h: New file.
* libc/include/wchar.h: Likewise. * libc/include/sys/syslimits.h: Likewise. * libc/locale/fix_grouping.c: Likewise. * libc/locale/ldpart.c: Likewise. * libc/locale/ldpart.h: Likewise. * libc/locale/lmessages.c: Likewise. * libc/locale/lmessages.h: Likewise. * libc/locale/lmonetary.c: Likewise. * libc/locale/lmonetary.h: Likewise. * libc/locale/lnumeric.c: Likewise. * libc/locale/lnumeric.h: Likewise. * libc/locale/nl_langinfo.3: Likewise. * libc/locale/nl_langinfo.c: Likewise. * libc/locale/timelocal.c: Likewise. * libc/locale/timelocal.h: Likewise. * libc/stdlib/btowc.c: Likewise. * libc/stdlib/mbrlen.c: Likewise. * libc/stdlib/mbrtowc.c: Likewise. * libc/stdlib/mbsinit.c: Likewise. * libc/stdlib/mbsrtowcs.c: Likewise. * libc/stdlib/wcrtomb.c: Likewise. * libc/stdlib/wcsrtombs.c: Likewise. * libc/stdlib/wctob.c: Likewise. * libc/sys/linux/prof-freq.c: Likewise. * libc/sys/linux/profile.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/include/stdlib.h: Change re-entrant functions to take mbstate_t pointers. * libc/include/sys/_types.h: Define _mbstate_t. * libc/include/sys/config.h (MB_LEN_MAX): New macro. * libc/include/sys/errno.h (EILSEQ): New error code. * libc/include/sys/reent.h: Include wchar.h. Change reentrant structure to use mbstate_t. * libc/locale/Makefile.am (LIB_SOURCES): Add new files. * libc/machine/powerpc/vfprintf.c: Use mbstate_t. * libc/machine/powerpc/vfscanf.c: Likewise. * libc/stdio/getdelim.c: Reallocate buffer only when necessary. * libc/stdio/vfprintf.c: Likewise. * libc/stdio/vfscanf.c: Likewise. * libc/stdlib/Makefile.am (LIB_SOURCES): Add new files. * libc/stdlib/mblen.c: Use mbstate_t. * libc/stdlib/mblen_r.c: Likewise. * libc/stdlib/mbstowcs.c: Likewise. * libc/stdlib/mbstowcs_r.c: Likewise. * libc/stdlib/mbtowc.c: Likewise. * libc/stdlib/mbtowc_r.c: Likewise. * libc/stdlib/wcstombs.c: Likewise. * libc/stdlib/wcstombs_r.c: Likewise. * libc/stdlib/wctomb_r.c: Likewise. * libc/sys/linux/Makefile.am (LIB_SOURCES): Add prof-freq.c and profile.c. * libc/sys/linux/machine/i386/Makefile.am (LIB_SOURCES): Add dl-procinfo.c. * libc/sys/linux/sys/errno.h (EILSEQ): New error code. * libc/sys/linux/sys/types.h (off_t): Define type. * testsuite/newlib.locale/UTF-8.c: Change locale name from UTF-8 to C-UTF-8. * testsuite/newlib.locale/UTF-8.exp: Likewise.
Diffstat (limited to 'newlib/libc/stdlib/mbtowc_r.c')
-rw-r--r--newlib/libc/stdlib/mbtowc_r.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c
index 866789f16..b7909d318 100644
--- a/newlib/libc/stdlib/mbtowc_r.c
+++ b/newlib/libc/stdlib/mbtowc_r.c
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <locale.h>
#include "mbctype.h"
+#include <wchar.h>
+#include <string.h>
#ifdef MB_CAPABLE
typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J,
@@ -51,7 +53,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
wchar_t *pwc _AND
const char *s _AND
size_t n _AND
- int *state)
+ mbstate_t *state)
{
wchar_t dummy;
unsigned char *t = (unsigned char *)s;
@@ -60,13 +62,13 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
pwc = &dummy;
if (s != NULL && n == 0)
- return -1;
+ return -2;
#ifdef MB_CAPABLE
if (r->_current_locale == NULL ||
(strlen (r->_current_locale) <= 1))
{ /* fall-through */ }
- else if (!strcmp (r->_current_locale, "UTF-8"))
+ else if (!strcmp (r->_current_locale, "C-UTF-8"))
{
wchar_t char1 = 0;
@@ -139,7 +141,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return 3;
}
else
- return -1;
+ return -2;
}
else if (char1 >= 0xf0 && char1 <= 0xf7)
{
@@ -172,7 +174,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return 4;
}
else
- return -1;
+ return -2;
}
else if (char1 >= 0xf8 && char1 <= 0xfb)
{
@@ -208,7 +210,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return 5;
}
else
- return -1;
+ return -2;
}
else if (char1 >= 0xfc && char1 <= 0xfd)
{
@@ -248,7 +250,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return 6;
}
else
- return -1;
+ return -2;
}
else
return -1;
@@ -263,7 +265,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
{
int char2 = t[1];
if (n <= 1)
- return -1;
+ return -2;
if (_issjis2 (char2))
{
*pwc = (((wchar_t)*t) << 8) + (wchar_t)(*(t+1));
@@ -283,7 +285,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
{
int char2 = t[1];
if (n <= 1)
- return -1;
+ return -2;
if (_iseucjp (char2))
{
*pwc = (((wchar_t)*t) << 8) + (wchar_t)(*(t+1));
@@ -303,11 +305,11 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
if (s == NULL)
{
- *state = 0;
+ state->__count = 0;
return 1; /* state-dependent */
}
- curr_state = (*state == 0 ? ASCII : JIS);
+ curr_state = (state->__count == 0 ? ASCII : JIS);
ptr = t;
for (i = 0; i < n; ++i)
@@ -351,19 +353,19 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
case NOOP:
break;
case EMPTY:
- *state = 0;
+ state->__count = 0;
*pwc = (wchar_t)0;
return i;
case COPY_A:
- *state = 0;
+ state->__count = 0;
*pwc = (wchar_t)*ptr;
return (i + 1);
case COPY_J:
- *state = 0;
+ state->__count = 0;
*pwc = (((wchar_t)*ptr) << 8) + (wchar_t)(*(ptr+1));
return (i + 1);
case COPY_J2:
- *state = 1;
+ state->__count = 1;
*pwc = (((wchar_t)*ptr) << 8) + (wchar_t)(*(ptr+1));
return (ptr - t) + 2;
case MAKE_A:
@@ -377,7 +379,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
}
- return -1; /* n < bytes needed */
+ return -2; /* n < bytes needed */
}
#endif /* MB_CAPABLE */
@@ -392,4 +394,3 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return 1;
}
-