[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wcwidth: avoid test failure on AIX 7.2
From: |
Bruno Haible |
Subject: |
wcwidth: avoid test failure on AIX 7.2 |
Date: |
Thu, 12 Dec 2019 13:08:18 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) |
On AIX 7.2, the wcwidth test fails:
../../gltests/test-wcwidth.c:72: assertion 'wcwidth (0x200B) == 0' failed
While it is better if wcwidth(0x200B) is zero (because it makes wcswidth
work better), it can be justified that wcwidth(0x200B) is -1:
- In Unicode, the character 0x200B is of category Cf (= Format).
- Therefore AIX does not include this character among the printable or
even the graphic characters (iswprint(0x200B) = iswgraph(0x200B) = 0).
- POSIX [1] says that if a character is not printable, wcwidth returns
-1 for it.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcwidth.html
2019-12-12 Bruno Haible <address@hidden>
wcwidth: Avoid test failure on AIX 7.2.
* tests/test-wcwidth.c (main): Don't fail if wcwidth(0x200B) is
negative.
* doc/posix-functions/wcwidth.texi: Mention the AIX issue.
diff --git a/doc/posix-functions/wcwidth.texi b/doc/posix-functions/wcwidth.texi
index 0acc1c4..a3afe9b 100644
--- a/doc/posix-functions/wcwidth.texi
+++ b/doc/posix-functions/wcwidth.texi
@@ -29,4 +29,8 @@ Portability problems not fixed by Gnulib:
@item
On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore
cannot
accommodate all Unicode characters.
+@item
+This function treats zero-width spaces like control characters on some
+platforms:
+AIX 7.2.
@end itemize
diff --git a/tests/test-wcwidth.c b/tests/test-wcwidth.c
index 8e9cea3..ecb50cd 100644
--- a/tests/test-wcwidth.c
+++ b/tests/test-wcwidth.c
@@ -69,7 +69,11 @@ main ()
#endif
/* Test width of some zero width characters. */
- ASSERT (wcwidth (0x200B) == 0);
+ /* While it is desirable that U+200B, U+200C, U+200D have width 0,
+ because this makes wcswidth work better on strings that contain these
+ characters, it is acceptable if an implementation treats these
+ characters like control characters. */
+ ASSERT (wcwidth (0x200B) <= 0);
ASSERT (wcwidth (0xFEFF) <= 0);
/* Test width of some math symbols.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- wcwidth: avoid test failure on AIX 7.2,
Bruno Haible <=