On Tue, 02 Jan 2024 19:59:57 -0800 Kaz Kylheku <k...@kylheku.com> wrote: > On 2024-01-02 16:11, Takashi Yano via Cygwin wrote: > > Perhaps, the off-by-one is for EOF as you guess. > > I doubt it. If EOF were out of range of char, it would have to be -129 or > less, > so that -127 would look even more wrong. > > I see EOF is just -1. That value will also be produced by '\xFF', or > "\xff"[0], etc.
In systems other than cygwin, ALLOW_NEGATIVE_CTYPE_INDEX might not be set. In that case, 124 const char _ctype_[1 + 256] = { 125 0, 126 _CTYPE_DATA_0_127, 127 _CTYPE_DATA_128_255 128 }; is used for __CTYPE_PTR. So, isalpha(EOF) reffers to 0 in line 125 via this trick. 45 int 46 isalpha (int c) 47 { 48 return(__CTYPE_PTR[c+1] & (_U|_L)); 49 } In cygwin, both isalpha((char*)0xff) and isalpha(EOF) reffers to _CTYPE_DATA_128_255[127] in line 89, while isalpha((unsigned char*)0xff) reffers to _CTYPE_DATA_128_255[127] in line 91. 88 char _ctype_b[128 + 256] = { 89 _CTYPE_DATA_128_255, 90 _CTYPE_DATA_0_127, 91 _CTYPE_DATA_128_255 92 }; -- Takashi Yano <takashi.y...@nifty.ne.jp> -- 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