1 --- nl_langinfo.c.orig 2004-11-25 11:38:19.000000000 -0800
2 +++ nl_langinfo.c 2005-02-18 22:22:41.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/locale/nl_langinfo.c,v 1.17 2003/06/26 10:46:16 phantom Exp $");
7 +#include "xlocale_private.h"
14 #include "lmessages.h"
15 #include "lmonetary.h"
16 -#include "../stdtime/timelocal.h"
17 +#include "timelocal.h"
19 #define _REL(BASE) ((int)item-BASE)
22 -nl_langinfo(nl_item item)
23 +nl_langinfo_l(nl_item item, locale_t loc)
28 static char *csym = NULL;
30 + NORMALIZE_LOCALE(loc);
34 - if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {
35 + if ((s = querylocale(LC_CTYPE_MASK, loc)) != NULL) {
36 if ((cs = strchr(s, '.')) != NULL)
38 else if (strcmp(s, "C") == 0 ||
43 - ret = (char *) __get_current_time_locale()->c_fmt;
44 + ret = (char *) __get_current_time_locale(loc)->c_fmt;
47 - ret = (char *) __get_current_time_locale()->x_fmt;
48 + ret = (char *) __get_current_time_locale(loc)->x_fmt;
51 - ret = (char *) __get_current_time_locale()->X_fmt;
52 + ret = (char *) __get_current_time_locale(loc)->X_fmt;
55 - ret = (char *) __get_current_time_locale()->ampm_fmt;
56 + ret = (char *) __get_current_time_locale(loc)->ampm_fmt;
59 - ret = (char *) __get_current_time_locale()->am;
60 + ret = (char *) __get_current_time_locale(loc)->am;
63 - ret = (char *) __get_current_time_locale()->pm;
64 + ret = (char *) __get_current_time_locale(loc)->pm;
66 case DAY_1: case DAY_2: case DAY_3:
67 case DAY_4: case DAY_5: case DAY_6: case DAY_7:
68 - ret = (char*) __get_current_time_locale()->weekday[_REL(DAY_1)];
69 + ret = (char*) __get_current_time_locale(loc)->weekday[_REL(DAY_1)];
71 case ABDAY_1: case ABDAY_2: case ABDAY_3:
72 case ABDAY_4: case ABDAY_5: case ABDAY_6: case ABDAY_7:
73 - ret = (char*) __get_current_time_locale()->wday[_REL(ABDAY_1)];
74 + ret = (char*) __get_current_time_locale(loc)->wday[_REL(ABDAY_1)];
76 case MON_1: case MON_2: case MON_3: case MON_4:
77 case MON_5: case MON_6: case MON_7: case MON_8:
78 case MON_9: case MON_10: case MON_11: case MON_12:
79 - ret = (char*) __get_current_time_locale()->month[_REL(MON_1)];
80 + ret = (char*) __get_current_time_locale(loc)->month[_REL(MON_1)];
82 case ABMON_1: case ABMON_2: case ABMON_3: case ABMON_4:
83 case ABMON_5: case ABMON_6: case ABMON_7: case ABMON_8:
84 case ABMON_9: case ABMON_10: case ABMON_11: case ABMON_12:
85 - ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)];
86 + ret = (char*) __get_current_time_locale(loc)->mon[_REL(ABMON_1)];
89 /* XXX: need to be implemented */
94 - ret = (char*) __get_current_numeric_locale()->decimal_point;
95 + ret = (char*) __get_current_numeric_locale(loc)->decimal_point;
98 - ret = (char*) __get_current_numeric_locale()->thousands_sep;
99 + ret = (char*) __get_current_numeric_locale(loc)->thousands_sep;
102 - ret = (char*) __get_current_messages_locale()->yesexpr;
103 + ret = (char*) __get_current_messages_locale(loc)->yesexpr;
106 - ret = (char*) __get_current_messages_locale()->noexpr;
107 + ret = (char*) __get_current_messages_locale(loc)->noexpr;
110 * YESSTR and NOSTR items marked with LEGACY are available, but not
111 @@ -131,25 +135,25 @@
112 * they're subject to remove in future specification editions.
114 case YESSTR: /* LEGACY */
115 - ret = (char*) __get_current_messages_locale()->yesstr;
116 + ret = (char*) __get_current_messages_locale(loc)->yesstr;
118 case NOSTR: /* LEGACY */
119 - ret = (char*) __get_current_messages_locale()->nostr;
120 + ret = (char*) __get_current_messages_locale(loc)->nostr;
123 * SUSv2 special formatted currency string
127 - cs = (char*) __get_current_monetary_locale()->currency_symbol;
128 + cs = (char*) __get_current_monetary_locale(loc)->currency_symbol;
130 - char pos = localeconv()->p_cs_precedes;
131 + char pos = localeconv_l(loc)->p_cs_precedes;
133 - if (pos == localeconv()->n_cs_precedes) {
134 + if (pos == localeconv_l(loc)->n_cs_precedes) {
137 if (pos == CHAR_MAX) {
138 - if (strcmp(cs, __get_current_monetary_locale()->mon_decimal_point) == 0)
139 + if (strcmp(cs, __get_current_monetary_locale(loc)->mon_decimal_point) == 0)
142 psn = pos ? '-' : '+';
143 @@ -166,10 +170,16 @@
146 case D_MD_ORDER: /* FreeBSD local extension */
147 - ret = (char *) __get_current_time_locale()->md_order;
148 + ret = (char *) __get_current_time_locale(loc)->md_order;
157 +nl_langinfo(nl_item item)
159 + return (nl_langinfo_l(item, __current_locale()));