DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51HA1aU72871934 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 51HA1aU72871934 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=S58KylIA X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B761B3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1739786494; bh=tTn3BW3yNHHqeG6U89xURriepY/w13+e7HJlSSD1txg=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=S58KylIAN7Pib3L2x7DanSPy+YUVRencukkQ+dcJ3XoLh2gRV/GI4GxnA4qVX/4A0 MbgDrUXjsRQAUUBB5ypnAbZJMkAois24NDZ9i0cbBzdvbwmG+zyHirs5HEeqHRNTYn F/Wkx4mqVKaFCFweIAHiprMHA/mJQ1DW6JJNII7I= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46C2E3858D1E Date: Mon, 17 Feb 2025 11:00:29 +0100 To: Bruno Haible Subject: Re: bug in strcasecmp and strncasecmp Message-ID: Mail-Followup-To: Bruno Haible , cygwin AT cygwin DOT com References: <2031387 DOT 2IRrRt1zHL AT nimes> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2031387.2IRrRt1zHL@nimes> 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: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen , cygwin AT cygwin DOT com 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" Hi Bruno, On Feb 16 17:18, Bruno Haible via Cygwin wrote: > Per POSIX [1], the functions strcasecmp and strncasecmp should > "use the current locale to determine the case of the characters.". > > [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/strcasecmp.html > > This is not what Cygwin does: In the fr_FR.ISO8859-1 locale, the > characters 0xE9 and 0xC9 are the same modulo case, but strcasecmp > and strncasecmp consider these characters to be different. Thanks for your report. This is a longstanding problem in newlib. All four strcasecmp functions call tolower on a char without casting them to unsigned. So tolower is called with negativ values if the char is not in the ASCII range. Adding a cast fixes that and I just pushed a matching patch. I'm just not sure if that's sufficient in the light of POSIX.1-2024. The above expression seems to indicate that strcasecmp and friends are now expected to work on multibyte codesets like UTF-8. I checked the glibc sources and they still do the bytewise tolower twist as well, though... Thanks, Corinna -- 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