From b9dce0b6185ce8a05780d64a5a284b3eb7c7e7ea Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 9 Dec 2019 12:02:49 +0100 Subject: [PATCH] Fix output of Unicode normalization test Several off-by-more-than-one errors caused the output in case of a test failure to be unintelligible. --- src/common/unicode/norm_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/unicode/norm_test.c b/src/common/unicode/norm_test.c index fee58a184a..b6d34dd22c 100644 --- a/src/common/unicode/norm_test.c +++ b/src/common/unicode/norm_test.c @@ -23,17 +23,17 @@ 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 * 7 + 1]; int i; i = 0; while (*s && i < BUF_DIGITS) { - snprintf(&buf[i * 2], 3, "%04X", *s); + sprintf(&buf[i * 7], "U+%04X ", *s); i++; s++; } - buf[i * 2] = '\0'; + buf[i * 7] = '\0'; return buf; } @@ -67,9 +67,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); } -- 2.24.0