bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] mbrlen, mbrtowc: fix bug with empty input


From: Pádraig Brady
Subject: Re: [PATCH] mbrlen, mbrtowc: fix bug with empty input
Date: Sun, 18 May 2014 12:22:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 05/17/2014 01:23 AM, Paul Eggert wrote:
> Pádraig Brady wrote:
>> To me, mbrtowc returning 0 for empty input is not surprising.
>> Also POSIX says for mbr{len,towc} that they shall return 0
>> "If the next n or fewer bytes complete the character that corresponds to the 
>> null wide character
> 
> At least 1 byte is needed to represent a null wide character. Therefore, zero 
> bytes cannot possibly complete a null wide character, which means mbrtowc on 
> empty input cannot return 0 if it wants to conform to POSIX and/or C11.
> 
> A similar argument shows why mbrtowc can't return (size_t) -1 on empty input: 
> it's because you need at least 1 byte to represent an encoding error.

Ah I saw the empty _string_ "" in the test case and got confused.
This is only for the empty _input_ case (n==0). So all good :)

thanks,
Pádraig.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]