Commit b8024121 authored by Peter Eisentraut's avatar Peter Eisentraut

Fix output of Unicode normalization test

Several off-by-more-than-one errors caused the output in case of a
test failure to be truncated and unintelligible.
Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb%402ndquadrant.com
parent c341c7d3
...@@ -23,17 +23,20 @@ static char * ...@@ -23,17 +23,20 @@ static char *
print_wchar_str(const pg_wchar *s) print_wchar_str(const pg_wchar *s)
{ {
#define BUF_DIGITS 50 #define BUF_DIGITS 50
static char buf[BUF_DIGITS * 2 + 1]; static char buf[BUF_DIGITS * 11 + 1];
int i; int i;
char *p;
i = 0; i = 0;
p = buf;
while (*s && i < BUF_DIGITS) while (*s && i < BUF_DIGITS)
{ {
snprintf(&buf[i * 2], 3, "%04X", *s); p += sprintf(p, "U+%04X ", *s);
i++; i++;
s++; s++;
} }
buf[i * 2] = '\0'; *p = '\0';
return buf; return buf;
} }
...@@ -67,9 +70,9 @@ main(int argc, char **argv) ...@@ -67,9 +70,9 @@ main(int argc, char **argv)
if (pg_wcscmp(test->output, result) != 0) if (pg_wcscmp(test->output, result) != 0)
{ {
printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum); printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum);
printf("input:\t%s\n", print_wchar_str(test->input)); printf("input: %s\n", print_wchar_str(test->input));
printf("expected:\t%s\n", print_wchar_str(test->output)); printf("expected: %s\n", print_wchar_str(test->output));
printf("got\t%s\n", print_wchar_str(result)); printf("got: %s\n", print_wchar_str(result));
printf("\n"); printf("\n");
exit(1); exit(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment