diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-04-11 01:07:57 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-04-11 01:07:57 +0000 |
commit | 671ab00dcc3eaa263ab225ac26e7fc6b7677b3d0 (patch) | |
tree | 29e83c04cb40b5df0af1a438abd001f41055214a | |
parent | 7e3f28752e9d9d5c3c92feec638c11f5c5505d17 (diff) | |
download | glibc-671ab00dcc3eaa263ab225ac26e7fc6b7677b3d0.tar.gz glibc-671ab00dcc3eaa263ab225ac26e7fc6b7677b3d0.tar.xz glibc-671ab00dcc3eaa263ab225ac26e7fc6b7677b3d0.zip |
Update.
* locale/tst-C-locale.c (run_test): Add tests for locale objects. * locale/newlocale.c (__newlocale): Correct setting __ctype_b, __ctype_tolower, and __ctype_toupper elements.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | locale/newlocale.c | 6 | ||||
-rw-r--r-- | locale/tst-C-locale.c | 186 |
3 files changed, 190 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index 82ef524cf0..44cc2024e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2001-04-10 Ulrich Drepper <drepper@redhat.com> + * locale/tst-C-locale.c (run_test): Add tests for locale objects. + * locale/newlocale.c (__newlocale): Correct setting __ctype_b, + __ctype_tolower, and __ctype_toupper elements. + * ctype/ctype_l.c: Fix definitions of __tolower_l and __toupper_l. Reported by Konstantin Osipov <rabid@spylog.ru>. diff --git a/locale/newlocale.c b/locale/newlocale.c index 1f5b745bb0..423e137b62 100644 --- a/locale/newlocale.c +++ b/locale/newlocale.c @@ -173,11 +173,11 @@ __newlocale (int category_mask, const char *locale, __locale_t base) { union locale_data_value *ctypes = result_ptr->__locales[LC_CTYPE]->values; result_ptr->__ctype_b = (const unsigned short int *) - (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_CLASS)].string); + ctypes[_NL_ITEM_INDEX (_NL_CTYPE_CLASS)].string + 128; result_ptr->__ctype_tolower = (const int *) - (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER)].string); + ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER)].string + 128; result_ptr->__ctype_toupper = (const int *) - (ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER)].string); + ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER)].string + 128; } return result_ptr; diff --git a/locale/tst-C-locale.c b/locale/tst-C-locale.c index e14806f578..1d2137270d 100644 --- a/locale/tst-C-locale.c +++ b/locale/tst-C-locale.c @@ -1,5 +1,5 @@ /* Tests of C and POSIX locale contents. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2001 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 @@ -17,6 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <ctype.h> #include <langinfo.h> #include <limits.h> #include <locale.h> @@ -32,6 +33,7 @@ run_test (const char *locname) const char *str; const wchar_t *wstr; int result = 0; + __locale_t loc; /* ISO C stuff. */ lc = localeconv (); @@ -92,7 +94,7 @@ run_test (const char *locname) str = nl_langinfo (name); \ if (strcmp (str, exp) != 0) \ { \ - printf ("nl_langinfo(" #name ") int locale %s wrong " \ + printf ("nl_langinfo(" #name ") in locale %s wrong " \ "(is \"%s\", should be \"%s\")\n", locname, str, exp); \ result = 1; \ } @@ -100,7 +102,7 @@ run_test (const char *locname) wstr = (wchar_t *) nl_langinfo (name); \ if (wcscmp (wstr, exp) != 0) \ { \ - printf ("nl_langinfo(" #name ") int locale %s wrong " \ + printf ("nl_langinfo(" #name ") in locale %s wrong " \ "(is \"%S\", should be \"%S\")\n", locname, wstr, exp); \ result = 1; \ } @@ -218,6 +220,184 @@ run_test (const char *locname) STRTEST (YESSTR, ""); STRTEST (NOSTR, ""); + /* Test the new locale mechanisms. */ + loc = __newlocale (LC_ALL, locname, NULL); + if (loc == NULL) + { + printf ("cannot create locale object for locale %s\n", locname); + result = 1; + } + else + { + int c; + +#undef STRTEST +#define STRTEST(name, exp) \ + str = __nl_langinfo_l (name, loc); \ + if (strcmp (str, exp) != 0) \ + { \ + printf ("__nl_langinfo_l(" #name ") in locale %s wrong " \ + "(is \"%s\", should be \"%s\")\n", locname, str, exp); \ + result = 1; \ + } +#undef WSTRTEST +#define WSTRTEST(name, exp) \ + wstr = (wchar_t *) __nl_langinfo_l (name, loc); \ + if (wcscmp (wstr, exp) != 0) \ + { \ + printf ("__nl_langinfo_l(" #name ") in 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, ""); + + /* Character class tests. */ + for (c = 0; c < 128; ++c) + { +#define CLASSTEST(name) \ + if (is##name (c) != __is##name##_l (c, loc)) \ + { \ + printf ("is%s('\\%o') != __is%s_l('\\%o')\n", \ + #name, c, #name, c); \ + result = 1; \ + } + CLASSTEST (alnum); + CLASSTEST (alpha); + CLASSTEST (cntrl); + CLASSTEST (digit); + CLASSTEST (lower); + CLASSTEST (graph); + CLASSTEST (print); + CLASSTEST (punct); + CLASSTEST (space); + CLASSTEST (upper); + CLASSTEST (xdigit); + +#define MAPTEST(name) \ + if (to##name (c) != __to##name##_l (c, loc)) \ + { \ + printf ("to%s('\\%o') != __to%s_l('\\%o'): '\\%o' vs '\\%o'\n", \ + #name, c, #name, c, \ + to##name (c), __to##name##_l (c, loc)); \ + result = 1; \ + } + MAPTEST (lower); + MAPTEST (upper); + } + } + return result; } |