The patch integrate:
- _CurrentMessagesLocale to locale_t (as lc_messages)
- _CurrentMonetaryLocale to locale_t (as lc_monetary)
- _CurrentNumericLocale to locale_t (as lc_numeric)
- _CurrentTimeLocale to locale_t (as lc_time)
The localeconv() function has static variable that will be addressed in
following patch.
--
Sebastien Marie
Index: b/lib/libc/locale/_def_messages.c
===================================================================
--- a/lib/libc/locale/_def_messages.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/_def_messages.c 2015-07-08 11:56:51.873920979 +0200
@@ -13,6 +13,4 @@
"^[Nn]",
"yes",
"no"
-} ;
-
-const _MessagesLocale *_CurrentMessagesLocale = &_DefaultMessagesLocale;
+};
Index: b/lib/libc/locale/_def_monetary.c
===================================================================
--- a/lib/libc/locale/_def_monetary.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/_def_monetary.c 2015-07-08 11:56:51.873920979 +0200
@@ -34,5 +34,3 @@
CHAR_MAX,
CHAR_MAX,
};
-
-const _MonetaryLocale *_CurrentMonetaryLocale = &_DefaultMonetaryLocale;
Index: b/lib/libc/locale/_def_numeric.c
===================================================================
--- a/lib/libc/locale/_def_numeric.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/_def_numeric.c 2015-07-08 11:56:51.873920979 +0200
@@ -13,5 +13,3 @@
"",
""
};
-
-const _NumericLocale *_CurrentNumericLocale = &_DefaultNumericLocale;
Index: b/lib/libc/locale/_def_time.c
===================================================================
--- a/lib/libc/locale/_def_time.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/_def_time.c 2015-07-08 11:56:51.883919979 +0200
@@ -32,5 +32,3 @@
"%H:%M:%S",
"%I:%M:%S %p"
};
-
-const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;
Index: b/lib/libc/locale/localeconv.c
===================================================================
--- a/lib/libc/locale/localeconv.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/localeconv.c 2015-07-08 11:56:51.883919979 +0200
@@ -7,6 +7,8 @@
#include <sys/localedef.h>
#include <locale.h>
+#include "xlocale_private.h"
+
/*
* The localeconv() function constructs a struct lconv from the current
* monetary and numeric locales.
@@ -26,38 +28,39 @@
localeconv(void)
{
static struct lconv ret;
+ locale_t loc = _current_locale();
if (__mlocale_changed) {
/* LC_MONETARY */
- ret.int_curr_symbol = _CurrentMonetaryLocale->int_curr_symbol;
- ret.currency_symbol = _CurrentMonetaryLocale->currency_symbol;
- ret.mon_decimal_point = _CurrentMonetaryLocale->mon_decimal_point;
- ret.mon_thousands_sep = _CurrentMonetaryLocale->mon_thousands_sep;
- ret.mon_grouping = _CurrentMonetaryLocale->mon_grouping;
- ret.positive_sign = _CurrentMonetaryLocale->positive_sign;
- ret.negative_sign = _CurrentMonetaryLocale->negative_sign;
- ret.int_frac_digits = _CurrentMonetaryLocale->int_frac_digits;
- ret.frac_digits = _CurrentMonetaryLocale->frac_digits;
- ret.p_cs_precedes = _CurrentMonetaryLocale->p_cs_precedes;
- ret.p_sep_by_space = _CurrentMonetaryLocale->p_sep_by_space;
- ret.n_cs_precedes = _CurrentMonetaryLocale->n_cs_precedes;
- ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space;
- ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn;
- ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn;
- ret.int_p_cs_precedes = _CurrentMonetaryLocale->int_p_cs_precedes;
- ret.int_p_sep_by_space = _CurrentMonetaryLocale->int_p_sep_by_space;
- ret.int_n_cs_precedes = _CurrentMonetaryLocale->int_n_cs_precedes;
- ret.int_n_sep_by_space = _CurrentMonetaryLocale->int_n_sep_by_space;
- ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn;
- ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn;
+ ret.int_curr_symbol = loc->lc_monetary->int_curr_symbol;
+ ret.currency_symbol = loc->lc_monetary->currency_symbol;
+ ret.mon_decimal_point = loc->lc_monetary->mon_decimal_point;
+ ret.mon_thousands_sep = loc->lc_monetary->mon_thousands_sep;
+ ret.mon_grouping = loc->lc_monetary->mon_grouping;
+ ret.positive_sign = loc->lc_monetary->positive_sign;
+ ret.negative_sign = loc->lc_monetary->negative_sign;
+ ret.int_frac_digits = loc->lc_monetary->int_frac_digits;
+ ret.frac_digits = loc->lc_monetary->frac_digits;
+ ret.p_cs_precedes = loc->lc_monetary->p_cs_precedes;
+ ret.p_sep_by_space = loc->lc_monetary->p_sep_by_space;
+ ret.n_cs_precedes = loc->lc_monetary->n_cs_precedes;
+ ret.n_sep_by_space = loc->lc_monetary->n_sep_by_space;
+ ret.p_sign_posn = loc->lc_monetary->p_sign_posn;
+ ret.n_sign_posn = loc->lc_monetary->n_sign_posn;
+ ret.int_p_cs_precedes = loc->lc_monetary->int_p_cs_precedes;
+ ret.int_p_sep_by_space = loc->lc_monetary->int_p_sep_by_space;
+ ret.int_n_cs_precedes = loc->lc_monetary->int_n_cs_precedes;
+ ret.int_n_sep_by_space = loc->lc_monetary->int_n_sep_by_space;
+ ret.int_p_sign_posn = loc->lc_monetary->int_p_sign_posn;
+ ret.int_n_sign_posn = loc->lc_monetary->int_n_sign_posn;
__mlocale_changed = 0;
}
if (__nlocale_changed) {
/* LC_NUMERIC */
- ret.decimal_point = (char *) _CurrentNumericLocale->decimal_point;
- ret.thousands_sep = (char *) _CurrentNumericLocale->thousands_sep;
- ret.grouping = (char *) _CurrentNumericLocale->grouping;
+ ret.decimal_point = (char *) loc->lc_numeric->decimal_point;
+ ret.thousands_sep = (char *) loc->lc_numeric->thousands_sep;
+ ret.grouping = (char *) loc->lc_numeric->grouping;
__nlocale_changed = 0;
}
Index: b/lib/libc/locale/nl_langinfo.c
===================================================================
--- a/lib/libc/locale/nl_langinfo.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/locale/nl_langinfo.c 2015-07-08 11:56:51.883919979 +0200
@@ -21,20 +21,20 @@
switch (item) {
case D_T_FMT:
- s = _CurrentTimeLocale->d_t_fmt;
+ s = loc->lc_time->d_t_fmt;
break;
case D_FMT:
- s = _CurrentTimeLocale->d_fmt;
+ s = loc->lc_time->d_fmt;
break;
case T_FMT:
- s = _CurrentTimeLocale->t_fmt;
+ s = loc->lc_time->t_fmt;
break;
case T_FMT_AMPM:
- s = _CurrentTimeLocale->t_fmt_ampm;
+ s = loc->lc_time->t_fmt_ampm;
break;
case AM_STR:
case PM_STR:
- s = _CurrentTimeLocale->am_pm[item - AM_STR];
+ s = loc->lc_time->am_pm[item - AM_STR];
break;
case DAY_1:
case DAY_2:
@@ -43,7 +43,7 @@
case DAY_5:
case DAY_6:
case DAY_7:
- s = _CurrentTimeLocale->day[item - DAY_1];
+ s = loc->lc_time->day[item - DAY_1];
break;
case ABDAY_1:
case ABDAY_2:
@@ -52,7 +52,7 @@
case ABDAY_5:
case ABDAY_6:
case ABDAY_7:
- s = _CurrentTimeLocale->abday[item - ABDAY_1];
+ s = loc->lc_time->abday[item - ABDAY_1];
break;
case MON_1:
case MON_2:
@@ -66,7 +66,7 @@
case MON_10:
case MON_11:
case MON_12:
- s = _CurrentTimeLocale->mon[item - MON_1];
+ s = loc->lc_time->mon[item - MON_1];
break;
case ABMON_1:
case ABMON_2:
@@ -80,25 +80,25 @@
case ABMON_10:
case ABMON_11:
case ABMON_12:
- s = _CurrentTimeLocale->abmon[item - ABMON_1];
+ s = loc->lc_time->abmon[item - ABMON_1];
break;
case RADIXCHAR:
- s = _CurrentNumericLocale->decimal_point;
+ s = loc->lc_numeric->decimal_point;
break;
case THOUSEP:
- s = _CurrentNumericLocale->thousands_sep;
+ s = loc->lc_numeric->thousands_sep;
break;
case YESSTR:
- s = _CurrentMessagesLocale->yesstr;
+ s = loc->lc_messages->yesstr;
break;
case YESEXPR:
- s = _CurrentMessagesLocale->yesexpr;
+ s = loc->lc_messages->yesexpr;
break;
case NOSTR:
- s = _CurrentMessagesLocale->nostr;
+ s = loc->lc_messages->nostr;
break;
case NOEXPR:
- s = _CurrentMessagesLocale->noexpr;
+ s = loc->lc_messages->noexpr;
break;
case CRNCYSTR: /* XXX */
s = "";
Index: b/lib/libc/locale/xlocale.c
===================================================================
--- a/lib/libc/locale/xlocale.c 2015-07-08 11:56:50.853893232 +0200
+++ b/lib/libc/locale/xlocale.c 2015-07-08 11:56:51.883919979 +0200
@@ -27,7 +27,11 @@
struct _locale_t _lc_global_locale = {
XLOCALE_INSTALLED,
{"C", "C", "C", "C", "C", "C", "C"},
- &_DefaultRuneLocale
+ &_DefaultRuneLocale,
+ &_DefaultMessagesLocale,
+ &_DefaultMonetaryLocale,
+ &_DefaultNumericLocale,
+ &_DefaultTimeLocale
};
Index: b/lib/libc/locale/xlocale_private.h
===================================================================
--- a/lib/libc/locale/xlocale_private.h 2015-07-08 11:39:01.331759641 +0200
+++ b/lib/libc/locale/xlocale_private.h 2015-07-08 11:56:51.883919979 +0200
@@ -18,6 +18,7 @@
#define _XLOCALE_PRIVATE_H_
#include <sys/cdefs.h>
+#include <sys/localedef.h>
#include <locale.h>
#include "runetype.h"
@@ -26,6 +27,10 @@
int flags;
char categories[_LC_LAST][32];
_RuneLocale *lc_ctype;
+ const _MessagesLocale *lc_messages;
+ const _MonetaryLocale *lc_monetary;
+ const _NumericLocale *lc_numeric;
+ const _TimeLocale *lc_time;
};
#define XLOCALE_INSTALLED (1 << 0)
Index: b/lib/libc/time/strptime.c
===================================================================
--- a/lib/libc/time/strptime.c 2015-07-08 11:38:48.371645285 +0200
+++ b/lib/libc/time/strptime.c 2015-07-08 11:56:51.893920515 +0200
@@ -36,8 +36,9 @@
#include "private.h"
#include "tzfile.h"
+#include "locale/xlocale_private.h"
-#define _ctloc(x) (_CurrentTimeLocale->x)
+#define _ctloc(x) (_current_locale()->lc_time->x)
/*
* We do not implement alternate representations. However, we always
Index: b/sys/sys/localedef.h
===================================================================
--- a/sys/sys/localedef.h 2015-07-08 11:38:48.371645285 +0200
+++ b/sys/sys/localedef.h 2015-07-08 11:56:51.893920515 +0200
@@ -44,7 +44,6 @@
char *nostr;
} _MessagesLocale;
-extern const _MessagesLocale *_CurrentMessagesLocale;
extern const _MessagesLocale _DefaultMessagesLocale;
@@ -73,7 +72,6 @@
char int_n_sign_posn;
} _MonetaryLocale;
-extern const _MonetaryLocale *_CurrentMonetaryLocale;
extern const _MonetaryLocale _DefaultMonetaryLocale;
@@ -84,7 +82,6 @@
const char *grouping;
} _NumericLocale;
-extern const _NumericLocale *_CurrentNumericLocale;
extern const _NumericLocale _DefaultNumericLocale;
@@ -100,7 +97,6 @@
const char *t_fmt_ampm;
} _TimeLocale;
-extern const _TimeLocale *_CurrentTimeLocale;
extern const _TimeLocale _DefaultTimeLocale;
#endif /* !_SYS_LOCALEDEF_H_ */