From 6a7f92da641360fe4c0bb37288982f72d211db7b Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 24 Jun 2015 14:07:15 -0400 Subject: fix #46 (make sure symbol-like codepoints have nonzero width even if they aren't in Unifont) --- test/charwidth.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test/charwidth.c') diff --git a/test/charwidth.c b/test/charwidth.c index 28554a4..986e7ca 100644 --- a/test/charwidth.c +++ b/test/charwidth.c @@ -10,7 +10,7 @@ int my_isprint(int c) { int main(int argc, char **argv) { - int c, error = 0; + int c, error = 0, updates = 0; (void) argc; /* unused */ (void) argv; /* unused */ @@ -24,6 +24,13 @@ int main(int argc, char **argv) fprintf(stderr, "nonzero width %d for combining char %x\n", w, c); error = 1; } + if (w == 0 && + ((cat >= UTF8PROC_CATEGORY_LU && cat <= UTF8PROC_CATEGORY_LO) || + (cat >= UTF8PROC_CATEGORY_ND && cat <= UTF8PROC_CATEGORY_SC) || + (cat >= UTF8PROC_CATEGORY_SO && cat <= UTF8PROC_CATEGORY_ZS))) { + fprintf(stderr, "zero width for symbol-like char %x\n", c); + error = 1; + } if (c <= 127 && ((!isprint(c) && w > 0) || (isprint(c) && wcwidth(c) != w))) { fprintf(stderr, "wcwidth %d mismatch %d for %s ASCII %x\n", @@ -44,17 +51,20 @@ int main(int argc, char **argv) int w = utf8proc_charwidth(c); int wc = wcwidth(c); if (sizeof(wchar_t) == 2 && c >= (1<<16)) continue; -#if 0 /* lots of these errors for out-of-date system unicode tables */ - if (wc == -1 && my_isprint(c) && w > 0) + if (wc == -1 && my_isprint(c) && w > 0) { + updates += 1; +#if 0 printf(" wcwidth(%x) = -1 for printable char\n", c); #endif + } if (wc == -1 && !my_isprint(c) && w > 0) printf(" wcwidth(%x) = -1 for non-printable width-%d char\n", c, w); if (wc >= 0 && wc != w) printf(" wcwidth(%x) = %d != charwidth %d\n", c, wc, w); } - + printf(" ... (positive widths for %d chars unknown to wcwidth) ...\n", + updates); printf("Character-width tests SUCCEEDED.\n"); return 0; -- cgit v1.2.3