FRIGN said: > >> DESCRIPTION > >> The wcwidth() function returns the number of columns needed to > >> represent the wide character c. If c is a printable wide > >> character, the value is at least 0. If c > >> is null wide character (L'\0'), the value is 0. Otherwise -1 is > >> returned. > > That's how POSIX-2001 defines it. > > So yeah, using abs() to "catch" the invalid case is fine, but could be > refined even more.
I don't follow your logic here. Glibc currently yelds incorrect result for a set of valid Unicode 7.0 codepoints that were invalid previously. This time they are 1 column width (I didn't verify that, so don't take my word for it), but in future wide characters may be added as well, and wcwidth() will return -1 for them as well, so the "abs()" hack won't work. IMO ideally st should either not print characters whose codepoints are unknown to libc, or should silently replace them with U+FFFD. At any rate, assumptions about codepoints' properties are not st's business. -- Dmitrij D. Czarkoff