From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: case-insensitive string comparison Date: Tue, 19 Jul 2022 18:47:14 -0400 Message-ID: References: <87ilnsq4cr.fsf@gnu.org> Reply-To: sds@gnu.org Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6188"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) To: emacs-devel@gnu.org, Roland Winkler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 20 00:48:18 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDw0n-0001OV-Oa for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Jul 2022 00:48:17 +0200 Original-Received: from localhost ([::1]:48136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDw0m-0005TZ-1r for ged-emacs-devel@m.gmane-mx.org; Tue, 19 Jul 2022 18:48:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDvzx-0004hD-Jr for emacs-devel@gnu.org; Tue, 19 Jul 2022 18:47:25 -0400 Original-Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:33345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDvzv-000576-He; Tue, 19 Jul 2022 18:47:25 -0400 Original-Received: by mail-qk1-x72a.google.com with SMTP id f14so12502657qkm.0; Tue, 19 Jul 2022 15:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:in-reply-to:references:user-agent :return-receipt-to:reply-to:mail-followup-to:date:message-id :mime-version; bh=W6DmYOFeBg1wmJp3T/gTh5Dhnq017a+TiDuo2Xic4xw=; b=XVyKXGBWG51PebRLnQr5RKsHWlCRIg8XsiJUIgPWm12Y93hZFli35OG2mx196ahKFz mwm6MPmi9s61v5tj1OHzroMJ6zplAipG1yjlAO4gktMaiCuUZiFRM3D7j0zxm9eatY5e t/CuXLshhe29KXFgrvE4IgOY0R891X7cqg6tVUz+SecYagLNqMCY+olHUiTPM29odfZb epjb9UMBH1lPBUN28/nnsaCSbdJNbRmDj+mn0RTRfxh38397ctr/U0xp6i1F8exxzwlN wgD1oG3rCUz8eWlp6zcWTdUMaGavPnk7yAda47lgbGb4yIXO8VkPrJvi8LQgkigdL+ko WOFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:in-reply-to:references :user-agent:return-receipt-to:reply-to:mail-followup-to:date :message-id:mime-version; bh=W6DmYOFeBg1wmJp3T/gTh5Dhnq017a+TiDuo2Xic4xw=; b=LYhDckVAJlHNQHVs0AGc1J8drRsE48tRhIdV1uCRdbYnLbBjyz4ClBxUBSKBRTm2Yq GaExoGQ2o/39uO8YO1++Pzzvept95rdK8IbTw2wCBE/1iBgGtK7n397FdkstD6rw6kpD CUAGl8pnBfBZ4QvlFJ9iE8iP9k0ZJDwyJKz7FqR/kGTMs6PmzKcqRzp2cwYIJbmGDGxW dYfvq7H0r7WHRjdh3kMD6f0QFJF1fovMLJGVpyMLIQRAEkZrM6qNpF28m5bhspoC0Ry6 nayrgWRjkPH5VFiyT4xbHkcBqNObezD1OKIeCwOYEvzp1LduoYWfUw0+2TEBcsLlXKrp cMRQ== X-Gm-Message-State: AJIora8VDNIxOq/TtjiVEXrBe1z1RRhxtiiwPX84yROw8L8gjrwhfdEN 3MUwvd843na/lZAuX5CZ88NTSOe2Sg== X-Google-Smtp-Source: AGRyM1slpV4PlDvUYFgh2eNm7dLKAPpEgwb+OrkdbWmD6e1g3fOo6YUNRC5iOEEVLEiW55b/ZN1Q6A== X-Received: by 2002:a05:620a:2809:b0:6a9:9088:f251 with SMTP id f9-20020a05620a280900b006a99088f251mr22427282qkp.653.1658270836268; Tue, 19 Jul 2022 15:47:16 -0700 (PDT) Original-Received: from 3c22fb11fdab.ant.amazon.com (pool-108-30-23-113.nycmny.fios.verizon.net. [108.30.23.113]) by smtp.gmail.com with ESMTPSA id bk34-20020a05620a1a2200b006af1f0af045sm14640014qkb.107.2022.07.19.15.47.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jul 2022 15:47:14 -0700 (PDT) In-Reply-To: <87ilnsq4cr.fsf@gnu.org> (Roland Winkler's message of "Tue, 19 Jul 2022 14:39:32 -0500") X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Followup-To: emacs-devel@gnu.org, Roland Winkler Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=sam.steingold@gmail.com; helo=mail-qk1-x72a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292296 Archived-At: > * Roland Winkler [2022-07-19 14:39:32 -0500]: > > On Tue, Jul 19 2022, Sam Steingold wrote: >> Specifically, I would like to add >> >> (defun string-equal-ignore-case (s1 s2) >> "Like `string-equal', but case-insensitive. >> Upper-case and lower-case letters are treated as equal. >> Unibyte strings are converted to multibyte for comparison." >> (eq t (compare-strings s1 0 nil s2 0 nil t))) >> >> to subr.el next to `string-prefix-p' - is this okay? > > I have run into this problem fairly often that I needed case-insensitive > string comparison, and I believe various elisp packages include a > "private" version of the above. I always felt that > `(eq t (compare-strings s1 0 nil s2 0 nil t))' was a crutch for this > common problem. Would it make sense to give the built-in function > string-equal an optional arg ignore-case? No, because I need to be able to pass `string-equal-ignore-case' to things like `cl-find' as `:test' &c. Also, if you look at fns.c, `string-equal' is basically `memcmp', while `compare-strings' is way more complex. PS. Actually, compare-strings/ignore_case is broken because it does, essentially, upcase both arguments, see https://stackoverflow.com/q/319426/850781 -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com https://memri.org https://www.dhimmitude.org http://think-israel.org A poet who reads his verse in public may have other nasty habits.