commit 7e0ad15c0fbfe25435c1acd0ed3e9cedfbff2488 Author: Carlos O'Donell Date: Mon Jan 31 00:34:42 2022 -0500 localedata: Adjust C.UTF-8 to align with C/POSIX. We have had one downstream report from Canonical [1] that an rrdtool test was broken by the differences in LC_TIME that we had in the non-builtin C locale (C.UTF-8). If one application has an issue there are going to be others, and so with this commit we review and fix all the issues that cause the builtin C locale to be different from C.UTF-8, which includes: * mon_decimal_point should be empty e.g. "" - Depends on mon_decimal_point_wc fix. * negative_sign should be empty e.g. "" * week should be aligned with the builtin C/POSIX locale * d_fmt corrected with escaped slashes e.g. "%m//%d//%y" * yesstr and nostr should be empty e.g. "" * country_ab2 and country_ab3 should be empty e.g. "" We bump LC_IDENTIFICATION version and adjust the date to indicate the change in the locale. A new tst-c-utf8-consistency test is added to ensure consistency between C/POSIX and C.UTF-8. Tested on x86_64 and i686 without regression. [1] https://sourceware.org/pipermail/libc-alpha/2022-January/135703.html Co-authored-by: Florian Weimer Reviewed-by: Florian Weimer diff --git a/localedata/Makefile b/localedata/Makefile index c9dd5a954e8194cc..5830b9d05141cccd 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -155,11 +155,31 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \ tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \ tst_wctype tst_wcwidth -tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \ - tst-leaks tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \ - tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale \ - tst-strfmon1 tst-sscanf bug-setlocale1 tst-setlocale2 tst-setlocale3 \ - tst-wctype tst-iconv-math-trans +tests = \ + $(locale_test_suite) \ + bug-iconv-trans \ + bug-setlocale1 \ + bug-usesetlocale \ + tst-c-utf8-consistency \ + tst-digits \ + tst-iconv-math-trans \ + tst-leaks \ + tst-mbswcs1 \ + tst-mbswcs2 \ + tst-mbswcs3 \ + tst-mbswcs4 \ + tst-mbswcs5 \ + tst-mbswcs6 \ + tst-setlocale \ + tst-setlocale2 \ + tst-setlocale3 \ + tst-sscanf \ + tst-strfmon1 \ + tst-wctype \ + tst-xlocale1 \ + tst-xlocale2 \ + # tests + tests-static = bug-setlocale1-static tests += $(tests-static) ifeq (yes,$(build-shared)) diff --git a/localedata/locales/C b/localedata/locales/C index ca801c79cf7e953e..fc0614e551519c6b 100644 --- a/localedata/locales/C +++ b/localedata/locales/C @@ -12,8 +12,8 @@ tel "" fax "" language "" territory "" -revision "2.0" -date "2020-06-28" +revision "2.1" +date "2022-01-30" category "i18n:2012";LC_IDENTIFICATION category "i18n:2012";LC_CTYPE category "i18n:2012";LC_COLLATE @@ -68,11 +68,11 @@ LC_MONETARY % glibc/locale/C-monetary.c.). int_curr_symbol "" currency_symbol "" -mon_decimal_point "." +mon_decimal_point "" mon_thousands_sep "" mon_grouping -1 positive_sign "" -negative_sign "-" +negative_sign "" int_frac_digits -1 frac_digits -1 p_cs_precedes -1 @@ -121,7 +121,9 @@ mon "January";"February";"March";"April";"May";"June";"July";/ % % ISO 8601 conforming applications should use the values 7, 19971201 (a % Monday), and 4 (Thursday), respectively. -week 7;19971201;4 +% +% This field is consciously aligned with the builtin C/POSIX locale. +week 7;19971130;4 first_weekday 1 first_workday 2 @@ -129,7 +131,7 @@ first_workday 2 d_t_fmt "%a %b %e %H:%M:%S %Y" % Appropriate date representation (%x) -d_fmt "%m/%d/%y" +d_fmt "%m//%d//%y" % Appropriate time representation (%X) t_fmt "%H:%M:%S" @@ -150,8 +152,8 @@ LC_MESSAGES % yesexpr "^[yY]" noexpr "^[nN]" -yesstr "Yes" -nostr "No" +yesstr "" +nostr "" END LC_MESSAGES LC_PAPER @@ -175,6 +177,10 @@ LC_ADDRESS % the LC_ADDRESS category. % (also used in the built in C/POSIX locale in glibc/locale/C-address.c) postal_fmt "%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N" +% The abbreviated 2 char and 3 char should be set to empty strings to +% match the C/POSIX locale. +country_ab2 "" +country_ab3 "" END LC_ADDRESS LC_TELEPHONE diff --git a/localedata/tst-c-utf8-consistency.c b/localedata/tst-c-utf8-consistency.c new file mode 100644 index 0000000000000000..50feed3090df0ff1 --- /dev/null +++ b/localedata/tst-c-utf8-consistency.c @@ -0,0 +1,539 @@ +/* Test that C/POSIX and C.UTF-8 are consistent. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +/* Initialized by do_test using newlocale. */ +static locale_t c_utf8; + +/* Set to true for second pass. */ +static bool use_nl_langinfo_l; + +static void +switch_to_c (void) +{ + if (setlocale (LC_ALL, "C") == NULL) + FAIL_EXIT1 ("setlocale (LC_ALL, \"C\")"); +} + +static void +switch_to_c_utf8 (void) +{ + if (setlocale (LC_ALL, "C.UTF-8") == NULL) + FAIL_EXIT1 ("setlocale (LC_ALL, \"C.UTF-8\")"); +} + +static char * +str (nl_item item) +{ + if (!use_nl_langinfo_l) + switch_to_c (); + return nl_langinfo (item); +} + +static char * +str_utf8 (nl_item item) +{ + if (use_nl_langinfo_l) + return nl_langinfo_l (item, c_utf8); + else + { + switch_to_c_utf8 (); + return nl_langinfo (item); + } +} + +static wchar_t * +wstr (nl_item item) +{ + return (wchar_t *) str (item); +} + +static wchar_t * +wstr_utf8 (nl_item item) +{ + return (wchar_t *) str_utf8 (item); +} + +static int +byte (nl_item item) +{ + return (signed char) *str (item); +} + +static int +byte_utf8 (nl_item item) +{ + return (signed char) *str_utf8 (item); +} + +static int +word (nl_item item) +{ + union + { + char *ptr; + int word; + } u; + u.ptr = str (item); + return u.word; +} + +static int +word_utf8 (nl_item item) +{ + union + { + char *ptr; + int word; + } u; + u.ptr = str_utf8 (item); + return u.word; +} + +static void +one_pass (void) +{ + /* LC_TIME. */ + TEST_COMPARE_STRING (str (ABDAY_1), str_utf8 (ABDAY_1)); + TEST_COMPARE_STRING (str (ABDAY_2), str_utf8 (ABDAY_2)); + TEST_COMPARE_STRING (str (ABDAY_3), str_utf8 (ABDAY_3)); + TEST_COMPARE_STRING (str (ABDAY_4), str_utf8 (ABDAY_4)); + TEST_COMPARE_STRING (str (ABDAY_5), str_utf8 (ABDAY_5)); + TEST_COMPARE_STRING (str (ABDAY_6), str_utf8 (ABDAY_6)); + TEST_COMPARE_STRING (str (ABDAY_7), str_utf8 (ABDAY_7)); + + TEST_COMPARE_STRING (str (DAY_1), str_utf8 (DAY_1)); + TEST_COMPARE_STRING (str (DAY_2), str_utf8 (DAY_2)); + TEST_COMPARE_STRING (str (DAY_3), str_utf8 (DAY_3)); + TEST_COMPARE_STRING (str (DAY_4), str_utf8 (DAY_4)); + TEST_COMPARE_STRING (str (DAY_5), str_utf8 (DAY_5)); + TEST_COMPARE_STRING (str (DAY_6), str_utf8 (DAY_6)); + TEST_COMPARE_STRING (str (DAY_7), str_utf8 (DAY_7)); + + TEST_COMPARE_STRING (str (ABMON_1), str_utf8 (ABMON_1)); + TEST_COMPARE_STRING (str (ABMON_2), str_utf8 (ABMON_2)); + TEST_COMPARE_STRING (str (ABMON_3), str_utf8 (ABMON_3)); + TEST_COMPARE_STRING (str (ABMON_4), str_utf8 (ABMON_4)); + TEST_COMPARE_STRING (str (ABMON_5), str_utf8 (ABMON_5)); + TEST_COMPARE_STRING (str (ABMON_6), str_utf8 (ABMON_6)); + TEST_COMPARE_STRING (str (ABMON_7), str_utf8 (ABMON_7)); + TEST_COMPARE_STRING (str (ABMON_8), str_utf8 (ABMON_8)); + TEST_COMPARE_STRING (str (ABMON_9), str_utf8 (ABMON_9)); + TEST_COMPARE_STRING (str (ABMON_10), str_utf8 (ABMON_10)); + TEST_COMPARE_STRING (str (ABMON_11), str_utf8 (ABMON_11)); + TEST_COMPARE_STRING (str (ABMON_12), str_utf8 (ABMON_12)); + + TEST_COMPARE_STRING (str (MON_1), str_utf8 (MON_1)); + TEST_COMPARE_STRING (str (MON_2), str_utf8 (MON_2)); + TEST_COMPARE_STRING (str (MON_3), str_utf8 (MON_3)); + TEST_COMPARE_STRING (str (MON_4), str_utf8 (MON_4)); + TEST_COMPARE_STRING (str (MON_5), str_utf8 (MON_5)); + TEST_COMPARE_STRING (str (MON_6), str_utf8 (MON_6)); + TEST_COMPARE_STRING (str (MON_7), str_utf8 (MON_7)); + TEST_COMPARE_STRING (str (MON_8), str_utf8 (MON_8)); + TEST_COMPARE_STRING (str (MON_9), str_utf8 (MON_9)); + TEST_COMPARE_STRING (str (MON_10), str_utf8 (MON_10)); + TEST_COMPARE_STRING (str (MON_11), str_utf8 (MON_11)); + TEST_COMPARE_STRING (str (MON_12), str_utf8 (MON_12)); + + TEST_COMPARE_STRING (str (AM_STR), str_utf8 (AM_STR)); + TEST_COMPARE_STRING (str (PM_STR), str_utf8 (PM_STR)); + + TEST_COMPARE_STRING (str (D_T_FMT), str_utf8 (D_T_FMT)); + TEST_COMPARE_STRING (str (D_FMT), str_utf8 (D_FMT)); + TEST_COMPARE_STRING (str (T_FMT), str_utf8 (T_FMT)); + TEST_COMPARE_STRING (str (T_FMT_AMPM), + str_utf8 (T_FMT_AMPM)); + + TEST_COMPARE_STRING (str (ERA), str_utf8 (ERA)); + TEST_COMPARE_STRING (str (ERA_YEAR), str_utf8 (ERA_YEAR)); + TEST_COMPARE_STRING (str (ERA_D_FMT), str_utf8 (ERA_D_FMT)); + TEST_COMPARE_STRING (str (ALT_DIGITS), str_utf8 (ALT_DIGITS)); + TEST_COMPARE_STRING (str (ERA_D_T_FMT), str_utf8 (ERA_D_T_FMT)); + TEST_COMPARE_STRING (str (ERA_T_FMT), str_utf8 (ERA_T_FMT)); + TEST_COMPARE (word (_NL_TIME_ERA_NUM_ENTRIES), + word_utf8 (_NL_TIME_ERA_NUM_ENTRIES)); + /* No array elements, so nothing to compare for _NL_TIME_ERA_ENTRIES. */ + TEST_COMPARE (word (_NL_TIME_ERA_NUM_ENTRIES), 0); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_1), wstr_utf8 (_NL_WABDAY_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_2), wstr_utf8 (_NL_WABDAY_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_3), wstr_utf8 (_NL_WABDAY_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_4), wstr_utf8 (_NL_WABDAY_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_5), wstr_utf8 (_NL_WABDAY_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_6), wstr_utf8 (_NL_WABDAY_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_7), wstr_utf8 (_NL_WABDAY_7)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_1), wstr_utf8 (_NL_WDAY_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_2), wstr_utf8 (_NL_WDAY_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_3), wstr_utf8 (_NL_WDAY_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_4), wstr_utf8 (_NL_WDAY_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_5), wstr_utf8 (_NL_WDAY_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_6), wstr_utf8 (_NL_WDAY_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_7), wstr_utf8 (_NL_WDAY_7)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_1), wstr_utf8 (_NL_WABMON_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_2), wstr_utf8 (_NL_WABMON_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_3), wstr_utf8 (_NL_WABMON_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_4), wstr_utf8 (_NL_WABMON_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_5), wstr_utf8 (_NL_WABMON_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_6), wstr_utf8 (_NL_WABMON_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_7), wstr_utf8 (_NL_WABMON_7)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_8), wstr_utf8 (_NL_WABMON_8)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_9), wstr_utf8 (_NL_WABMON_9)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_10), wstr_utf8 (_NL_WABMON_10)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_11), wstr_utf8 (_NL_WABMON_11)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_12), wstr_utf8 (_NL_WABMON_12)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_1), wstr_utf8 (_NL_WMON_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_2), wstr_utf8 (_NL_WMON_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_3), wstr_utf8 (_NL_WMON_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_4), wstr_utf8 (_NL_WMON_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_5), wstr_utf8 (_NL_WMON_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_6), wstr_utf8 (_NL_WMON_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_7), wstr_utf8 (_NL_WMON_7)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_8), wstr_utf8 (_NL_WMON_8)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_9), wstr_utf8 (_NL_WMON_9)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_10), wstr_utf8 (_NL_WMON_10)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_11), wstr_utf8 (_NL_WMON_11)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_12), wstr_utf8 (_NL_WMON_12)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WAM_STR), wstr_utf8 (_NL_WAM_STR)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WPM_STR), wstr_utf8 (_NL_WPM_STR)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WD_T_FMT), wstr_utf8 (_NL_WD_T_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WD_FMT), wstr_utf8 (_NL_WD_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WT_FMT), wstr_utf8 (_NL_WT_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WT_FMT_AMPM), + wstr_utf8 (_NL_WT_FMT_AMPM)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_YEAR), wstr_utf8 (_NL_WERA_YEAR)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_D_FMT), wstr_utf8 (_NL_WERA_D_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALT_DIGITS), + wstr_utf8 (_NL_WALT_DIGITS)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_D_T_FMT), + wstr_utf8 (_NL_WERA_D_T_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_T_FMT), wstr_utf8 (_NL_WERA_T_FMT)); + + /* This is somewhat inconsistent, but see locale/categories.def. */ + TEST_COMPARE (byte (_NL_TIME_WEEK_NDAYS), byte_utf8 (_NL_TIME_WEEK_NDAYS)); + TEST_COMPARE (word (_NL_TIME_WEEK_1STDAY), + word_utf8 (_NL_TIME_WEEK_1STDAY)); + TEST_COMPARE (byte (_NL_TIME_WEEK_1STWEEK), + byte_utf8 (_NL_TIME_WEEK_1STWEEK)); + TEST_COMPARE (byte (_NL_TIME_FIRST_WEEKDAY), + byte_utf8 (_NL_TIME_FIRST_WEEKDAY)); + TEST_COMPARE (byte (_NL_TIME_FIRST_WORKDAY), + byte_utf8 (_NL_TIME_FIRST_WORKDAY)); + TEST_COMPARE (byte (_NL_TIME_CAL_DIRECTION), + byte_utf8 (_NL_TIME_CAL_DIRECTION)); + TEST_COMPARE_STRING (str (_NL_TIME_TIMEZONE), str_utf8 (_NL_TIME_TIMEZONE)); + + TEST_COMPARE_STRING (str (_DATE_FMT), str_utf8 (_DATE_FMT)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_W_DATE_FMT), wstr_utf8 (_NL_W_DATE_FMT)); + + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_TIME_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_TIME_CODESET), "UTF-8"); + + TEST_COMPARE_STRING (str (ALTMON_1), str_utf8 (ALTMON_1)); + TEST_COMPARE_STRING (str (ALTMON_2), str_utf8 (ALTMON_2)); + TEST_COMPARE_STRING (str (ALTMON_3), str_utf8 (ALTMON_3)); + TEST_COMPARE_STRING (str (ALTMON_4), str_utf8 (ALTMON_4)); + TEST_COMPARE_STRING (str (ALTMON_5), str_utf8 (ALTMON_5)); + TEST_COMPARE_STRING (str (ALTMON_6), str_utf8 (ALTMON_6)); + TEST_COMPARE_STRING (str (ALTMON_7), str_utf8 (ALTMON_7)); + TEST_COMPARE_STRING (str (ALTMON_8), str_utf8 (ALTMON_8)); + TEST_COMPARE_STRING (str (ALTMON_9), str_utf8 (ALTMON_9)); + TEST_COMPARE_STRING (str (ALTMON_10), str_utf8 (ALTMON_10)); + TEST_COMPARE_STRING (str (ALTMON_11), str_utf8 (ALTMON_11)); + TEST_COMPARE_STRING (str (ALTMON_12), str_utf8 (ALTMON_12)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_1), wstr_utf8 (_NL_WALTMON_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_2), wstr_utf8 (_NL_WALTMON_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_3), wstr_utf8 (_NL_WALTMON_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_4), wstr_utf8 (_NL_WALTMON_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_5), wstr_utf8 (_NL_WALTMON_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_6), wstr_utf8 (_NL_WALTMON_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_7), wstr_utf8 (_NL_WALTMON_7)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_8), wstr_utf8 (_NL_WALTMON_8)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_9), wstr_utf8 (_NL_WALTMON_9)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_10), wstr_utf8 (_NL_WALTMON_10)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_11), wstr_utf8 (_NL_WALTMON_11)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_12), wstr_utf8 (_NL_WALTMON_12)); + + TEST_COMPARE_STRING (str (_NL_ABALTMON_1), str_utf8 (_NL_ABALTMON_1)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_2), str_utf8 (_NL_ABALTMON_2)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_3), str_utf8 (_NL_ABALTMON_3)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_4), str_utf8 (_NL_ABALTMON_4)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_5), str_utf8 (_NL_ABALTMON_5)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_6), str_utf8 (_NL_ABALTMON_6)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_7), str_utf8 (_NL_ABALTMON_7)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_8), str_utf8 (_NL_ABALTMON_8)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_9), str_utf8 (_NL_ABALTMON_9)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_10), str_utf8 (_NL_ABALTMON_10)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_11), str_utf8 (_NL_ABALTMON_11)); + TEST_COMPARE_STRING (str (_NL_ABALTMON_12), str_utf8 (_NL_ABALTMON_12)); + + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_1), + wstr_utf8 (_NL_WABALTMON_1)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_2), + wstr_utf8 (_NL_WABALTMON_2)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_3), + wstr_utf8 (_NL_WABALTMON_3)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_4), + wstr_utf8 (_NL_WABALTMON_4)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_5), + wstr_utf8 (_NL_WABALTMON_5)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_6), + wstr_utf8 (_NL_WABALTMON_6)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_7), + wstr_utf8 (_NL_WABALTMON_7)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_8), + wstr_utf8 (_NL_WABALTMON_8)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_9), + wstr_utf8 (_NL_WABALTMON_9)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_10), + wstr_utf8 (_NL_WABALTMON_10)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_11), + wstr_utf8 (_NL_WABALTMON_11)); + TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_12), + wstr_utf8 (_NL_WABALTMON_12)); + + /* LC_COLLATE. Mostly untested, only expected differences. */ + TEST_COMPARE_STRING (str (_NL_COLLATE_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_COLLATE_CODESET), "UTF-8"); + + /* LC_CTYPE. Mostly untested, only expected differences. */ + TEST_COMPARE_STRING (str (CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (CODESET), "UTF-8"); + + /* LC_MONETARY. */ + TEST_COMPARE_STRING (str (INT_CURR_SYMBOL), str_utf8 (INT_CURR_SYMBOL)); + TEST_COMPARE_STRING (str (CURRENCY_SYMBOL), str_utf8 (CURRENCY_SYMBOL)); + TEST_COMPARE_STRING (str (MON_DECIMAL_POINT), str_utf8 (MON_DECIMAL_POINT)); + TEST_COMPARE_STRING (str (MON_THOUSANDS_SEP), str_utf8 (MON_THOUSANDS_SEP)); + TEST_COMPARE_STRING (str (MON_GROUPING), str_utf8 (MON_GROUPING)); + TEST_COMPARE_STRING (str (POSITIVE_SIGN), str_utf8 (POSITIVE_SIGN)); + TEST_COMPARE_STRING (str (NEGATIVE_SIGN), str_utf8 (NEGATIVE_SIGN)); + TEST_COMPARE (byte (INT_FRAC_DIGITS), byte_utf8 (INT_FRAC_DIGITS)); + TEST_COMPARE (byte (FRAC_DIGITS), byte_utf8 (FRAC_DIGITS)); + TEST_COMPARE (byte (P_CS_PRECEDES), byte_utf8 (P_CS_PRECEDES)); + TEST_COMPARE (byte (P_SEP_BY_SPACE), byte_utf8 (P_SEP_BY_SPACE)); + TEST_COMPARE (byte (N_CS_PRECEDES), byte_utf8 (N_CS_PRECEDES)); + TEST_COMPARE (byte (N_SEP_BY_SPACE), byte_utf8 (N_SEP_BY_SPACE)); + TEST_COMPARE (byte (P_SIGN_POSN), byte_utf8 (P_SIGN_POSN)); + TEST_COMPARE (byte (N_SIGN_POSN), byte_utf8 (N_SIGN_POSN)); + TEST_COMPARE_STRING (str (CRNCYSTR), str_utf8 (CRNCYSTR)); + TEST_COMPARE (byte (INT_P_CS_PRECEDES), byte_utf8 (INT_P_CS_PRECEDES)); + TEST_COMPARE (byte (INT_P_SEP_BY_SPACE), byte_utf8 (INT_P_SEP_BY_SPACE)); + TEST_COMPARE (byte (INT_N_CS_PRECEDES), byte_utf8 (INT_N_CS_PRECEDES)); + TEST_COMPARE (byte (INT_N_SEP_BY_SPACE), byte_utf8 (INT_N_SEP_BY_SPACE)); + TEST_COMPARE (byte (INT_P_SIGN_POSN), byte_utf8 (INT_P_SIGN_POSN)); + TEST_COMPARE (byte (INT_N_SIGN_POSN), byte_utf8 (INT_N_SIGN_POSN)); + TEST_COMPARE_STRING (str (_NL_MONETARY_DUO_INT_CURR_SYMBOL), + str_utf8 (_NL_MONETARY_DUO_INT_CURR_SYMBOL)); + TEST_COMPARE_STRING (str (_NL_MONETARY_DUO_CURRENCY_SYMBOL), + str_utf8 (_NL_MONETARY_DUO_CURRENCY_SYMBOL)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_FRAC_DIGITS), + byte_utf8 (_NL_MONETARY_DUO_INT_FRAC_DIGITS)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_FRAC_DIGITS), + byte_utf8 (_NL_MONETARY_DUO_FRAC_DIGITS)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_P_CS_PRECEDES), + byte_utf8 (_NL_MONETARY_DUO_P_CS_PRECEDES)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_P_SEP_BY_SPACE), + byte_utf8 (_NL_MONETARY_DUO_P_SEP_BY_SPACE)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_N_CS_PRECEDES), + byte_utf8 (_NL_MONETARY_DUO_N_CS_PRECEDES)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_N_SEP_BY_SPACE), + byte_utf8 (_NL_MONETARY_DUO_N_SEP_BY_SPACE)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_CS_PRECEDES), + byte_utf8 (_NL_MONETARY_DUO_INT_P_CS_PRECEDES)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE), + byte_utf8 (_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_CS_PRECEDES), + byte_utf8 (_NL_MONETARY_DUO_INT_N_CS_PRECEDES)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE), + byte_utf8 (_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_INT_P_SIGN_POSN)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_INT_N_SIGN_POSN)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_P_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_P_SIGN_POSN)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_N_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_N_SIGN_POSN)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_INT_P_SIGN_POSN)); + TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SIGN_POSN), + byte_utf8 (_NL_MONETARY_DUO_INT_N_SIGN_POSN)); + TEST_COMPARE (word (_NL_MONETARY_UNO_VALID_FROM), + word_utf8 (_NL_MONETARY_UNO_VALID_FROM)); + TEST_COMPARE (word (_NL_MONETARY_UNO_VALID_TO), + word_utf8 (_NL_MONETARY_UNO_VALID_TO)); + TEST_COMPARE (word (_NL_MONETARY_DUO_VALID_FROM), + word_utf8 (_NL_MONETARY_DUO_VALID_FROM)); + TEST_COMPARE (word (_NL_MONETARY_DUO_VALID_TO), + word_utf8 (_NL_MONETARY_DUO_VALID_TO)); + /* _NL_MONETARY_CONVERSION_RATE cannot be tested (word array). */ + TEST_COMPARE (word (_NL_MONETARY_DECIMAL_POINT_WC), + word_utf8 (_NL_MONETARY_DECIMAL_POINT_WC)); + TEST_COMPARE (word (_NL_MONETARY_THOUSANDS_SEP_WC), + word_utf8 (_NL_MONETARY_THOUSANDS_SEP_WC)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_MONETARY_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_MONETARY_CODESET), "UTF-8"); + + /* LC_NUMERIC. */ + + TEST_COMPARE_STRING (str (DECIMAL_POINT), str_utf8 (DECIMAL_POINT)); + TEST_COMPARE_STRING (str (RADIXCHAR), str_utf8 (RADIXCHAR)); + TEST_COMPARE_STRING (str (THOUSANDS_SEP), str_utf8 (THOUSANDS_SEP)); + TEST_COMPARE_STRING (str (THOUSEP), str_utf8 (THOUSEP)); + TEST_COMPARE_STRING (str (GROUPING), str_utf8 (GROUPING)); + TEST_COMPARE (word (_NL_NUMERIC_DECIMAL_POINT_WC), + word_utf8 (_NL_NUMERIC_DECIMAL_POINT_WC)); + TEST_COMPARE (word (_NL_NUMERIC_THOUSANDS_SEP_WC), + word_utf8 (_NL_NUMERIC_THOUSANDS_SEP_WC)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_NUMERIC_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_NUMERIC_CODESET), "UTF-8"); + + /* LC_MESSAGES. */ + + TEST_COMPARE_STRING (str (YESEXPR), str_utf8 (YESEXPR)); + TEST_COMPARE_STRING (str (NOEXPR), str_utf8 (NOEXPR)); + TEST_COMPARE_STRING (str (YESSTR), str_utf8 (YESSTR)); + TEST_COMPARE_STRING (str (NOSTR), str_utf8 (NOSTR)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_MESSAGES_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_MESSAGES_CODESET), "UTF-8"); + + /* LC_PAPER. */ + + TEST_COMPARE (word (_NL_PAPER_HEIGHT), word_utf8 (_NL_PAPER_HEIGHT)); + TEST_COMPARE (word (_NL_PAPER_WIDTH), word_utf8 (_NL_PAPER_WIDTH)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_PAPER_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_PAPER_CODESET), "UTF-8"); + + /* LC_NAME. */ + + TEST_COMPARE_STRING (str (_NL_NAME_NAME_FMT), + str_utf8 (_NL_NAME_NAME_FMT)); + TEST_COMPARE_STRING (str (_NL_NAME_NAME_GEN), + str_utf8 (_NL_NAME_NAME_GEN)); + TEST_COMPARE_STRING (str (_NL_NAME_NAME_MR), + str_utf8 (_NL_NAME_NAME_MR)); + TEST_COMPARE_STRING (str (_NL_NAME_NAME_MRS), + str_utf8 (_NL_NAME_NAME_MRS)); + TEST_COMPARE_STRING (str (_NL_NAME_NAME_MISS), + str_utf8 (_NL_NAME_NAME_MISS)); + TEST_COMPARE_STRING (str (_NL_NAME_NAME_MS), + str_utf8 (_NL_NAME_NAME_MS)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_NAME_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_NAME_CODESET), "UTF-8"); + + /* LC_ADDRESS. */ + + TEST_COMPARE_STRING (str (_NL_ADDRESS_POSTAL_FMT), + str_utf8 (_NL_ADDRESS_POSTAL_FMT)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_NAME), + str_utf8 (_NL_ADDRESS_COUNTRY_NAME)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_POST), + str_utf8 (_NL_ADDRESS_COUNTRY_POST)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_AB2), + str_utf8 (_NL_ADDRESS_COUNTRY_AB2)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_AB3), + str_utf8 (_NL_ADDRESS_COUNTRY_AB3)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_CAR), + str_utf8 (_NL_ADDRESS_COUNTRY_CAR)); + TEST_COMPARE (word (_NL_ADDRESS_COUNTRY_NUM), + word_utf8 (_NL_ADDRESS_COUNTRY_NUM)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_ISBN), + str_utf8 (_NL_ADDRESS_COUNTRY_ISBN)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_NAME), + str_utf8 (_NL_ADDRESS_LANG_NAME)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_AB), + str_utf8 (_NL_ADDRESS_LANG_AB)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_TERM), + str_utf8 (_NL_ADDRESS_LANG_TERM)); + TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_LIB), + str_utf8 (_NL_ADDRESS_LANG_LIB)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_ADDRESS_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_ADDRESS_CODESET), "UTF-8"); + + /* LC_TELEPHONE. */ + + TEST_COMPARE_STRING (str (_NL_TELEPHONE_TEL_INT_FMT), + str_utf8 (_NL_TELEPHONE_TEL_INT_FMT)); + TEST_COMPARE_STRING (str (_NL_TELEPHONE_TEL_DOM_FMT), + str_utf8 (_NL_TELEPHONE_TEL_DOM_FMT)); + TEST_COMPARE_STRING (str (_NL_TELEPHONE_INT_SELECT), + str_utf8 (_NL_TELEPHONE_INT_SELECT)); + TEST_COMPARE_STRING (str (_NL_TELEPHONE_INT_PREFIX), + str_utf8 (_NL_TELEPHONE_INT_PREFIX)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_TELEPHONE_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_TELEPHONE_CODESET), "UTF-8"); + + /* LC_MEASUREMENT. */ + + TEST_COMPARE (byte (_NL_MEASUREMENT_MEASUREMENT), + byte_utf8 (_NL_MEASUREMENT_MEASUREMENT)); + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_MEASUREMENT_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_MEASUREMENT_CODESET), "UTF-8"); + + /* LC_IDENTIFICATION is skipped since C.UTF-8 is distinct from C. */ + + /* _NL_IDENTIFICATION_CATEGORY cannot be tested because it is a + string array. */ + /* Expected difference. */ + TEST_COMPARE_STRING (str (_NL_IDENTIFICATION_CODESET), "ANSI_X3.4-1968"); + TEST_COMPARE_STRING (str_utf8 (_NL_IDENTIFICATION_CODESET), "UTF-8"); +} + +static int +do_test (void) +{ + puts ("info: using setlocale and nl_langinfo"); + one_pass (); + + puts ("info: using nl_langinfo_l"); + + c_utf8 = newlocale (LC_ALL_MASK, "C.UTF-8", (locale_t) 0); + TEST_VERIFY_EXIT (c_utf8 != (locale_t) 0); + + switch_to_c (); + use_nl_langinfo_l = true; + one_pass (); + + freelocale (c_utf8); + + return 0; +} + +#include