2001-03-19 21:40:15 +00:00
|
|
|
/* Based on a test case by Paul Eggert. */
|
|
|
|
#include <locale.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
char const string[] = "";
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
test (const char *locale)
|
|
|
|
{
|
|
|
|
size_t bufsize;
|
|
|
|
size_t r;
|
|
|
|
size_t l;
|
|
|
|
char *buf;
|
2002-08-29 09:26:30 +00:00
|
|
|
locale_t loc;
|
2001-03-19 21:40:15 +00:00
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
if (setlocale (LC_COLLATE, locale) == NULL)
|
|
|
|
{
|
|
|
|
printf ("cannot set locale \"%s\"\n", locale);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
bufsize = strxfrm (NULL, string, 0) + 1;
|
|
|
|
buf = malloc (bufsize);
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
|
|
|
printf ("cannot allocate %zd bytes\n", bufsize);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
r = strxfrm (buf, string, bufsize);
|
|
|
|
l = strlen (buf);
|
|
|
|
if (r != l)
|
|
|
|
{
|
|
|
|
printf ("locale \"%s\": strxfrm returned %zu, strlen returned %zu\n",
|
|
|
|
locale, r, l);
|
|
|
|
result = 1;
|
|
|
|
}
|
2001-10-27 03:00:50 +00:00
|
|
|
|
2002-08-29 09:26:30 +00:00
|
|
|
loc = newlocale (1 << LC_ALL, locale, NULL);
|
2001-10-27 03:00:50 +00:00
|
|
|
|
2002-08-29 09:26:30 +00:00
|
|
|
r = strxfrm_l (buf, string, bufsize, loc);
|
2001-10-27 03:00:50 +00:00
|
|
|
l = strlen (buf);
|
|
|
|
if (r != l)
|
|
|
|
{
|
|
|
|
printf ("locale \"%s\": strxfrm_l returned %zu, strlen returned %zu\n",
|
|
|
|
locale, r, l);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
2002-08-29 09:26:30 +00:00
|
|
|
freelocale (loc);
|
2001-10-27 03:00:50 +00:00
|
|
|
|
2001-03-19 21:40:15 +00:00
|
|
|
free (buf);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-05 09:54:08 +00:00
|
|
|
static int
|
|
|
|
do_test (void)
|
2001-03-19 21:40:15 +00:00
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
result |= test ("C");
|
|
|
|
result |= test ("en_US.ISO-8859-1");
|
|
|
|
result |= test ("de_DE.UTF-8");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2014-11-05 09:54:08 +00:00
|
|
|
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
#include "../test-skeleton.c"
|