summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-11-05 22:38:29 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-11-05 22:38:29 +0000
commitbd0bf51fa4b9e169dff3784bc3f6488691bc9877 (patch)
treec373c77853fdb5e52c713ab4643c3721c911dc09
parentc1dea5f3659f1bb610c3c58a620a8fb066ad3ef9 (diff)
Forgot to change btowc and wctob when I changed the wc<->mb functions yesterday.
-rw-r--r--libc/misc/wchar/wchar.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index 6bdc7c068..100ca19a8 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -68,6 +68,10 @@
* and consistency with the stds requirements that a printf format string by
* a valid multibyte string beginning and ending in it's initial shift state.
*
+ * Nov 5, 2002
+ *
+ * Forgot to change btowc and wctob when I changed the wc<->mb functions yesterday.
+ *
* Manuel
*/
@@ -146,9 +150,17 @@ wint_t btowc(int c)
#else /* __CTYPE_HAS_8_BIT_LOCALES */
- /* If we don't have 8-bit locale support, then this is trivial since
- * anything outside of 0-0x7f is illegal in C/POSIX and UTF-8 locales. */
- return (((unsigned int)c) < 0x80) ? c : WEOF;
+#ifdef __CTYPE_HAS_UTF_8_LOCALES
+ if (ENCODING == __ctype_encoding_utf8) {
+ return (((unsigned int)c) < 0x80) ? c : WEOF;
+ }
+#endif /* __CTYPE_HAS_UTF_8_LOCALES */
+
+#ifdef __UCLIBC_HAS_LOCALE__
+ assert(ENCODING == __ctype_encoding_7_bit);
+#endif
+
+ return (((unsigned int)c) <= UCHAR_MAX) ? c : WEOF;
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
}
@@ -169,13 +181,17 @@ int wctob(wint_t c)
#else /* __CTYPE_HAS_8_BIT_LOCALES */
- /* If we don't have 8-bit locale support, then this is trivial since
- * anything outside of 0-0x7f is illegal in C/POSIX and UTF-8 locales. */
-
- /* TODO: need unsigned version of wint_t... */
-/* return (((unsigned int)c) < 0x80) ? c : WEOF; */
- return ((c >= 0) && (c < 0x80)) ? c : EOF;
+#ifdef __CTYPE_HAS_UTF_8_LOCALES
+ if (ENCODING == __ctype_encoding_utf8) {
+ return ((c >= 0) && (c < 0x80)) ? c : EOF;
+ }
+#endif /* __CTYPE_HAS_UTF_8_LOCALES */
+
+#ifdef __UCLIBC_HAS_LOCALE__
+ assert(ENCODING == __ctype_encoding_7_bit);
+#endif
+ return ((c >= 0) && (c <= UCHAR_MAX)) ? c : EOF;
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
}