From e0eb1d38c4e11e7d728ea2de0a374a4e30c04278 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 22 Nov 2011 17:32:39 +0100 Subject: [PATCH] Let MB_CUR_LEN lookup the actual value. * instead of yielding 1, MB_CUR_LEN now looks up the correct value in the ctype data provided by the locale backend --- headers/posix/ctype.h | 2 ++ headers/posix/stdlib.h | 8 +++++--- headers/private/libroot/locale/LocaleBackend.h | 2 ++ src/system/libroot/posix/glibc/locale/Jamfile | 1 - src/system/libroot/posix/glibc/stdlib/stdlib.h | 2 +- .../libroot/posix/locale/LocaleDataBridge.cpp | 6 ++++++ src/system/libroot/posix/locale/ctype.cpp | 17 +++++++++++++++++ 7 files changed, 33 insertions(+), 5 deletions(-) diff --git a/headers/posix/ctype.h b/headers/posix/ctype.h index 5b0c420e93..9d75cea58c 100644 --- a/headers/posix/ctype.h +++ b/headers/posix/ctype.h @@ -72,6 +72,8 @@ extern const int *__ctype_toupper; #define isupper(c) __isctype((c), _ISupper) #define isxdigit(c) __isctype((c), _ISxdigit) +extern unsigned short int __ctype_mb_cur_max; + #ifdef __cplusplus } #endif diff --git a/headers/posix/stdlib.h b/headers/posix/stdlib.h index 24ebf81a1c..efec9062a5 100644 --- a/headers/posix/stdlib.h +++ b/headers/posix/stdlib.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2011 Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDLIB_H_ @@ -13,9 +13,8 @@ #include #include - #define RAND_MAX 0x7fffffff -#define MB_CUR_MAX 1 +#define MB_CUR_MAX (__ctype_get_mb_cur_max()) #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 @@ -180,6 +179,9 @@ extern int grantpt(int masterFD); extern char* ptsname(int masterFD); extern int unlockpt(int masterFD); +/* internal accessor to value for MB_CUR_MAX */ +extern unsigned short __ctype_get_mb_cur_max(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/headers/private/libroot/locale/LocaleBackend.h b/headers/private/libroot/locale/LocaleBackend.h index 3e754e6442..4228f842e3 100644 --- a/headers/private/libroot/locale/LocaleBackend.h +++ b/headers/private/libroot/locale/LocaleBackend.h @@ -31,6 +31,8 @@ struct LocaleCtypeDataBridge { const int* posixToUpperMap; LocaleCtypeDataBridge(); + + void setMbCurMax(unsigned short mbCurMax); }; diff --git a/src/system/libroot/posix/glibc/locale/Jamfile b/src/system/libroot/posix/glibc/locale/Jamfile index 7797505cb8..918a1465ca 100644 --- a/src/system/libroot/posix/glibc/locale/Jamfile +++ b/src/system/libroot/posix/glibc/locale/Jamfile @@ -23,6 +23,5 @@ MergeObject posix_gnu_locale.o : lc-messages.c lc-monetary.c lc-numeric.c - mb_cur_max.c xlocale.c ; diff --git a/src/system/libroot/posix/glibc/stdlib/stdlib.h b/src/system/libroot/posix/glibc/stdlib/stdlib.h index 275f34a83b..6d175df441 100644 --- a/src/system/libroot/posix/glibc/stdlib/stdlib.h +++ b/src/system/libroot/posix/glibc/stdlib/stdlib.h @@ -135,7 +135,7 @@ __END_NAMESPACE_C99 /* Maximum length of a multibyte character in the current locale. */ #define MB_CUR_MAX (__ctype_get_mb_cur_max ()) -extern size_t __ctype_get_mb_cur_max (void) __THROW; +extern unsigned short __ctype_get_mb_cur_max(void); __BEGIN_NAMESPACE_STD diff --git a/src/system/libroot/posix/locale/LocaleDataBridge.cpp b/src/system/libroot/posix/locale/LocaleDataBridge.cpp index d2cce87b60..c8f2631974 100644 --- a/src/system/libroot/posix/locale/LocaleDataBridge.cpp +++ b/src/system/libroot/posix/locale/LocaleDataBridge.cpp @@ -36,6 +36,12 @@ LocaleCtypeDataBridge::LocaleCtypeDataBridge() } +void LocaleCtypeDataBridge::setMbCurMax(unsigned short mbCurMax) +{ + __ctype_mb_cur_max = mbCurMax; +} + + LocaleMessagesDataBridge::LocaleMessagesDataBridge() : posixLanginfo(gPosixLanginfo) diff --git a/src/system/libroot/posix/locale/ctype.cpp b/src/system/libroot/posix/locale/ctype.cpp index 156a2aa8ec..08faf6a464 100644 --- a/src/system/libroot/posix/locale/ctype.cpp +++ b/src/system/libroot/posix/locale/ctype.cpp @@ -26,6 +26,20 @@ #undef toupper +extern "C" +{ + + +unsigned short int __ctype_mb_cur_max = 1; + + +unsigned short +__ctype_get_mb_cur_max() +{ + return __ctype_mb_cur_max; +} + + int isalnum(int c) { @@ -180,3 +194,6 @@ toupper(int c) return c; } + + +}