]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/nl_langinfo.c.patch
Libc-391.2.3.tar.gz
[apple/libc.git] / locale / FreeBSD / nl_langinfo.c.patch
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
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/nl_langinfo.c,v 1.17 2003/06/26 10:46:16 phantom Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <langinfo.h>
10 #include <limits.h>
11 #include <locale.h>
12 @@ -36,20 +38,22 @@
13 #include "lnumeric.h"
14 #include "lmessages.h"
15 #include "lmonetary.h"
16 -#include "../stdtime/timelocal.h"
17 +#include "timelocal.h"
18
19 #define _REL(BASE) ((int)item-BASE)
20
21 char *
22 -nl_langinfo(nl_item item)
23 +nl_langinfo_l(nl_item item, locale_t loc)
24 {
25 - char *ret, *s, *cs;
26 + char *ret, *cs;
27 + const char *s;
28 static char *csym = NULL;
29
30 + NORMALIZE_LOCALE(loc);
31 switch (item) {
32 case CODESET:
33 ret = "";
34 - if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {
35 + if ((s = querylocale(LC_CTYPE_MASK, loc)) != NULL) {
36 if ((cs = strchr(s, '.')) != NULL)
37 ret = cs + 1;
38 else if (strcmp(s, "C") == 0 ||
39 @@ -58,40 +62,40 @@
40 }
41 break;
42 case D_T_FMT:
43 - ret = (char *) __get_current_time_locale()->c_fmt;
44 + ret = (char *) __get_current_time_locale(loc)->c_fmt;
45 break;
46 case D_FMT:
47 - ret = (char *) __get_current_time_locale()->x_fmt;
48 + ret = (char *) __get_current_time_locale(loc)->x_fmt;
49 break;
50 case T_FMT:
51 - ret = (char *) __get_current_time_locale()->X_fmt;
52 + ret = (char *) __get_current_time_locale(loc)->X_fmt;
53 break;
54 case T_FMT_AMPM:
55 - ret = (char *) __get_current_time_locale()->ampm_fmt;
56 + ret = (char *) __get_current_time_locale(loc)->ampm_fmt;
57 break;
58 case AM_STR:
59 - ret = (char *) __get_current_time_locale()->am;
60 + ret = (char *) __get_current_time_locale(loc)->am;
61 break;
62 case PM_STR:
63 - ret = (char *) __get_current_time_locale()->pm;
64 + ret = (char *) __get_current_time_locale(loc)->pm;
65 break;
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)];
70 break;
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)];
75 break;
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)];
81 break;
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)];
87 break;
88 case ERA:
89 /* XXX: need to be implemented */
90 @@ -114,16 +118,16 @@
91 ret = "";
92 break;
93 case RADIXCHAR:
94 - ret = (char*) __get_current_numeric_locale()->decimal_point;
95 + ret = (char*) __get_current_numeric_locale(loc)->decimal_point;
96 break;
97 case THOUSEP:
98 - ret = (char*) __get_current_numeric_locale()->thousands_sep;
99 + ret = (char*) __get_current_numeric_locale(loc)->thousands_sep;
100 break;
101 case YESEXPR:
102 - ret = (char*) __get_current_messages_locale()->yesexpr;
103 + ret = (char*) __get_current_messages_locale(loc)->yesexpr;
104 break;
105 case NOEXPR:
106 - ret = (char*) __get_current_messages_locale()->noexpr;
107 + ret = (char*) __get_current_messages_locale(loc)->noexpr;
108 break;
109 /*
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.
113 */
114 case YESSTR: /* LEGACY */
115 - ret = (char*) __get_current_messages_locale()->yesstr;
116 + ret = (char*) __get_current_messages_locale(loc)->yesstr;
117 break;
118 case NOSTR: /* LEGACY */
119 - ret = (char*) __get_current_messages_locale()->nostr;
120 + ret = (char*) __get_current_messages_locale(loc)->nostr;
121 break;
122 /*
123 * SUSv2 special formatted currency string
124 */
125 case CRNCYSTR:
126 ret = "";
127 - cs = (char*) __get_current_monetary_locale()->currency_symbol;
128 + cs = (char*) __get_current_monetary_locale(loc)->currency_symbol;
129 if (*cs != '\0') {
130 - char pos = localeconv()->p_cs_precedes;
131 + char pos = localeconv_l(loc)->p_cs_precedes;
132
133 - if (pos == localeconv()->n_cs_precedes) {
134 + if (pos == localeconv_l(loc)->n_cs_precedes) {
135 char psn = '\0';
136
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)
140 psn = '.';
141 } else
142 psn = pos ? '-' : '+';
143 @@ -166,10 +170,16 @@
144 }
145 break;
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;
149 break;
150 default:
151 ret = "";
152 }
153 return (ret);
154 }
155 +
156 +char *
157 +nl_langinfo(nl_item item)
158 +{
159 + return (nl_langinfo_l(item, __current_locale()));
160 +}