summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2019-12-11 07:42:17 +0000
committerPeter Eisentraut2019-12-11 07:42:17 +0000
commitb802412106e82ccf1aef36a4984e321082c122cb (patch)
tree2777dc3cc4bf860e260f7b79259ad949f9bcbc78
parentc341c7d391e256f80cfbae53b4f55278bffca699 (diff)
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 <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb%402ndquadrant.com
-rw-r--r--src/common/unicode/norm_test.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/common/unicode/norm_test.c b/src/common/unicode/norm_test.c
index fee58a184aa..de7d6a72c78 100644
--- a/src/common/unicode/norm_test.c
+++ b/src/common/unicode/norm_test.c
@@ -23,17 +23,20 @@ static char *
print_wchar_str(const pg_wchar *s)
{
#define BUF_DIGITS 50
- static char buf[BUF_DIGITS * 2 + 1];
+ static char buf[BUF_DIGITS * 11 + 1];
int i;
+ char *p;
i = 0;
+ p = buf;
while (*s && i < BUF_DIGITS)
{
- snprintf(&buf[i * 2], 3, "%04X", *s);
+ p += sprintf(p, "U+%04X ", *s);
i++;
s++;
}
- buf[i * 2] = '\0';
+ *p = '\0';
+
return buf;
}
@@ -67,9 +70,9 @@ main(int argc, char **argv)
if (pg_wcscmp(test->output, result) != 0)
{
printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum);
- printf("input:\t%s\n", print_wchar_str(test->input));
- printf("expected:\t%s\n", print_wchar_str(test->output));
- printf("got\t%s\n", print_wchar_str(result));
+ printf("input: %s\n", print_wchar_str(test->input));
+ printf("expected: %s\n", print_wchar_str(test->output));
+ printf("got: %s\n", print_wchar_str(result));
printf("\n");
exit(1);
}