From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dmta0013.nifty.com (mta-snd00003.nifty.com [106.153.226.35]) by sourceware.org (Postfix) with ESMTPS id C60BC3858292 for ; Wed, 3 Jan 2024 06:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C60BC3858292 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C60BC3858292 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=106.153.226.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704265125; cv=none; b=WCCvQNg8541O2PlDvo1b2boPoOEWu2fPyUU/pQsGFYwkw0JQI5WXcJI4FL8uLdFGTuMzLAtY5cnd6E0NJRDeygrseoeYZBxVxK7GF74ZJ/JtS/CIFopVWqonXyuG/qB6/GNoa1lP9MmpcOo6LHadD2/QAMg2iBQkMYjh8NfoWGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704265125; c=relaxed/simple; bh=T3C582HLA/AfYQdVjyI10Y6osilsZUotqWQR808JCI8=; h=Date:From:To:Subject:Message-Id:Mime-Version; b=o/JwgCxv7Czz8VPUFoA0rJbhqYGpJJETqtVmrMIFS5S1RSaD+7bTF6/vJEXEsDqkqftlYb76u+uLQCHg7AkaOwF2YXpqCgxcuFl3JmDuqIYSDZQ+NJ3nULnUw66dnh1NhpF0m4VPLXzaccUJh8gGTTkBKO8/vrrTavHFApHeoPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from HP-Z230 by dmta0013.nifty.com with ESMTP id <20240103065839544.UODL.43072.HP-Z230@nifty.com> for ; Wed, 3 Jan 2024 15:58:39 +0900 Date: Wed, 3 Jan 2024 15:58:39 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Possibly buggy use of ctype.h macros. Message-Id: <20240103155839.ecb5eddf00ccab39c882fe61@nifty.ne.jp> In-Reply-To: <382d26d43e66b45eca9facdd8bb9063d@kylheku.com> References: <20240103082556.8ba92d98e1023f6e6fb175e2@nifty.ne.jp> <5d6e0d9bbeef1d4184b6067845d1e5a5@kylheku.com> <20240103091124.7b4b9e2f7a896c0c2fe416ab@nifty.ne.jp> <382d26d43e66b45eca9facdd8bb9063d@kylheku.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 02 Jan 2024 19:59:57 -0800 Kaz Kylheku 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