DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51HN9jIZ3157930
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 51HN9jIZ3157930
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=fSckR09P
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 371363858C41
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1739830715;
	bh=fK328rjQJ7YARn16UA696GE34EQFma2ngDOELPQUD18=;
	h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=fSckR09PfJJRuFocA+K+iUZNHNZGqlwjaiyzDvfVV5+itAVwIyQocMni7iRnMSfnz
	 Civ8A+XCw/qqR2oJE3B8hn5iC68CHHXCY/iF8zpMee2zgSCIo4WrkQSPZCGOxZqJ09
	 t1Tg/6fxSzn3uq0feJfUyDz4pU1R5WHCYEdCIxGs=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 170023858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 170023858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739830643; cv=none;
 b=gv5VFHp+XY9OZtVXSu7Zx7xk1x3hsTCfvD8H/MHa/F8WU2Ps5I5kqAP2Xw2Z1R0Nh40o1b7D1lXF5v35BzOls3J6NNl85JZGbjPmGFt7oDvHm5sAz46cAMAtgQ0JxuX7SznMmB12c7jkjSeURz/nGxy3NGvq9srT/m8kpYaXNCI=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1739830643; c=relaxed/simple;
 bh=EN19PqlXcAOFCJzhZPIX8z9e9qXrenYB2+SJ2dxZncI=;
 h=Message-ID:Date:MIME-Version:From:Subject:To:DKIM-Signature;
 b=MI4vhsAAZHgVIVfmjwvZazFlUpXyvQHiGfCzChq1j0baxUT3ObGj6C8Subs7EqLSo9+IwQTeR7cH89rOkX4moNQeuy/sN2jO3RFrFD+qiK8YPFDsdC6J95svtpeypgeZ/RA33GOYoeNOv02yLfrzPKZjI7+jcQr636fjFfq7deA=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 170023858D20
Message-ID: <00aff5c7-c2ed-4e31-8f0d-3b4ed8f010c3@SystematicSW.ab.ca>
Date: Mon, 17 Feb 2025 15:17:19 -0700
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug in strcasecmp and strncasecmp
To: cygwin@cygwin.com
References: <2031387.2IRrRt1zHL@nimes> <Z7MIvRl6XKQ0Ky0m@calimero.vinschen.de>
Content-Language: en-CA
Autocrypt: addr=Brian.Inglis@SystematicSW.ab.ca; keydata=
 xjMEXopx8xYJKwYBBAHaRw8BAQdAnCK0qv/xwUCCZQoA9BHRYpstERrspfT0NkUWQVuoePbN
 LkJyaWFuIEluZ2xpcyA8QnJpYW4uSW5nbGlzQFN5c3RlbWF0aWNTdy5hYi5jYT7ClgQTFggA
 PhYhBMM5/lbU970GBS2bZB62lxu92I8YBQJeinHzAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQW
 AgMBAh4BAheAAAoJEB62lxu92I8Y0ioBAI8xrggNxziAVmr+Xm6nnyjoujMqWcq3oEhlYGAO
 WacZAQDFtdDx2koSVSoOmfaOyRTbIWSf9/Cjai29060fsmdsDM44BF6KcfMSCisGAQQBl1UB
 BQEBB0Awv8kHI2PaEgViDqzbnoe8B9KMHoBZLS92HdC7ZPh8HQMBCAfCfgQYFggAJhYhBMM5
 /lbU970GBS2bZB62lxu92I8YBQJeinHzAhsMBQkJZgGAAAoJEB62lxu92I8YZwUBAJw/74rF
 IyaSsGI7ewCdCy88Lce/kdwX7zGwid+f8NZ3AQC/ezTFFi5obXnyMxZJN464nPXiggtT9gN5
 RSyTY8X+AQ==
Organization: Systematic Software
In-Reply-To: <Z7MIvRl6XKQ0Ky0m@calimero.vinschen.de>
X-Stat-Signature: 6bx14yjiphhz5amkgbm59tiqfgphimez
X-Rspamd-Server: rspamout02
X-Rspamd-Queue-Id: 3788720027
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX18nawOm4q/0UBJ2KpQFz0HTWUbK92tSZMY=
X-HE-Tag: 1739830640-623856
X-HE-Meta: U2FsdGVkX1+5yjHEx6FsfElPlIvaFJE0ET0VzpD6L5l+M0oezJIHcJuPldpPkwTGonn+3Kr25KbG4qBYouPm1vCnqhgE+Jwk+nyLp5hC4R77EuTQpgj3i5UbkYNOnua6YVBqiItpJKzjRwpmEuQtAEAo5IpEit/B6ERW11wWI2XjkW2/SgaTpVYfDUeKig4Tl+ptcTUv4g/PVKb3kinTAdlACmQ45P5O8A6AQ/FsCfpKu/3XqtND7dWNOwl1MftLzMEW4ZK9/rgaiwIWAHymLc0SDcPkVUzld4dzS3Wjb2d7ji9DQgnsD78feK985TsBFhPJo2eCN5vuVC+l3PXgzOPnislswTXiEdd+3VBY1NWn3QdSVTNvanxFncZWEtWcyCO3Yqg4wvNFgOOgMc8zdIGRwLRe90rROgSzi8q4RrbQzxyZtP5RmA==
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 51HN9jIZ3157930

On 2025-02-17 03:00, Corinna Vinschen via Cygwin wrote:
> 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...

Seems like one need only do that in the POSIX (2024) locale:

"When the LC_CTYPE category of the locale being used is from the POSIX locale, 
these functions shall behave as if the strings had been converted to lowercase 
and then a byte comparison performed, and errno shall not be changed on valid 
input. Otherwise, the results are unspecified."

so an implementation is free to DTRT in human locales, as with say TZ.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

-- 
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

