瀏覽代碼

byte-based C locale, phase 3: make MB_CUR_MAX variable to activate code

this patch activates the new byte-based C locale (high bytes treated
as abstract code unit "characters" rather than decoded as multibyte
characters) by making the value of MB_CUR_MAX depend on the active
locale. for the C locale, the LC_CTYPE category pointer is null,
yielding a value of 1. all other locales yield a value of 4.
Rich Felker 9 年之前
父節點
當前提交
f22a9edaf8
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 2 1
      include/stdlib.h
  2. 3 0
      src/internal/locale_impl.h

+ 2 - 1
include/stdlib.h

@@ -76,7 +76,8 @@ size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
 #define EXIT_FAILURE 1
 #define EXIT_SUCCESS 0
 
-#define MB_CUR_MAX ((size_t)+4)
+size_t __ctype_get_mb_cur_max(void);
+#define MB_CUR_MAX (__ctype_get_mb_cur_max())
 
 #define RAND_MAX (0x7fffffff)
 

+ 3 - 0
src/internal/locale_impl.h

@@ -34,4 +34,7 @@ const char *__lctrans_cur(const char *);
 
 #define CURRENT_UTF8 (!!__pthread_self()->locale->cat[LC_CTYPE])
 
+#undef MB_CUR_MAX
+#define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1)
+
 #endif