2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com>

* 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 <newlib.h>
        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
This commit is contained in:
Jeff Johnston
2004-04-23 21:44:22 +00:00
parent 27c7566ca4
commit f777e3a5ac
36 changed files with 170 additions and 99 deletions

View File

@ -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 <<mblen>>. 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>> returns <<0>> if
<[s]> is <<NULL>> or the empty string; it returns <<1>> if not MB_CAPABLE or
<[s]> is <<NULL>> 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 <newlib.h>
#include <stdlib.h>
#include <wchar.h>
@ -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 */

View File

@ -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 <<NULL>> or the empty string; it returns <<1>> if not MB_CAPABLE or
<[s]> is <<NULL>> 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 <newlib.h>
#include <stdlib.h>
#include <wchar.h>
@ -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 */
}

View File

@ -1,4 +1,5 @@
#include <reent.h>
#include <newlib.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
@ -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);

View File

@ -1,4 +1,5 @@
#include <reent.h>
#include <newlib.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
@ -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);

View File

@ -1,4 +1,5 @@
#include <reent.h>
#include <newlib.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
@ -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);

View File

@ -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 <<mbstowcs>>. 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 <<mbstowcs>> returns <<0>> if
<[s]> is <<NULL>> 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: <<n>> or the
number of multi-byte characters in <<s>> plus 1 (to
@ -49,6 +49,7 @@ effects vary with the locale.
#ifndef _REENT_ONLY
#include <newlib.h>
#include <stdlib.h>
#include <wchar.h>
@ -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 */

View File

@ -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 <<mbtowc>>. 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 <<mbtowc>> 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 <<mbtowc>> returns <<0>> if
<[s]> is <<NULL>> 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 <newlib.h>
#include <stdlib.h>
#include <wchar.h>
@ -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 */

View File

@ -1,10 +1,11 @@
#include <newlib.h>
#include <stdlib.h>
#include <locale.h>
#include "mbctype.h"
#include <wchar.h>
#include <string.h>
#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)

View File

@ -1,4 +1,5 @@
#include <reent.h>
#include <newlib.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
@ -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);

View File

@ -1,4 +1,5 @@
#include <reent.h>
#include <newlib.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
@ -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);

View File

@ -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 <<wcstombs>>. 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 <<wcstombs>> returns <<0>> if
<[s]> is <<NULL>> 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: <<n>> or the
number of bytes that are transferred to <<s>>, not including the
@ -50,6 +50,7 @@ effects vary with the locale.
#ifndef _REENT_ONLY
#include <newlib.h>
#include <stdlib.h>
#include <wchar.h>
@ -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 */

View File

@ -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 <<wctomb>>. 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 <<wctomb>> 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 <<wctomb>> returns <<0>> if
<[s]> is <<NULL>>; it returns <<-1>> if MB_CAPABLE is enabled
<[s]> is <<NULL>>; 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 <newlib.h>
#include <stdlib.h>
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 */