Re: [dev] [PATCH] [st] Fix issues with wcwidth() returning -1 for

From: FRIGN <>
Date: Mon, 27 Oct 2014 13:25:29 +0100

On Mon, 27 Oct 2014 13:03:49 +0100
Marc André Tanner <> 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):

>> 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.



Received on Mon Oct 27 2014 - 13:25:29 CET

This archive was generated by hypermail 2.3.0 : Mon Oct 27 2014 - 13:36:08 CET