On Mon, 27 Oct 2014 13:03:49 +0100
Marc André Tanner <mat_AT_brain-dump.org> wrote:
> POSIX states for int wcwidth(wchar_t wc): "... or return -1 (if wc
> does not correspond to a printable wide-character code)." Therefore
> I think a return value of -1 should be handled gracefully.
I have to agree here, even though I do not favor changing the code for
broken libraries, I have to quote wcwidth(3):
>> 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.
Cheers
FRIGN
--
FRIGN <dev_AT_frign.de>
Received on Mon Oct 27 2014 - 13:25:29 CET