* 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.
This commit is contained in:
Ulrich Drepper 2000-06-27 03:59:26 +00:00
parent 6ba025af69
commit 4edc30e4d7
4 changed files with 173 additions and 23 deletions

View File

@ -1,5 +1,20 @@
2000-06-26 Ulrich Drepper <drepper@redhat.com>
* 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.

View File

@ -284,7 +284,7 @@ space /
% ISO/IEC 6429/
<U0008>;<U000A>..<U000D>;/
% TABLE 1 BASIC LATIN/
<U0020>;/
<U0020>;<U00A0>;/
% TABLE 35 GENERAL PUNCTUATION/
<U2000>..<U2006>;<U2008>..<U200B>;/
% TABLE 50 CJK SYMBOLS AND PUNCTUATION, HIRAGANA/
@ -294,7 +294,7 @@ cntrl <U0001>..<U001F>;<U007F>..<U009F>
%
punct /
<U0021>..<U002F>;<U003A>..<U0040>;<U005B>..<U0060>;<U007B>..<U007E>;/
<U00A0>..<U00A9>;<U00AB>..<U00B4>;<U00B6>..<U00B9>;<U00BB>..<U00BF>;/
<U00A1>..<U00A9>;<U00AB>..<U00B4>;<U00B6>..<U00B9>;<U00BB>..<U00BF>;/
<U00D7>;<U00F7>;/
<U037E>;<U0482>;<U055A>..<U055F>;<U0589>;<U05BE>;<U05C0>;<U05C3>;/
<U05F3>;<U05F4>;<U060C>;<U061B>;<U061F>;<U0640>;<U064B>..<U0652>;/
@ -387,7 +387,7 @@ graph /
%
xdigit <U0030>..<U0039>;<U0041>..<U0046>;<U0061>..<U0066>
%
blank <U0008>;<U0020>;<U2000>..<U2006>;<U2008>..<U200B>;<U3000>
blank <U0008>;<U0020>;<U00A0>;<U2000>..<U2006>;<U2008>..<U200B>;<U3000>
%
toupper /
(<U0061>,<U0041>);(<U0062>,<U0042>);(<U0063>,<U0043>);(<U0064>,<U0044>);/

View File

@ -20,6 +20,7 @@
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
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,13 +77,12 @@ 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",
/* 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);
@ -66,7 +94,6 @@ main (void)
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;
}

View File

@ -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