ctype.h header define MB_CUR_MAX macro to be the maximum number of bytes
in a character specified by the current locale (category LC_CTYPE).
Switch the implementation from global variable to function, in order to
get the value from the current locale state (global or per-thread).
--
Sebastien Marie
Index: b/include/stdlib.h
===================================================================
--- a/include/stdlib.h 2015-06-30 12:00:11.373211391 +0200
+++ b/include/stdlib.h 2015-06-30 12:18:58.142432363 +0200
@@ -92,8 +92,8 @@
#define RAND_MAX 0x7fffffff
-extern size_t __mb_cur_max;
-#define MB_CUR_MAX __mb_cur_max
+extern size_t __mb_cur_max(void);
+#define MB_CUR_MAX __mb_cur_max()
#include <sys/cdefs.h>
Index: b/lib/libc/locale/__mb_cur_max.c
===================================================================
--- a/lib/libc/locale/__mb_cur_max.c 2015-06-30 12:00:11.373211391 +0200
+++ b/lib/libc/locale/__mb_cur_max.c 2015-06-30 12:18:58.142432363 +0200
@@ -30,6 +30,19 @@
#include <sys/types.h>
#include <limits.h>
-size_t __mb_cur_max = 1;
+#include "rune.h"
+#include "citrus/citrus_ctype_local.h"
+#include "xlocale_private.h"
+
size_t __mb_len_max_runtime = MB_LEN_MAX;
+size_t
+__mb_cur_max()
+{
+ locale_t loc = _current_locale();
+
+ if (loc->lc_ctype->rl_citrus_ctype != NULL)
+ return (loc->lc_ctype->rl_citrus_ctype->cc_mb_cur_max);
+ else
+ return (1);
+}
Index: b/lib/libc/locale/setrunelocale.c
===================================================================
--- a/lib/libc/locale/setrunelocale.c 2015-06-30 12:18:53.262377426 +0200
+++ b/lib/libc/locale/setrunelocale.c 2015-06-30 12:18:58.152431919 +0200
@@ -207,7 +207,6 @@
found:
locale->lc_ctype = rl;
- __mb_cur_max = rl->rl_citrus_ctype->cc_mb_cur_max;
return 0;
}