X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18AE0385828B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1704265187; bh=GKs5G/nh/7L6toIi0nwsDOAUyx0inDmJGxHnlsrmsVQ=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DzJ3GHKnBAOs/X7irMmDT3dGsl0v/4Cm4zgpOhqzNetRBpfyQCQkv+7fI36vYY3Od +thdlbIrqyJxwKVLw9zbPiTzNMDoevHwfJTo+XFi8c7jd3OlQtUWFP2NhoM79oNRx5 zaqXrwSLVst3WJ4yjE/FcFE8hItrRLo2TGFM8m/I= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C60BC3858292 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C60BC3858292 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 Date: Wed, 3 Jan 2024 15:58:39 +0900 To: cygwin AT cygwin DOT 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 DOT 8ba92d98e1023f6e6fb175e2 AT nifty DOT ne DOT jp> <5d6e0d9bbeef1d4184b6067845d1e5a5 AT kylheku DOT com> <20240103091124 DOT 7b4b9e2f7a896c0c2fe416ab AT nifty DOT ne DOT jp> <382d26d43e66b45eca9facdd8bb9063d AT kylheku DOT com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 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 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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 -- 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