2000-09-05 22:41:48 +00:00
|
|
|
#include <locale.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
/* This is the relevant piece from the charmap:
|
|
|
|
<UFF61> /x8e/xa1 HALFWIDTH IDEOGRAPHIC FULL STOP
|
|
|
|
<UFF62> /x8e/xa2 HALFWIDTH LEFT CORNER BRACKET
|
|
|
|
<UFF63> /x8e/xa3 HALFWIDTH RIGHT CORNER BRACKET
|
|
|
|
<UFF64> /x8e/xa4 HALFWIDTH IDEOGRAPHIC COMMA
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char input[] = "\x8e\xa1g\x8e\xa2h\x8e\xa3i\x8e\xa4j";
|
|
|
|
|
2014-11-05 09:54:08 +00:00
|
|
|
static int
|
|
|
|
do_test (void)
|
2000-09-05 22:41:48 +00:00
|
|
|
{
|
|
|
|
wchar_t buf[1000];
|
|
|
|
#define nbuf (sizeof (buf) / sizeof (buf[0]))
|
|
|
|
int result = 0;
|
|
|
|
ssize_t n;
|
|
|
|
|
|
|
|
if (setlocale (LC_ALL, "ja_JP.EUC-JP") == NULL)
|
|
|
|
{
|
|
|
|
puts ("cannot set locale");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK(fmt, nexp, exp) \
|
|
|
|
n = swprintf (buf, nbuf, fmt, input); \
|
|
|
|
if (n != nexp) \
|
|
|
|
{ \
|
|
|
|
printf ("swprintf (.., .., L\"%ls\", \"%ls\") return %d, not %d\n", \
|
2002-08-27 06:41:29 +00:00
|
|
|
fmt, (wchar_t*) input, (int) n, (int) nexp); \
|
2000-09-05 22:41:48 +00:00
|
|
|
result = 1; \
|
|
|
|
} \
|
|
|
|
else if (wcscmp (buf, exp) != 0) \
|
|
|
|
{ \
|
|
|
|
printf ("\
|
|
|
|
swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n", \
|
2002-08-27 06:41:29 +00:00
|
|
|
fmt, (wchar_t *) input, buf, exp ); \
|
2000-09-05 22:41:48 +00:00
|
|
|
result = 1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK (L"[%-6.0s]", 8, L"[ ]");
|
|
|
|
CHECK (L"[%-6.1s]", 8, L"[\xff61 ]");
|
|
|
|
CHECK (L"[%-6.2s]", 8, L"[\xff61g ]");
|
|
|
|
CHECK (L"[%-6.3s]", 8, L"[\xff61g\xff62 ]");
|
|
|
|
CHECK (L"[%-6.4s]", 8, L"[\xff61g\xff62h ]");
|
|
|
|
CHECK (L"[%-6.5s]", 8, L"[\xff61g\xff62h\xff63 ]");
|
|
|
|
CHECK (L"[%-6.6s]", 8, L"[\xff61g\xff62h\xff63i]");
|
|
|
|
CHECK (L"[%-6.7s]", 9, L"[\xff61g\xff62h\xff63i\xff64]");
|
|
|
|
CHECK (L"[%-6.8s]", 10, L"[\xff61g\xff62h\xff63i\xff64j]");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2014-11-05 09:54:08 +00:00
|
|
|
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
#include "../test-skeleton.c"
|