www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/02/17/05:01:37

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 <bruno AT clisp DOT org>
Subject: Re: bug in strcasecmp and strncasecmp
Message-ID: <Z7MIvRl6XKQ0Ky0m@calimero.vinschen.de>
Mail-Followup-To: Bruno Haible <bruno AT clisp DOT org>, cygwin AT cygwin DOT com
References: <2031387 DOT 2IRrRt1zHL AT nimes>
MIME-Version: 1.0
In-Reply-To: <2031387.2IRrRt1zHL@nimes>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>, cygwin AT cygwin DOT com
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019