In today's CI run, the test no longer fails on macOS, FreeBSD, Solaris.
It only fails in Alpine Linux and NetBSD.
Weird, NetBSD 10 was the only VM I tested the previous fix on.
Also it's weird because it suggests a mismatch between isprint()
and wcwidth() which is generally -1 for non printable chars.
Ah I see NetBSD 11 is now used in CI.
Updating my local VM to that, it seems the gnulib tables are now used
(I think because __STDC_ISO_10646__ isn't defined),
and gnulib's width only returns -1 for some control chars.
How about something like the following to return -1 for all control chars?
Anyway in the meantime I've applied:
https://github.com/coreutils/coreutils/commit/3a674513e
to skip the test where wcwidth!=-1 for these line separators.
cheers,
Padraig
diff --git a/lib/uniwidth/width.c b/lib/uniwidth/width.c
index 0b440ac395..0063d005ef 100644
--- a/lib/uniwidth/width.c
+++ b/lib/uniwidth/width.c
@@ -23,6 +23,7 @@
#include <stdcountof.h>
#include "cjk.h"
+#include "unictype.h"
/* The non-spacing attribute table consists of:
* Non-spacing characters; generated from PropList.txt or
@@ -57,18 +58,16 @@
int
uc_width (ucs4_t uc, const char *encoding)
{
- /* Test for non-spacing or control character. */
+ if (uc != 0 && uc_is_cntrl (uc))
+ return -1;
+
+ /* Test for non-spacing character. */
if ((uc >> 9) < countof (nonspacing_table_ind))
{
int ind = nonspacing_table_ind[uc >> 9];
if (ind >= 0)
if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1)
- {
- if (uc > 0 && uc < 0xa0)
- return -1;
- else
- return 0;
- }
+ return 0;
}
else if ((uc >> 9) == (0xe0000 >> 9))
{