From 6332497afb798448a5cd744aa7026822823f201b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 4 Apr 2025 23:00:35 +0100 Subject: [PATCH] test_unicode_norm: fix display of failing tests. There was a bytes / array elements confusion in the code that prints out the input and output Unicode strings when a test fails. It was using a loop with index variable 'pos', which was used as an array index, but incremented by sizeof(a character) each time, leading to only every fourth character actually being printed. I assume this is leftover confusion from when I hadn't quite decided whether to abuse the char-based strbuf for these Unicode character buffers, or make a specialist type. Discovered when I reached for this test program just now in order to manually decompose a Unicode string. It doesn't have a convenient CLI for that, but it was a thing I already knew where to find! --- utils/unicode-norm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/unicode-norm.c b/utils/unicode-norm.c index af620fd3..22f48bd4 100644 --- a/utils/unicode-norm.c +++ b/utils/unicode-norm.c @@ -341,13 +341,13 @@ static void subtest(const char *filename, int lineno, const char *subdesc, pass++; } else { printf("%s:%d: failed %s: NF%c([", filename, lineno, subdesc, nftype); - for (size_t pos = 0; pos < input->len; pos += sizeof(uchar)) + for (size_t pos = 0; pos < input->len; pos++) printf("%s%04X", pos ? " " : "", (unsigned)input->buf[pos]); printf("]) -> ["); - for (size_t pos = 0; pos < nf->len; pos += sizeof(uchar)) + for (size_t pos = 0; pos < nf->len; pos++) printf("%s%04X", pos ? " " : "", (unsigned)nf->buf[pos]); printf("] != ["); - for (size_t pos = 0; pos < expected->len; pos += sizeof(uchar)) + for (size_t pos = 0; pos < expected->len; pos++) printf("%s%04X", pos ? " " : "", (unsigned)expected->buf[pos]); printf("]\n"); fail++;