Bill,

Neither the C standard nor POSIX require anything other than values from -1 
(EOF) to 255 to work.  Since we are dealing with char strings we are not going 
to see an EOF except in the case where a character has the value 255 but is 
interpreted as a signed value (which is allowed).  Thus, masking with 255 is 
both safe and necessary for cross-platform code...

On Dec 9, 2011, at 12:02 PM, Bill Spitzak wrote:

> Sorry I misinterpreted the 255 as being 127.
> 
> That said, correct isdigit() implementations are supposed to handle the 
> native compiler char->int conversion of the argument. This masking can 
> make the -1 EOF match the 255 character and thus is really incorrect.
> 
> On 12/07/2011 09:25 PM, Michael Sweet wrote:
>> Bill,
>> 
>> A digit is just 0 to 9, per the definition of isdigit.  Masking off the sign 
>> extension of the char value will just keep the values from 0 to 255 - UTF-8 
>> sequences will have bit 7 set which will prevent isdigit from matching.
>> 
>> 
>> On Dec 7, 2011, at 11:09 PM, Bill Spitzak wrote:
>>> On 10/18/2011 11:43 AM, Michael Sweet wrote:
>>>> In this case I would not use strtol to skip digits, but a simple while 
>>>> loop instead:
>>>> 
>>>>     while (isdigit(*str&   255))
>>>>       str ++;
>>>> 
>>>> (the "&   255" part is necessary to avoid portability issues with UTF-8 
>>>> strings)
>>> 
>>> That seems wrong. That will actually turn some parts of UTF-8 characters
>>> into digits and thus match. You actually do not want to change the
>>> bytes, all the bytes in a multi-byte UTF-8 character will fail the
>>> isdigit() test and thus this will stop at that point.
>>> 
>>> _______________________________________________
>>> fltk-dev mailing list
>>> [email protected]
>>> http://lists.easysw.com/mailman/listinfo/fltk-dev
>> 
>> _____________
>> Michael Sweet
>> 
> 
> _______________________________________________
> fltk-dev mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk-dev

_____________
Michael Sweet

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to