Auteur: Sebastian Gottschalk Date: À: pcre-dev Sujet: Re: [pcre-dev] bugs in PCRE
Philip Hazel wrote:
> On Sat, 8 Mar 2008, Craig Silverstein wrote:
>
>> This isn't C++ actually; it's the normal C isspace() etc. I don't
>> understand what you mean about these functions "requiring" an unsigned
>> char. As you note, their signature takes an int. Passing a signed
>> char to these functions is just fine: any number that would be
>> interpreted as negative (that is, ascii >= 128) will have isspace()
>> and isdigit() return false, which is what we want.
>
> Thinking about it, I suspect the reason they are defined with int
> arguments is so that a char argument (which is what they are commonly
> called with) is OK in both "char-is-signed" and "char-is-unsigned"
> environments.
I suspect the reason is performance. Since read() returns int for signaling
chars and the EOF symbol, you can pass these integers directly to isXXX().
And because the function is not required to validate its input, passing
anything else than 0-255 might result in wrong behaviour.