Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b802412

Browse files
committed
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: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb%402ndquadrant.com
1 parent c341c7d commit b802412

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/common/unicode/norm_test.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ static char *
2323
print_wchar_str(const pg_wchar *s)
2424
{
2525
#define BUF_DIGITS 50
26-
static char buf[BUF_DIGITS * 2 + 1];
26+
static char buf[BUF_DIGITS * 11 + 1];
2727
int i;
28+
char *p;
2829

2930
i = 0;
31+
p = buf;
3032
while (*s && i < BUF_DIGITS)
3133
{
32-
snprintf(&buf[i * 2], 3, "%04X", *s);
34+
p += sprintf(p, "U+%04X ", *s);
3335
i++;
3436
s++;
3537
}
36-
buf[i * 2] = '\0';
38+
*p = '\0';
39+
3740
return buf;
3841
}
3942

@@ -67,9 +70,9 @@ main(int argc, char **argv)
6770
if (pg_wcscmp(test->output, result) != 0)
6871
{
6972
printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum);
70-
printf("input:\t%s\n", print_wchar_str(test->input));
71-
printf("expected:\t%s\n", print_wchar_str(test->output));
72-
printf("got\t%s\n", print_wchar_str(result));
73+
printf("input: %s\n", print_wchar_str(test->input));
74+
printf("expected: %s\n", print_wchar_str(test->output));
75+
printf("got: %s\n", print_wchar_str(result));
7376
printf("\n");
7477
exit(1);
7578
}

0 commit comments

Comments
 (0)