Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
5836344
aout
argp
assert
bare
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libio
linuxthreads
linuxthreads_db
locale
programs
.cvsignore
C-address.c
C-collate.c
C-ctype.c
C-identification.c
C-measurement.c
C-messages.c
C-monetary.c
C-name.c
C-numeric.c
C-paper.c
C-telephone.c
C-time.c
C-translit.h
C-translit.h.in
C_name.c
Makefile
SYS_libc.c
Versions
broken_cur_max.c
categories.def
codeset_name.c
coll-lookup.h
duplocale.c
elem-hash.h
findlocale.c
freelocale.c
gen-translit.pl
indigits.h
indigitswc.h
iso-3166.def
iso-4217.def
iso-639.def
langinfo.h
lc-address.c
lc-collate.c
lc-ctype.c
lc-identification.c
lc-measurement.c
lc-messages.c
lc-monetary.c
lc-name.c
lc-numeric.c
lc-paper.c
lc-telephone.c
lc-time.c
loadlocale.c
locale.h
localeconv.c
localeinfo.h
mb_cur_max.c
newlocale.c
nl_langinfo.c
nl_langinfo_l.c
outdigits.h
outdigitswc.h
setlocale.c
strlen-hash.h
tst-C-locale.c
weight.h
weightwc.h
xlocale.h
localedata
login
mach
malloc
manual
math
misc
nis
nscd
nss
po
posix
pwd
resolv
resource
rpm
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdio
stdlib
streams
string
sunrpc
sysdeps
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
INTERFACE
Make-dist
MakeTAGS
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README-alpha
README.libm
README.template
Rules
Versions.def
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
extra-lib.mk
glibcbug.in
o-iterator.mk
shlib-versions
test-skeleton.c
version.h
Breadcrumbs
glibc
/
locale
/
tst-C-locale.c
Copy path
Blame
Blame
Latest commit
History
History
249 lines (227 loc) · 7.31 KB
Breadcrumbs
glibc
/
locale
/
tst-C-locale.c
Top
File metadata and controls
Code
Blame
249 lines (227 loc) · 7.31 KB
Raw
/* Tests of C and POSIX locale contents. Copyright (C) 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@redhat.com>, 2000. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <langinfo.h> #include <limits.h> #include <locale.h> #include <stdio.h> #include <string.h> #include <wchar.h> static int run_test (const char *locname) { struct lconv *lc; const char *str; const wchar_t *wstr; int result = 0; /* ISO C stuff. */ lc = localeconv (); if (lc == NULL) { printf ("localeconv failed for locale %s\n", locname); result = 1; } else { #define STRTEST(name, exp) \ do \ if (strcmp (lc->name, exp) != 0) \ { \ printf (#name " in locale %s wrong (is \"%s\", should be \"%s\")\n",\ locname, lc->name, exp); \ result = 1; \ } \ while (0) STRTEST (decimal_point, "."); STRTEST (thousands_sep, ""); STRTEST (grouping, ""); STRTEST (mon_decimal_point, ""); STRTEST (mon_thousands_sep, ""); STRTEST (mon_grouping, ""); STRTEST (positive_sign, ""); STRTEST (negative_sign, ""); STRTEST (currency_symbol, ""); STRTEST (int_curr_symbol, ""); #define CHARTEST(name, exp) \ do \ if (lc->name != exp) \ { \ printf (#name " in locale %s wrong (is %d, should be %d)\n", \ locname, lc->name, CHAR_MAX); \ result = 1; \ } \ while (0) CHARTEST (frac_digits, CHAR_MAX); CHARTEST (p_cs_precedes, CHAR_MAX); CHARTEST (n_cs_precedes, CHAR_MAX); CHARTEST (p_sep_by_space, CHAR_MAX); CHARTEST (n_sep_by_space, CHAR_MAX); CHARTEST (p_sign_posn, CHAR_MAX); CHARTEST (n_sign_posn, CHAR_MAX); CHARTEST (int_frac_digits, CHAR_MAX); CHARTEST (int_p_cs_precedes, CHAR_MAX); CHARTEST (int_n_cs_precedes, CHAR_MAX); CHARTEST (int_p_sep_by_space, CHAR_MAX); CHARTEST (int_n_sep_by_space, CHAR_MAX); CHARTEST (int_p_sign_posn, CHAR_MAX); CHARTEST (int_n_sign_posn, CHAR_MAX); } #undef STRTEST #define STRTEST(name, exp) \ str = nl_langinfo (name); \ if (strcmp (str, exp) != 0) \ { \ printf ("nl_langinfo(" #name ") int locale %s wrong " \ "(is \"%s\", should be \"%s\")\n", locname, str, exp); \ result = 1; \ } #define WSTRTEST(name, exp) \ wstr = (wchar_t *) nl_langinfo (name); \ if (wcscmp (wstr, exp) != 0) \ { \ printf ("nl_langinfo(" #name ") int locale %s wrong " \ "(is \"%S\", should be \"%S\")\n", locname, wstr, exp); \ result = 1; \ } /* Unix stuff. */ STRTEST (ABDAY_1, "Sun"); STRTEST (ABDAY_2, "Mon"); STRTEST (ABDAY_3, "Tue"); STRTEST (ABDAY_4, "Wed"); STRTEST (ABDAY_5, "Thu"); STRTEST (ABDAY_6, "Fri"); STRTEST (ABDAY_7, "Sat"); STRTEST (DAY_1, "Sunday"); STRTEST (DAY_2, "Monday"); STRTEST (DAY_3, "Tuesday"); STRTEST (DAY_4, "Wednesday"); STRTEST (DAY_5, "Thursday"); STRTEST (DAY_6, "Friday"); STRTEST (DAY_7, "Saturday"); STRTEST (ABMON_1, "Jan"); STRTEST (ABMON_2, "Feb"); STRTEST (ABMON_3, "Mar"); STRTEST (ABMON_4, "Apr"); STRTEST (ABMON_5, "May"); STRTEST (ABMON_6, "Jun"); STRTEST (ABMON_7, "Jul"); STRTEST (ABMON_8, "Aug"); STRTEST (ABMON_9, "Sep"); STRTEST (ABMON_10, "Oct"); STRTEST (ABMON_11, "Nov"); STRTEST (ABMON_12, "Dec"); STRTEST (MON_1, "January"); STRTEST (MON_2, "February"); STRTEST (MON_3, "March"); STRTEST (MON_4, "April"); STRTEST (MON_5, "May"); STRTEST (MON_6, "June"); STRTEST (MON_7, "July"); STRTEST (MON_8, "August"); STRTEST (MON_9, "September"); STRTEST (MON_10, "October"); STRTEST (MON_11, "November"); STRTEST (MON_12, "December"); STRTEST (AM_STR, "AM"); STRTEST (PM_STR, "PM"); STRTEST (D_T_FMT, "%a %b %e %H:%M:%S %Y"); STRTEST (D_FMT, "%m/%d/%y"); STRTEST (T_FMT, "%H:%M:%S"); STRTEST (T_FMT_AMPM, "%I:%M:%S %p"); STRTEST (RADIXCHAR, "."); STRTEST (THOUSEP, ""); STRTEST (YESEXPR, "^[yY]"); STRTEST (NOEXPR, "^[nN]"); /* Extensions. */ WSTRTEST (_NL_WABDAY_1, L"Sun"); WSTRTEST (_NL_WABDAY_2, L"Mon"); WSTRTEST (_NL_WABDAY_3, L"Tue"); WSTRTEST (_NL_WABDAY_4, L"Wed"); WSTRTEST (_NL_WABDAY_5, L"Thu"); WSTRTEST (_NL_WABDAY_6, L"Fri"); WSTRTEST (_NL_WABDAY_7, L"Sat"); WSTRTEST (_NL_WDAY_1, L"Sunday"); WSTRTEST (_NL_WDAY_2, L"Monday"); WSTRTEST (_NL_WDAY_3, L"Tuesday"); WSTRTEST (_NL_WDAY_4, L"Wednesday"); WSTRTEST (_NL_WDAY_5, L"Thursday"); WSTRTEST (_NL_WDAY_6, L"Friday"); WSTRTEST (_NL_WDAY_7, L"Saturday"); WSTRTEST (_NL_WABMON_1, L"Jan"); WSTRTEST (_NL_WABMON_2, L"Feb"); WSTRTEST (_NL_WABMON_3, L"Mar"); WSTRTEST (_NL_WABMON_4, L"Apr"); WSTRTEST (_NL_WABMON_5, L"May"); WSTRTEST (_NL_WABMON_6, L"Jun"); WSTRTEST (_NL_WABMON_7, L"Jul"); WSTRTEST (_NL_WABMON_8, L"Aug"); WSTRTEST (_NL_WABMON_9, L"Sep"); WSTRTEST (_NL_WABMON_10, L"Oct"); WSTRTEST (_NL_WABMON_11, L"Nov"); WSTRTEST (_NL_WABMON_12, L"Dec"); WSTRTEST (_NL_WMON_1, L"January"); WSTRTEST (_NL_WMON_2, L"February"); WSTRTEST (_NL_WMON_3, L"March"); WSTRTEST (_NL_WMON_4, L"April"); WSTRTEST (_NL_WMON_5, L"May"); WSTRTEST (_NL_WMON_6, L"June"); WSTRTEST (_NL_WMON_7, L"July"); WSTRTEST (_NL_WMON_8, L"August"); WSTRTEST (_NL_WMON_9, L"September"); WSTRTEST (_NL_WMON_10, L"October"); WSTRTEST (_NL_WMON_11, L"November"); WSTRTEST (_NL_WMON_12, L"December"); WSTRTEST (_NL_WAM_STR, L"AM"); WSTRTEST (_NL_WPM_STR, L"PM"); WSTRTEST (_NL_WD_T_FMT, L"%a %b %e %H:%M:%S %Y"); WSTRTEST (_NL_WD_FMT, L"%m/%d/%y"); WSTRTEST (_NL_WT_FMT, L"%H:%M:%S"); WSTRTEST (_NL_WT_FMT_AMPM, L"%I:%M:%S %p"); STRTEST (_DATE_FMT, "%a %b %e %H:%M:%S %Z %Y"); WSTRTEST (_NL_W_DATE_FMT, L"%a %b %e %H:%M:%S %Z %Y"); STRTEST (INT_CURR_SYMBOL, ""); STRTEST (CURRENCY_SYMBOL, ""); STRTEST (MON_DECIMAL_POINT, ""); STRTEST (MON_THOUSANDS_SEP, ""); STRTEST (MON_GROUPING, ""); STRTEST (POSITIVE_SIGN, ""); STRTEST (NEGATIVE_SIGN, ""); STRTEST (GROUPING, ""); STRTEST (YESSTR, ""); STRTEST (NOSTR, ""); return result; } int main (void) { int result; /* First use the name "C". */ if (setlocale (LC_ALL, "C") == NULL) { puts ("cannot set C locale"); result = 1; } else result = run_test ("C"); /* Then the name "POSIX". */ if (setlocale (LC_ALL, "POSIX") == NULL) { puts ("cannot set POSIX locale"); result = 1; } else result |= run_test ("POSIX"); return result; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
You can’t perform that action at this time.