On 2024-01-02 15:25, Takashi Yano via Cygwin wrote:
> On Tue, 02 Jan 2024 14:18:15 -0800
> Kaz Kylheku via Cygwin <cygwin@cygwin.com> wrote:
>> I noticed that this macro, defined in winsup/cygwin/local_includes/path.h:
>>
>>   #define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
>>
>> is being used with arguments of type char, like dereferenced "char *" 
>> pointers.
>>
>> Unless the isalpha implementation is robust against this, it should be 
>> isalpha((unsigned char) *(s)).
> 
> 
> https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/ctype/ctype_.h;h=a73870b3e4ade5545fd41bcc6f10446a22b4b46e;hb=HEAD

I see, so on Cygwin, the negative index is allowed, thanks to a displacement.

# define DEFAULT_CTYPE_PTR      ((char *) _ctype_b + 127)

But, 127? A (signed) char can go to -128. '\x80' will access _ctype_b[-1]. Is 
that also somehow OK?

(Tangential remark: all ctype implementations have to handle at least one 
negative value, namely EOF.)


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to