diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 06959f60f..19e7ebd3b 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,32 @@ +2004-04-23 Artem B. Bityuckiy + + * configure.in: Define _MB_CAPABLE if mb supported. + * configure: Regenerated. + * configure.host: Remove manual setting of MB_CAPABLE compiler + flag. + * newlib.hin: Add _MB_CAPABLE flag. + * libc/ctype/iswalpha.c, libc/ctype/iswblank.c: Include + and check for _MB_CAPABLE flag instead of MB_CAPABLE. + * libc/ctype/iswcntrl.c, libc/ctype/iswprint.c: Ditto. + * libc/ctype/iswpunct.c, libc/ctype/iswspace.c: Ditto. + * libc/ctype/jp2uc.c: Ditto. + * libc/ctype/towlower.c, libc/ctype/towupper.c: Ditto. + * libc/locale/locale.c: Ditto + * libc/machine/powerpc/vfscanf.c: Ditto + * libc/stdio/vfprintf.c, libc/stdio/vfscanf.c: Ditto + * libc/stdlib/mblen.c: Ditto + * libc/stdlib/mblen_r.c, libc/stdlib/mbrlen.c: Ditto + * libc/stdlib/mbrtowc.c, libc/stdlib/mbsrtowcs.c: Ditto + * libc/stdlib/mbstowcs.c, libc/stdlib/mbtowc.c: Ditto + * libc/stdlib/mbtowc_r.c, libc/stdlib/wcrtomb.c: Ditto + * libc/stdlib/wcsrtombs.c, libc/stdlib/wcstombs.c: Ditto + * libc/stdlib/wctomb.c, libc/sys/linux/intl/dcigettext.c: Ditto + * libc/sys/linux/intl/explodename.c: Ditto + * libc/sys/linux/intl/finddomain.c: Ditto + * libc/sys/linux/intl/l10nflist.c: Ditto + * libc/sys/linux/intl/loadmsgcat.c: Ditto + * libc/sys/linux/intl/localealias.c: Ditto + 2004-04-23 Jeff Johnston * libc/machine/powerpc/vfscanf.c (NNZDIGITS): New define. diff --git a/newlib/configure b/newlib/configure index 05c5ae95a..eec333cf1 100755 --- a/newlib/configure +++ b/newlib/configure @@ -3206,6 +3206,10 @@ EOF fi if test "${newlib_mb}" = "yes"; then +cat >> confdefs.h <> confdefs.h < +#include #include #include #include #include "local.h" -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE #include "utf8alpha.h" -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ int _DEFUN(iswalpha,(c), wint_t c) @@ -74,7 +75,7 @@ _DEFUN(iswalpha,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -335,7 +336,7 @@ _DEFUN(iswalpha,(c), wint_t c) /* not in table */ return 0; } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < (wint_t)0x100 ? isalpha (c) : 0); } diff --git a/newlib/libc/ctype/iswblank.c b/newlib/libc/ctype/iswblank.c index 8834e954d..b10756d5e 100644 --- a/newlib/libc/ctype/iswblank.c +++ b/newlib/libc/ctype/iswblank.c @@ -56,6 +56,7 @@ PORTABILITY No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include @@ -70,7 +71,7 @@ _DEFUN(iswblank,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -98,7 +99,7 @@ _DEFUN(iswblank,(c), wint_t c) (c >= 0x2008 && c <= 0x200b) || c == 0x205f || c == 0x3000); } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < 0x100 ? isblank (c) : 0); } diff --git a/newlib/libc/ctype/iswcntrl.c b/newlib/libc/ctype/iswcntrl.c index b33af01ee..d09295225 100644 --- a/newlib/libc/ctype/iswcntrl.c +++ b/newlib/libc/ctype/iswcntrl.c @@ -56,6 +56,7 @@ PORTABILITY No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include @@ -70,7 +71,7 @@ _DEFUN(iswcntrl,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -97,7 +98,7 @@ _DEFUN(iswcntrl,(c), wint_t c) (c >= 0x007f && c <= 0x009f) || c == 0x2028 || c == 0x2029); } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < 0x100 ? iscntrl (c) : 0); } diff --git a/newlib/libc/ctype/iswprint.c b/newlib/libc/ctype/iswprint.c index 5acba9cd7..f4ec08752 100644 --- a/newlib/libc/ctype/iswprint.c +++ b/newlib/libc/ctype/iswprint.c @@ -56,14 +56,15 @@ PORTABILITY No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include #include "local.h" -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE #include "utf8print.h" -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ int _DEFUN(iswprint,(c), wint_t c) @@ -74,7 +75,7 @@ _DEFUN(iswprint,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -390,7 +391,7 @@ _DEFUN(iswprint,(c), wint_t c) /* not in table */ return 0; } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < (wint_t)0x100 ? isprint (c) : 0); } diff --git a/newlib/libc/ctype/iswpunct.c b/newlib/libc/ctype/iswpunct.c index 716fe5f62..88442b6ca 100644 --- a/newlib/libc/ctype/iswpunct.c +++ b/newlib/libc/ctype/iswpunct.c @@ -56,14 +56,15 @@ PORTABILITY No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include #include "local.h" -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE #include "utf8punct.h" -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ int _DEFUN(iswpunct,(c), wint_t c) @@ -74,7 +75,7 @@ _DEFUN(iswpunct,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -325,7 +326,7 @@ _DEFUN(iswpunct,(c), wint_t c) /* not in table */ return 0; } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < (wint_t)0x100 ? ispunct (c) : 0); } diff --git a/newlib/libc/ctype/iswspace.c b/newlib/libc/ctype/iswspace.c index cd3d85a7c..f4d0a0b91 100644 --- a/newlib/libc/ctype/iswspace.c +++ b/newlib/libc/ctype/iswspace.c @@ -56,6 +56,7 @@ PORTABILITY No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include @@ -70,7 +71,7 @@ _DEFUN(iswspace,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -99,7 +100,7 @@ _DEFUN(iswspace,(c), wint_t c) c == 0x2028 || c == 0x2029 || c == 0x205f || c == 0x3000); } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < 0x100 ? isspace (c) : 0); } diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c index 044c76b86..9d26a7a68 100644 --- a/newlib/libc/ctype/jp2uc.c +++ b/newlib/libc/ctype/jp2uc.c @@ -29,7 +29,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE #include <_ansi.h> #include @@ -140,4 +142,4 @@ _DEFUN (__jp2uc, (c, type), wint_t c _AND int type) return WEOF; } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ diff --git a/newlib/libc/ctype/towlower.c b/newlib/libc/ctype/towlower.c index a0b03b8c5..5c36a31a6 100644 --- a/newlib/libc/ctype/towlower.c +++ b/newlib/libc/ctype/towlower.c @@ -59,6 +59,7 @@ No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include @@ -75,7 +76,7 @@ _DEFUN(towlower,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -471,7 +472,7 @@ _DEFUN(towlower,(c), wint_t c) return 0x00e5; } } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < 0x00ff ? (wint_t)(tolower ((int)c)) : c); } diff --git a/newlib/libc/ctype/towupper.c b/newlib/libc/ctype/towupper.c index b14e5aa07..530aebf3a 100644 --- a/newlib/libc/ctype/towupper.c +++ b/newlib/libc/ctype/towupper.c @@ -59,6 +59,7 @@ No supporting OS subroutines are required. */ #include <_ansi.h> +#include #include #include #include @@ -75,7 +76,7 @@ _DEFUN(towupper,(c), wint_t c) unicode = 0; /* fall-through */ } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE else if (!strcmp (__lc_ctype, "C-JIS")) { c = __jp2uc (c, JP_JIS); @@ -498,7 +499,7 @@ _DEFUN(towupper,(c), wint_t c) return (c - 0x28); } } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ return (c < 0x00ff ? (wint_t)(toupper ((int)c)) : c); } diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c index 66c93d740..d48a53a87 100644 --- a/newlib/libc/locale/locale.c +++ b/newlib/libc/locale/locale.c @@ -44,7 +44,7 @@ locale. This is a minimal implementation, supporting only the required <<"C">> value for <[locale]>; strings representing other locales are not -honored unless MB_CAPABLE is defined in which case three new +honored unless _MB_CAPABLE is defined in which case three new extensions are allowed for LC_CTYPE or LC_MESSAGES only: <<"C-JIS">>, <<"C-EUCJP">>, <<"C-SJIS">>, or <<"C-ISO-8859-1">>. (<<"">> is also accepted; it represents the default locale @@ -86,6 +86,7 @@ No supporting OS subroutines are required. * (Only "C" or null supported). */ +#include #include #include #include @@ -120,7 +121,7 @@ _DEFUN(_setlocale_r, (p, category, locale), int category _AND _CONST char *locale) { -#ifndef MB_CAPABLE +#ifndef _MB_CAPABLE if (locale) { if (strcmp (locale, "C") && strcmp (locale, "")) diff --git a/newlib/libc/machine/powerpc/vfscanf.c b/newlib/libc/machine/powerpc/vfscanf.c index add121111..00aafb508 100644 --- a/newlib/libc/machine/powerpc/vfscanf.c +++ b/newlib/libc/machine/powerpc/vfscanf.c @@ -103,6 +103,7 @@ Supporting OS subroutines required: */ #include <_ansi.h> +#include #include #include #include @@ -279,7 +280,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) char buf[BUF]; /* buffer for numeric conversions */ vec_union vec_buf; char *lptr; /* literal pointer */ -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE mbstate_t state; /* value to keep track of multibyte state */ #endif @@ -304,7 +305,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) nread = 0; for (;;) { -#ifndef MB_CAPABLE +#ifndef _MB_CAPABLE wc = *fmt; #else memset (&state, '\0', sizeof (state)); diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index b61c78d2c..ab40b2f6c 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -180,6 +180,7 @@ static char *rcsid = "$Id$"; #endif #include <_ansi.h> +#include #include #include #include @@ -440,7 +441,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), struct __siov iov[NIOV];/* ... and individual io vectors */ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ char ox[2]; /* space for 0x hex-prefix */ -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE wchar_t wc; mbstate_t state; /* mbtowc calls from library must not change state */ #endif @@ -457,7 +458,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), static _CONST char zeroes[PADSIZE] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE memset (&state, '\0', sizeof (state)); #endif /* @@ -560,7 +561,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), */ for (;;) { cp = fmt; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE while ((n = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &state)) > 0) { if (wc == '%') break; @@ -574,7 +575,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), PRINT (cp, m); ret += m; } -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (n <= 0) goto done; #else @@ -1491,7 +1492,7 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), int pos, last_arg; int max_pos_arg = n; enum types { INT, LONG_INT, SHORT_INT, QUAD_INT, CHAR, CHAR_PTR, DOUBLE, LONG_DOUBLE, WIDE_CHAR }; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE wchar_t wc; mbstate_t wc_state; int nbytes; @@ -1501,7 +1502,7 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), if (*last_fmt != NULL) fmt = *last_fmt; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE memset (&wc_state, '\0', sizeof (wc_state)); #endif @@ -1509,7 +1510,7 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), read the desired parameter from the vararg list. */ while (*fmt && n >= numargs) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) { fmt += nbytes; diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 7e4f335bc..7f83e16bf 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -103,6 +103,7 @@ Supporting OS subroutines required: */ #include <_ansi.h> +#include #include #include #include @@ -293,7 +294,7 @@ _DEFUN(__svfscanf_r, (rptr, fp, fmt0, ap), nread = 0; for (;;) { -#ifndef MB_CAPABLE +#ifndef _MB_CAPABLE wc = *fmt; #else memset (&state, '\0', sizeof (state)); diff --git a/newlib/libc/stdlib/mblen.c b/newlib/libc/stdlib/mblen.c index b1310956f..6df27b93a 100644 --- a/newlib/libc/stdlib/mblen.c +++ b/newlib/libc/stdlib/mblen.c @@ -16,20 +16,20 @@ TRAD_SYNOPSIS size_t <[n]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <>. In this case, the only ``multi-byte character sequences'' recognized are single bytes, and thus <<1>> is returned unless <[s]> is the null pointer or has a length of 0 or is the empty string. -When MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. RETURNS This implementation of <> returns <<0>> if -<[s]> is <> or the empty string; it returns <<1>> if not MB_CAPABLE or +<[s]> is <> or the empty string; it returns <<1>> if not _MB_CAPABLE or the character is a single-byte character; it returns <<-1>> if the multi-byte character is invalid; otherwise it returns the number of bytes in the multibyte character. @@ -43,6 +43,7 @@ effects vary with the locale. #ifndef _REENT_ONLY +#include #include #include @@ -51,7 +52,7 @@ _DEFUN (mblen, (s, n), const char *s _AND size_t n) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE int retval = 0; mbstate_t *state; @@ -66,13 +67,13 @@ _DEFUN (mblen, (s, n), else return retval; -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ if (s == NULL || *s == '\0') return 0; if (n == 0) return -1; return 1; -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/stdlib/mblen_r.c b/newlib/libc/stdlib/mblen_r.c index 1d6659743..9361f6573 100644 --- a/newlib/libc/stdlib/mblen_r.c +++ b/newlib/libc/stdlib/mblen_r.c @@ -18,20 +18,20 @@ TRAD_SYNOPSIS int *<[state]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <<_mblen_r>>. In this case, the only ``multi-byte character sequences'' recognized are single bytes, and thus <<1>> is returned unless <[s]> is the null pointer or has a length of 0 or is the empty string. -When MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. RETURNS This implementation of <<_mblen_r>> returns <<0>> if -<[s]> is <> or the empty string; it returns <<1>> if not MB_CAPABLE or +<[s]> is <> or the empty string; it returns <<1>> if not _MB_CAPABLE or the character is a single-byte character; it returns <<-1>> if the multi-byte character is invalid; otherwise it returns the number of bytes in the multibyte character. @@ -43,6 +43,7 @@ effects vary with the locale. <<_mblen_r>> requires no supporting OS subroutines. */ +#include #include #include @@ -53,7 +54,7 @@ _DEFUN (_mblen_r, (r, s, n, state), size_t n _AND mbstate_t *state) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE int retval; retval = _mbtowc_r (r, NULL, s, n, state); @@ -64,12 +65,12 @@ _DEFUN (_mblen_r, (r, s, n, state), } return retval; -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ if (s == NULL || *s == '\0') return 0; if (n == 0) return -1; return 1; -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } diff --git a/newlib/libc/stdlib/mbrlen.c b/newlib/libc/stdlib/mbrlen.c index cf14add86..ac9aa324f 100644 --- a/newlib/libc/stdlib/mbrlen.c +++ b/newlib/libc/stdlib/mbrlen.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,7 +8,7 @@ size_t mbrlen(const char *s, size_t n, mbstate_t *ps) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (ps == NULL) { _REENT_CHECK_MISC(_REENT); diff --git a/newlib/libc/stdlib/mbrtowc.c b/newlib/libc/stdlib/mbrtowc.c index 3a9659243..c5e700dc9 100644 --- a/newlib/libc/stdlib/mbrtowc.c +++ b/newlib/libc/stdlib/mbrtowc.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -15,7 +16,7 @@ _DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps), { int retval = 0; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (ps == NULL) { _REENT_CHECK_MISC(ptr); diff --git a/newlib/libc/stdlib/mbsrtowcs.c b/newlib/libc/stdlib/mbsrtowcs.c index d050bf837..2eaa0fe56 100644 --- a/newlib/libc/stdlib/mbsrtowcs.c +++ b/newlib/libc/stdlib/mbsrtowcs.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -18,7 +19,7 @@ _DEFUN (_mbsrtowcs_r, (r, dst, src, n, ps), size_t count = 0; int bytes; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (ps == NULL) { _REENT_CHECK_MISC(r); diff --git a/newlib/libc/stdlib/mbstowcs.c b/newlib/libc/stdlib/mbstowcs.c index cb09f31d0..334b5f54d 100644 --- a/newlib/libc/stdlib/mbstowcs.c +++ b/newlib/libc/stdlib/mbstowcs.c @@ -17,13 +17,13 @@ TRAD_SYNOPSIS size_t <[n]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <>. In this case, the only ``multi-byte character sequences'' recognized are single bytes, and they are ``converted'' to wide-char versions simply by byte extension. -When MB_CAPABLE is defined, this routine calls <<_mbstowcs_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_mbstowcs_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. @@ -31,7 +31,7 @@ be restricted to a defined set of locales. RETURNS This implementation of <> returns <<0>> if <[s]> is <> or is the empty string; -it returns <<-1>> if MB_CAPABLE and one of the +it returns <<-1>> if _MB_CAPABLE and one of the multi-byte characters is invalid or incomplete; otherwise it returns the minimum of: <> or the number of multi-byte characters in <> plus 1 (to @@ -49,6 +49,7 @@ effects vary with the locale. #ifndef _REENT_ONLY +#include #include #include @@ -58,12 +59,12 @@ _DEFUN (mbstowcs, (pwcs, s, n), const char *s _AND size_t n) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE mbstate_t state; state.__count = 0; return _mbstowcs_r (_REENT, pwcs, s, n, &state); -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ int count = 0; @@ -76,7 +77,7 @@ _DEFUN (mbstowcs, (pwcs, s, n), } return count; -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/stdlib/mbtowc.c b/newlib/libc/stdlib/mbtowc.c index e1e725dbf..3f34b8a28 100644 --- a/newlib/libc/stdlib/mbtowc.c +++ b/newlib/libc/stdlib/mbtowc.c @@ -17,7 +17,7 @@ TRAD_SYNOPSIS size_t <[n]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <>. In this case, only ``multi-byte character sequences'' recognized are single bytes, and they are ``converted'' to themselves. @@ -25,7 +25,7 @@ Each call to <> copies one character from <<*<[s]>>> to <<*<[pwc]>>>, unless <[s]> is a null pointer. The argument n is ignored. -When MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. @@ -33,7 +33,7 @@ be restricted to a defined set of locales. RETURNS This implementation of <> returns <<0>> if <[s]> is <> or is the empty string; -it returns <<1>> if not MB_CAPABLE or +it returns <<1>> if not _MB_CAPABLE or the character is a single-byte character; it returns <<-1>> if n is <<0>> or the multi-byte character is invalid; otherwise it returns the number of bytes in the multibyte character. @@ -51,6 +51,7 @@ effects vary with the locale. #ifndef _REENT_ONLY +#include #include #include @@ -60,7 +61,7 @@ _DEFUN (mbtowc, (pwc, s, n), const char *s _AND size_t n) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE int retval = 0; mbstate_t *ps; @@ -75,7 +76,7 @@ _DEFUN (mbtowc, (pwc, s, n), return -1; } return retval; -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ if (s == NULL) return 0; if (n == 0) @@ -83,7 +84,7 @@ _DEFUN (mbtowc, (pwc, s, n), if (pwc) *pwc = (wchar_t) *s; return (*s != '\0'); -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index c7c7effca..7f0dd11aa 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -1,10 +1,11 @@ +#include #include #include #include "mbctype.h" #include #include -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J, NUL, JIS_CHAR, OTHER, JIS_C_NUM } JIS_CHAR_TYPE; typedef enum { ASCII, JIS, A_ESC, A_ESC_DL, JIS_1, J_ESC, J_ESC_BR, @@ -39,7 +40,7 @@ static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = { /* J_ESC */ { ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR }, /* J_ESC_BR */{ ERROR, ERROR, ERROR, ERROR, MAKE_A, MAKE_A, ERROR, ERROR, ERROR }, }; -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ /* we override the mbstate_t __count field for more complex encodings and use it store a state value */ #define __state __count @@ -63,7 +64,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state), if (s != NULL && n == 0) return -2; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (__lc_ctype == NULL || (strlen (__lc_ctype) <= 1)) { /* fall-through */ } @@ -455,7 +456,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state), state->__state = curr_state; return -2; /* n < bytes needed */ } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ /* otherwise this must be the "C" locale or unknown locale */ if (s == NULL) diff --git a/newlib/libc/stdlib/wcrtomb.c b/newlib/libc/stdlib/wcrtomb.c index fbd71b1e2..06e487471 100644 --- a/newlib/libc/stdlib/wcrtomb.c +++ b/newlib/libc/stdlib/wcrtomb.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -14,7 +15,7 @@ _DEFUN (_wcrtomb_r, (ptr, s, wc, ps), int retval = 0; char buf[10]; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (ps == NULL) { _REENT_CHECK_MISC(ptr); diff --git a/newlib/libc/stdlib/wcsrtombs.c b/newlib/libc/stdlib/wcsrtombs.c index 8c55b0878..6871d0c00 100644 --- a/newlib/libc/stdlib/wcsrtombs.c +++ b/newlib/libc/stdlib/wcsrtombs.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -18,7 +19,7 @@ _DEFUN (_wcsrtombs_r, (r, dst, src, len, ps), size_t n; int i; -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE if (ps == NULL) { _REENT_CHECK_MISC(r); diff --git a/newlib/libc/stdlib/wcstombs.c b/newlib/libc/stdlib/wcstombs.c index f02d4ab1f..83e48da93 100644 --- a/newlib/libc/stdlib/wcstombs.c +++ b/newlib/libc/stdlib/wcstombs.c @@ -17,12 +17,12 @@ TRAD_SYNOPSIS size_t <[n]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <>. In this case, all wide-characters are expected to represent single bytes and so are converted simply by casting to char. -When MB_CAPABLE is defined, this routine calls <<_wcstombs_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_wcstombs_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. @@ -30,7 +30,7 @@ be restricted to a defined set of locales. RETURNS This implementation of <> returns <<0>> if <[s]> is <> or is the empty string; -it returns <<-1>> if MB_CAPABLE and one of the +it returns <<-1>> if _MB_CAPABLE and one of the wide-char characters does not represent a valid multi-byte character; otherwise it returns the minimum of: <> or the number of bytes that are transferred to <>, not including the @@ -50,6 +50,7 @@ effects vary with the locale. #ifndef _REENT_ONLY +#include #include #include @@ -59,12 +60,12 @@ _DEFUN (wcstombs, (s, pwcs, n), const wchar_t *pwcs _AND size_t n) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE mbstate_t state; state.__count = 0; return _wcstombs_r (_REENT, s, pwcs, n, &state); -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ int count = 0; if (n != 0) { @@ -76,7 +77,7 @@ _DEFUN (wcstombs, (s, pwcs, n), } return count; -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/stdlib/wctomb.c b/newlib/libc/stdlib/wctomb.c index 5cff10fff..f2c62496f 100644 --- a/newlib/libc/stdlib/wctomb.c +++ b/newlib/libc/stdlib/wctomb.c @@ -16,24 +16,24 @@ TRAD_SYNOPSIS wchar_t <[wchar]>; DESCRIPTION -When MB_CAPABLE is not defined, this is a minimal ANSI-conforming +When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming implementation of <>. The only ``wide characters'' recognized are single bytes, and they are ``converted'' to themselves. -When MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform +When _MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform the conversion, passing a state variable to allow state dependent decoding. The result is based on the locale setting which may be restricted to a defined set of locales. Each call to <> modifies <<*<[s]>>> unless <[s]> is a null -pointer or MB_CAPABLE is defined and <[wchar]> is invalid. +pointer or _MB_CAPABLE is defined and <[wchar]> is invalid. RETURNS This implementation of <> returns <<0>> if -<[s]> is <>; it returns <<-1>> if MB_CAPABLE is enabled +<[s]> is <>; it returns <<-1>> if _MB_CAPABLE is enabled and the wchar is not a valid multi-byte character, it returns <<1>> -if MB_CAPABLE is not defined or the wchar is in reality a single +if _MB_CAPABLE is not defined or the wchar is in reality a single byte character, otherwise it returns the number of bytes in the multi-byte character. @@ -46,6 +46,7 @@ effects vary with the locale. #ifndef _REENT_ONLY +#include #include int @@ -53,17 +54,17 @@ _DEFUN (wctomb, (s, wchar), char *s _AND wchar_t wchar) { -#ifdef MB_CAPABLE +#ifdef _MB_CAPABLE _REENT_CHECK_MISC(_REENT); return _wctomb_r (_REENT, s, wchar, &(_REENT_WCTOMB_STATE(_REENT))); -#else /* not MB_CAPABLE */ +#else /* not _MB_CAPABLE */ if (s == NULL) return 0; *s = (char) wchar; return 1; -#endif /* not MB_CAPABLE */ +#endif /* not _MB_CAPABLE */ } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/sys/linux/intl/dcigettext.c b/newlib/libc/sys/linux/intl/dcigettext.c index 017be4623..de47064aa 100644 --- a/newlib/libc/sys/linux/intl/dcigettext.c +++ b/newlib/libc/sys/linux/intl/dcigettext.c @@ -17,7 +17,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Tell glibc's to provide a prototype for mempcpy(). This must come before because may include @@ -1237,7 +1239,7 @@ free_mem (void) text_set_element (__libc_subfreeres, free_mem); #endif -#else /* !MB_CAPABLE */ +#else /* !_MB_CAPABLE */ #include #include @@ -1281,4 +1283,4 @@ __dcigettext (domainname, msgid1, msgid2, plural, n, category) } weak_alias(__dcigettext, dcigettext) -#endif /* !MB_CAPABLE */ +#endif /* !_MB_CAPABLE */ diff --git a/newlib/libc/sys/linux/intl/explodename.c b/newlib/libc/sys/linux/intl/explodename.c index d36b045bb..6effd3347 100644 --- a/newlib/libc/sys/linux/intl/explodename.c +++ b/newlib/libc/sys/linux/intl/explodename.c @@ -1,4 +1,6 @@ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -201,4 +203,4 @@ _nl_explode_name (name, language, modifier, territory, codeset, return mask; } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ diff --git a/newlib/libc/sys/linux/intl/finddomain.c b/newlib/libc/sys/linux/intl/finddomain.c index f64305776..4f27790be 100644 --- a/newlib/libc/sys/linux/intl/finddomain.c +++ b/newlib/libc/sys/linux/intl/finddomain.c @@ -1,4 +1,6 @@ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Handle list of needed message catalogs Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. @@ -217,4 +219,4 @@ free_mem (void) text_set_element (__libc_subfreeres, free_mem); #endif -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ diff --git a/newlib/libc/sys/linux/intl/l10nflist.c b/newlib/libc/sys/linux/intl/l10nflist.c index 1a5cf1e0c..564df73fb 100644 --- a/newlib/libc/sys/linux/intl/l10nflist.c +++ b/newlib/libc/sys/linux/intl/l10nflist.c @@ -1,4 +1,6 @@ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -418,4 +420,4 @@ stpcpy (dest, src) } #endif -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ diff --git a/newlib/libc/sys/linux/intl/loadmsgcat.c b/newlib/libc/sys/linux/intl/loadmsgcat.c index 94f3e9a4c..b5f722e3b 100644 --- a/newlib/libc/sys/linux/intl/loadmsgcat.c +++ b/newlib/libc/sys/linux/intl/loadmsgcat.c @@ -1,4 +1,6 @@ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Load needed message catalogs. Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. diff --git a/newlib/libc/sys/linux/intl/localealias.c b/newlib/libc/sys/linux/intl/localealias.c index 03b6304cc..f3a892342 100644 --- a/newlib/libc/sys/linux/intl/localealias.c +++ b/newlib/libc/sys/linux/intl/localealias.c @@ -1,4 +1,6 @@ -#ifdef MB_CAPABLE +#include + +#ifdef _MB_CAPABLE /* Handle aliases for locale names. Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. @@ -440,4 +442,4 @@ alias_compare (map1, map2) #endif } -#endif /* MB_CAPABLE */ +#endif /* _MB_CAPABLE */ diff --git a/newlib/newlib.hin b/newlib/newlib.hin index 6f5497c08..dfdf198e2 100644 --- a/newlib/newlib.hin +++ b/newlib/newlib.hin @@ -8,6 +8,9 @@ /* Newlib version */ #undef _NEWLIB_VERSION +/* Multibyte supported */ +#undef _MB_CAPABLE + /* MB_LEN_MAX */ #undef _MB_LEN_MAX