From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Matching regex case-sensitively in C strings? Date: Mon, 7 Nov 2022 12:35:24 -0800 Message-ID: References: <218795BA-107D-4A86-9ACF-0A44BD2EC3D2@gmail.com> <83edufyoad.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37731"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 07 21:36:30 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 1os8r8-0009aO-53 for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Nov 2022 21:36:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1os8qG-0005wM-78; Mon, 07 Nov 2022 15:35:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1os8qA-0005vt-1q for emacs-devel@gnu.org; Mon, 07 Nov 2022 15:35:33 -0500 Original-Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1os8q8-0002AZ-FN; Mon, 07 Nov 2022 15:35:29 -0500 Original-Received: by mail-pj1-x1035.google.com with SMTP id v4-20020a17090a088400b00212cb0ed97eso11354412pjc.5; Mon, 07 Nov 2022 12:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JHheHqZSy+Jas4O3BcDU1cNHkOHgyMLf5jWVn+VgReg=; b=SQSK8pu1Xeek0sNX1uEqEzhrWS2uXINhclDMKUokdr4QjegUJrBJe2/4nR3Qh8SPbd gQ1xTfieup8Ed6EPDVz04yv5bi/vlfj7jod6EOXowZZ5pwUW89zSzhZl7ntzWUubjBEV Z4q+bml+IfE/q7lOoUG7X5/c2dycHc4jyN7evJV/z8UtJEyWlVTlxtg3u8FP86jEcNR+ ge4UvverdTXt1u3xFJVmlLgv3ESksZxmcEhfDFoxov70YkcWqpDHqcHeXh8IanZOIiyv sD7ysUPeVsZJ6xVGs2TI6j2xTY1j6Gvi6IsfVXytNqZLJKJdN0/oW8Z/PmN5rg/B3qym laPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JHheHqZSy+Jas4O3BcDU1cNHkOHgyMLf5jWVn+VgReg=; b=2MmyR1IQ0373hmRqD72zIZLBjpiEPN4258KuE7EJABVeMgQ+9qV2uzYC54YKcJp9Z8 jJTbfygdlFct+z58w7OjfufJNYKDoARxuYTjJxBuPxGtcx+qt+0n+UhaYs2uoeAwxI/J czkRp5HyODJ+H8fUgL5n64tDzbj6bguuhpBOnh3psAkZHVrVEI8l3H+4RisvCQkWuqFD c+5V8Bn4vTkDtFM56Bvg2YmWaV/iaPLjBa9ePoUNw26bUZt4rnHQSuT/Ckcnv0XASFrW nWqTwau72DHV2HqGvN3C1VV5tq29rkB+mzUAwlxAozjDupBPeljBUK1g/Xd3prWqG8NU cB6A== X-Gm-Message-State: ACrzQf3P4j4NLcYpC9zT90PX2Hd5wVEbwZkAVAaTG93V7oBu1cZi2Yp+ 8xQhue+KEeJo8G/E2LwWLDtT/opdsOI= X-Google-Smtp-Source: AMsMyM5o7ceH2OvPp7IFKuU7zMpmtqiIrtWwqyNQ50yxuQUcuOzWDkcn7b6HfHU9GbDLIl6PJv2Hgg== X-Received: by 2002:a17:902:e850:b0:17d:c0e3:fde with SMTP id t16-20020a170902e85000b0017dc0e30fdemr901885plg.29.1667853326086; Mon, 07 Nov 2022 12:35:26 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id t11-20020a170902e84b00b00186c41bd213sm5385671plg.177.2022.11.07.12.35.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2022 12:35:25 -0800 (PST) In-Reply-To: <83edufyoad.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=casouri@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299304 Archived-At: > On Nov 7, 2022, at 3:52 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sun, 6 Nov 2022 21:41:42 -0800 >>=20 >> Is there a function that matches regex case-sensitively in a C = string? Ie, something like fast_c_string_match_ignore_case but = case-sensitive. >=20 > I don't think so, but it should be trivial to add such a function if > you need it. Cool, I need some help understanding fast_c_string_match_ignore_case: ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string, ptrdiff_t len) { regexp =3D string_make_unibyte (regexp); // Why do we need to unwind stack? specpdl_ref count =3D SPECPDL_INDEX (); struct regexp_cache *cache_entry =3D compile_pattern (regexp, 0, Vascii_canon_table, 0, 0); // What does freezing a pattern do? freeze_pattern (cache_entry); // What is re_match_object for? I see that it can be t, nil or a = string. re_match_object =3D Qt; //=20 ptrdiff_t val =3D re_search (&cache_entry->buf, string, len, 0, len, = 0); unbind_to (count, Qnil); return val; } Yuan=