summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/mblen.c13
-rw-r--r--newlib/libc/stdlib/mblen_r.c13
-rw-r--r--newlib/libc/stdlib/mbrlen.c3
-rw-r--r--newlib/libc/stdlib/mbrtowc.c3
-rw-r--r--newlib/libc/stdlib/mbsrtowcs.c3
-rw-r--r--newlib/libc/stdlib/mbstowcs.c13
-rw-r--r--newlib/libc/stdlib/mbtowc.c13
-rw-r--r--newlib/libc/stdlib/mbtowc_r.c9
-rw-r--r--newlib/libc/stdlib/wcrtomb.c3
-rw-r--r--newlib/libc/stdlib/wcsrtombs.c3
-rw-r--r--newlib/libc/stdlib/wcstombs.c13
-rw-r--r--newlib/libc/stdlib/wctomb.c17
12 files changed, 59 insertions, 47 deletions
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 <<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 */
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 <<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 */
}
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 <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);
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 <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);
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 <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);
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 <<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 */
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 <<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 */
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 <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)
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 <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);
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 <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);
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 <<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 */
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 <<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 */