From 4edc30e4d70ff4bd49abf8dc5a98502f07ff5991 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 27 Jun 2000 03:59:26 +0000 Subject: Update. * tst-ctype.c: Read in more tests from stdin. * tst-ctype.sh: Feed extra test data to program via stdin. * tst-ctype-de_DE.in: New file. * locales/i18n (punct): Exclude U00A0. (blank): Include U00A0. * locales/ja_JP: Updates for new format. * Makefile (test-srcs): Add tst-ctype. (distribute): Add tst-ctype.sh. (do-tst-ctype): New target. Run for tests. * tst-ctype.c: New file. * tst-ctype.sh: New file. --- localedata/ChangeLog | 15 +++++ localedata/locales/i18n | 6 +- localedata/tst-ctype.c | 172 ++++++++++++++++++++++++++++++++++++++++++------ localedata/tst-ctype.sh | 7 +- 4 files changed, 175 insertions(+), 25 deletions(-) (limited to 'localedata') diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 94a65c1baf..48970b2729 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,5 +1,20 @@ 2000-06-26 Ulrich Drepper + * tst-ctype.c: Read in more tests from stdin. + * tst-ctype.sh: Feed extra test data to program via stdin. + * tst-ctype-de_DE.in: New file. + + * locales/i18n (punct): Exclude U00A0. + (blank): Include U00A0. + + * locales/ja_JP: Updates for new format. + + * Makefile (test-srcs): Add tst-ctype. + (distribute): Add tst-ctype.sh. + (do-tst-ctype): New target. Run for tests. + * tst-ctype.c: New file. + * tst-ctype.sh: New file. + * locales/i18n: NUL character must not be in cntrl. * Makefile (test-input): Add en_US.ISO-8859-1. diff --git a/localedata/locales/i18n b/localedata/locales/i18n index e91e60fff3..4d78fba1f0 100644 --- a/localedata/locales/i18n +++ b/localedata/locales/i18n @@ -284,7 +284,7 @@ space / % ISO/IEC 6429/ ;..;/ % TABLE 1 BASIC LATIN/ - ;/ + ;;/ % TABLE 35 GENERAL PUNCTUATION/ ..;..;/ % TABLE 50 CJK SYMBOLS AND PUNCTUATION, HIRAGANA/ @@ -294,7 +294,7 @@ cntrl ..;.. % punct / ..;..;..;..;/ - ..;..;..;..;/ + ..;..;..;..;/ ;;/ ;;..;;;;;/ ;;;;;;..;/ @@ -387,7 +387,7 @@ graph / % xdigit ..;..;.. % -blank ;;..;..; +blank ;;;..;..; % toupper / (,);(,);(,);(,);/ diff --git a/localedata/tst-ctype.c b/localedata/tst-ctype.c index 9ee678201f..729ff6689a 100644 --- a/localedata/tst-ctype.c +++ b/localedata/tst-ctype.c @@ -20,6 +20,7 @@ #include #include #include +#include static const char lower[] = "abcdefghijklmnopqrstuvwxyz"; @@ -27,6 +28,29 @@ static const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char digits[] = "0123456789"; +static struct classes +{ + const char *name; + int mask; +} classes[] = +{ +#define ENTRY(name) { #name, _IS##name } + ENTRY (upper), + ENTRY (lower), + ENTRY (alpha), + ENTRY (digit), + ENTRY (xdigit), + ENTRY (space), + ENTRY (print), + ENTRY (graph), + ENTRY (blank), + ENTRY (cntrl), + ENTRY (punct), + ENTRY (alnum) +}; +#define nclasses (sizeof (classes) / sizeof (classes[0])) + + #define FAIL(str, args...) \ { \ printf (" " str "\n", ##args); \ @@ -40,6 +64,11 @@ main (void) const char *cp; const char *cp2; int errors = 0; + char *inpline = NULL; + size_t inplinelen = 0; + char *resline = NULL; + size_t reslinelen = 0; + int n; setlocale (LC_ALL, ""); @@ -48,25 +77,23 @@ main (void) #if 0 /* Just for debugging. */ - { - /* Contents of the class array. */ - int n = 0; - - printf ("upper = %04x lower = %04x alpha = %04x digit = %04x xdigit = %04x\n" - "space = %04x print = %04x graph = %04x blank = %04x cntrl = %04x\n" - "punct = %04x alnum = %04x\n", - _ISupper, _ISlower, _ISalpha, _ISdigit, _ISxdigit, - _ISspace, _ISprint, _ISgraph, _ISblank, _IScntrl, - _ISpunct, _ISalnum); - - while (n < 256) - { - if (n % 8 == 0) - printf ("%02x: ", n); - printf ("%04x%s", __ctype_b[n], (n + 1) % 8 == 0 ? "\n" : " "); - ++n; - } - } + + /* Contents of the class array. */ + printf ("\ +upper = %04x lower = %04x alpha = %04x digit = %04x xdigit = %04x\n\ +space = %04x print = %04x graph = %04x blank = %04x cntrl = %04x\n\ +punct = %04x alnum = %04x\n", + _ISupper, _ISlower, _ISalpha, _ISdigit, _ISxdigit, + _ISspace, _ISprint, _ISgraph, _ISblank, _IScntrl, + _ISpunct, _ISalnum); + + while (n < 256) + { + if (n % 8 == 0) + printf ("%02x: ", n); + printf ("%04x%s", __ctype_b[n], (n + 1) % 8 == 0 ? "\n" : " "); + ++n; + } #endif puts (" Test of ASCII character range\n special NUL byte handling"); @@ -253,10 +280,113 @@ main (void) FAIL ("toupper ('%c') != '%c'", *cp, *cp); + /* Now some locale specific tests. */ + while (! feof (stdin)) + { + unsigned char *inp; + unsigned char *resp; + + if (getline (&inpline, &inplinelen, stdin) <= 0 + || getline (&resline, &reslinelen, stdin) <= 0) + break; + + inp = strchr (inpline, '\n'); + if (inp != NULL) + *inp = '\0'; + resp = strchr (resline, '\n'); + if (resp != NULL) + *resp = '\0'; + + inp = inpline; + while (*inp != ' ' && *inp != '\t' && *inp && *inp != '\n' + && *inp != '\0') + ++inp; + + if (*inp == '\0') + { + printf ("line \"%s\" is without content\n", inpline); + continue; + } + *inp++ = '\0'; + while (*inp == ' ' || *inp == '\t') + ++inp; + + /* Try all classes. */ + for (n = 0; n < nclasses; ++n) + if (strcmp (inpline, classes[n].name) == 0) + break; + + resp = resline; + while (*resp == ' ' || *resp == '\t') + ++resp; + + if (strlen (inp) != strlen (resp)) + { + printf ("lines \"%.20s\"... and \"%.20s\" have not the same length\n", + inp, resp); + continue; + } + + if (n < nclasses) + { + if (strspn (resp, "01") != strlen (resp)) + { + printf ("result string \"%s\" malformed\n", resp); + continue; + } + + printf (" Locale-specific tests for `%s'\n", inpline); + + while (*inp != '\0' && *inp != '\n') + { + if (((__ctype_b[(unsigned int) *inp] & classes[n].mask) != 0) + != (*resp != '0')) + { + printf (" is%s('%c' = '\\x%02x') %s true\n", inpline, + *inp, *inp, *resp == '1' ? "not" : "is"); + ++errors; + } + ++inp; + ++resp; + } + } + else if (strcmp (inpline, "tolower") == 0) + { + while (*inp != '\0') + { + if (tolower (*inp) != *resp) + { + printf (" tolower('%c' = '\\x%02x') != '%c'\n", + *inp, *inp, *resp); + ++errors; + } + ++inp; + ++resp; + } + } + else if (strcmp (inpline, "toupper") == 0) + { + while (*inp != '\0') + { + if (toupper (*inp) != *resp) + { + printf (" toupper('%c' = '\\x%02x') != '%c'\n", + *inp, *inp, *resp); + ++errors; + } + ++inp; + ++resp; + } + } + else + printf ("\"%s\": unknown class or map\n", inpline); + } + + if (errors != 0) { - printf (" %d errors for `%s' locale\n\n\n", errors, - setlocale (LC_ALL, NULL)); + printf (" %d error%s for `%s' locale\n\n\n", errors, + errors == 1 ? "" : "s", setlocale (LC_ALL, NULL)); return 1; } diff --git a/localedata/tst-ctype.sh b/localedata/tst-ctype.sh index e348464bfc..b768134122 100755 --- a/localedata/tst-ctype.sh +++ b/localedata/tst-ctype.sh @@ -25,9 +25,14 @@ status=0 # Run the test programs. rm -f ${common_objpfx}localedata/tst-ctype.out for loc in de_DE en_US; do + if test -f tst-ctype-$loc.in; then + input=tst-ctype-$loc.in + else + input=/dev/null + fi LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \ LC_ALL=$loc ${common_objpfx}elf/ld.so --library-path $common_objpfx \ - ${common_objpfx}localedata/tst-ctype \ + ${common_objpfx}localedata/tst-ctype < $input \ >> ${common_objpfx}localedata/tst-ctype.out || status=1 done -- cgit 1.4.1