diff options
Diffstat (limited to 'StdLib/LibC/Locale')
-rw-r--r-- | StdLib/LibC/Locale/Locale.inf | 9 | ||||
-rw-r--r-- | StdLib/LibC/Locale/_wcstoul.h | 6 | ||||
-rw-r--r-- | StdLib/LibC/Locale/multibyte_sb.c | 27 |
3 files changed, 25 insertions, 17 deletions
diff --git a/StdLib/LibC/Locale/Locale.inf b/StdLib/LibC/Locale/Locale.inf index 5fee723f85..c891e3bfaf 100644 --- a/StdLib/LibC/Locale/Locale.inf +++ b/StdLib/LibC/Locale/Locale.inf @@ -63,12 +63,3 @@ [LibraryClasses]
LibC
LibCType
-
-################################################################
-#
-# The Build Options, below, are only used when building the C library.
-# DO NOT use them when building your application!
-# Nasty things could happen if you do.
-#
-[BuildOptions]
- GCC:*_*_*_CC_FLAGS = -fno-builtin
diff --git a/StdLib/LibC/Locale/_wcstoul.h b/StdLib/LibC/Locale/_wcstoul.h index ebfc330fe9..2131d4b5c1 100644 --- a/StdLib/LibC/Locale/_wcstoul.h +++ b/StdLib/LibC/Locale/_wcstoul.h @@ -42,6 +42,8 @@ NetBSD: _wcstoul.h,v 1.3 2005/11/29 03:11:59 christos Exp
*/
+#include <Library/BaseLib.h>
+
/*
* function template for wcstoul, wcstoull and wcstoumax.
*
@@ -102,8 +104,8 @@ _FUNCNAME( /*
* See strtoul for comments as to the logic used.
*/
- cutoff = __wUINT_MAX / (__wUINT)base;
- cutlim = (int)(__wUINT_MAX % (__wUINT)base);
+ cutoff = (__wUINT)DivU64x32 ((UINT64) __wUINT_MAX, (UINT32) base);
+ cutlim = (int) ModU64x32 ((UINT64) __wUINT_MAX, (UINT32) base);
for (acc = 0, any = 0;; wc = (wint_t) *s++) {
i = __wctoint((wchar_t)wc);
if (i == -1) {
diff --git a/StdLib/LibC/Locale/multibyte_sb.c b/StdLib/LibC/Locale/multibyte_sb.c index 6d57cd6c09..0a73898e61 100644 --- a/StdLib/LibC/Locale/multibyte_sb.c +++ b/StdLib/LibC/Locale/multibyte_sb.c @@ -137,7 +137,7 @@ wcrtomb( /* ps appears to be unused */
if (s == NULL)
- return 0;
+ return 1; /* Spec. says this should be 1. */
*s = (char) wchar;
return 1;
@@ -150,7 +150,12 @@ wctomb( )
{
- /* s may be NULL */
+ /*
+ If s is NULL just return if MB Characters have state
+ dependent encodings.
+ */
+ if (s == NULL)
+ return 0;
return (int)wcrtomb(s, wchar, NULL);
}
@@ -176,8 +181,10 @@ mbsrtowcs( if (n != 0) {
if (pwcs != NULL) {
do {
- if ((*pwcs++ = (wchar_t) *(*s)++) == 0)
+ if ((*pwcs++ = (wchar_t) *(*s)++) == 0) {
+ *s = NULL;
break;
+ }
count++;
} while (--n != 0);
} else {
@@ -232,8 +239,10 @@ wcsrtombs( if (n != 0) {
do {
- if ((*s++ = (char) *(*pwcs)++) == 0)
+ if ((*s++ = (char) *(*pwcs)++) == 0) {
+ *pwcs = NULL;
break;
+ }
count++;
} while (--n != 0);
}
@@ -266,7 +275,13 @@ btowc(int c) int
wctob(wint_t c)
{
- if (c == WEOF || c & ~0xFF)
+ /* wctob needs to be consistent with wcrtomb.
+ if wcrtomb says that a character is representable in 1 byte,
+ which this implementation always says, then wctob needs to
+ also represent the character as 1 byte.
+ */
+ if (c == WEOF) {
return EOF;
- return (int)c;
+ }
+ return (int)(c & 0xFF);
}
|