From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#64128: regexp parser zero-width assertion bugs Date: Mon, 19 Jun 2023 12:21:50 -0700 Organization: UCLA Computer Science Department Message-ID: <687a312e-3d1d-edd8-039d-f1cac98caaa6@cs.ucla.edu> References: <4A303177-384E-4FEF-98F2-FAB89A12ACC9@gmail.com> <83pm5tpdy2.fsf@gnu.org> <6AA06366-E276-47EA-96A3-506DA8B17D41@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24726"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: Eli Zaretskii , 64128@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 19 21:22:29 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qBKSK-00067T-RN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Jun 2023 21:22:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBKRw-0000Op-60; Mon, 19 Jun 2023 15:22:04 -0400 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 1qBKRu-0000OS-Ps for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 15:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBKRu-0001Jr-EY for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 15:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qBKRt-0000zF-RF for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 15:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2023 19:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64128 X-GNU-PR-Package: emacs Original-Received: via spool by 64128-submit@debbugs.gnu.org id=B64128.16872025183784 (code B ref 64128); Mon, 19 Jun 2023 19:22:01 +0000 Original-Received: (at 64128) by debbugs.gnu.org; 19 Jun 2023 19:21:58 +0000 Original-Received: from localhost ([127.0.0.1]:57320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBKRq-0000yy-Cu for submit@debbugs.gnu.org; Mon, 19 Jun 2023 15:21:58 -0400 Original-Received: from mail.cs.ucla.edu ([131.179.128.66]:54670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBKRo-0000yk-Kw for 64128@debbugs.gnu.org; Mon, 19 Jun 2023 15:21:57 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 2043C3C09FB41; Mon, 19 Jun 2023 12:21:51 -0700 (PDT) Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wm3MuimmvdyN; Mon, 19 Jun 2023 12:21:50 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id CE5793C09FB43; Mon, 19 Jun 2023 12:21:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu CE5793C09FB43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1687202510; bh=x5xsnWMnSSOtpgaJ7HDFaTpVSWx07Mu0Vb4fwZiBdNE=; h=Message-ID:Date:MIME-Version:To:From; b=bqUmJA3D95rfkuZZJLFuk8HUVAf/vmR0Z7eH0qj2s2zv1PLQbB1INRF25iw2NohZC 6TAAzsDhZ5+ArQ7KYP7XzgM8X0nlnv/Q5Nk5fjYEL6Saj50di94yz+0KnNCrAbMt+S NEWdWFzFy2RhpQN6eKA7Vz1B2gSo4C58i0jl/686mjpZvh+C9AS4kB9+mS4YxY5HKD NuIbyTMnsmi0cXzlTmFrMGiStrDlM4EM6dwtM5Q4eMUfR/SiuKU9zRMaYHI5u55TSB XrBPAGAU0HdnBfwBQw3FV6GsroakaBdCaWTBqxzXg4Ju4F7y6CT5Y4WcFRUmmY+5/B RlvcKqoRDnCTg== X-Virus-Scanned: amavisd-new at mail.cs.ucla.edu Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z7r1ypVQNQWc; Mon, 19 Jun 2023 12:21:50 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id A590E3C09FB41; Mon, 19 Jun 2023 12:21:50 -0700 (PDT) Content-Language: en-US In-Reply-To: <6AA06366-E276-47EA-96A3-506DA8B17D41@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263712 Archived-At: On 2023-06-19 11:34, Mattias Engdeg=C3=A5rd wrote: > Here is a reduced patch that only fixes the really silly behaviour repo= rted earlier, by making sure that `laststart` is reset correctly for all = group A assertions. This should be uncontroversial. > Maybe we should change group B assertions so that they work in the same= way. > - operand. Reset at the beginning of groups and alternatives. */ > + operand. Reset at the beginning of groups and alternatives, > + and after zero-width assertions which should not be the target > + of any postfix repetition operators. */ If I understand things correctly, this would cause "\b*c" to be treated=20 like "\b\*c". If so, it's headed in the wrong direction. It's long been documented that the only reason "*" is ordinary at the=20 start of a regular expression or subexpression is "historical=20 compatibility", and it's also long been documented that you shouldn't=20 take advantage of this and you should backslash-escape the "*" anyway.=20 In contrast, for constructs like \b* there is not a historical=20 compatibility reason, so there's not a good argument for treating "*" as=20 an ordinary character after "\b". Instead, \b should not be a special case before "*", and \b* should be=20 equivalent to \(\b\)* and should match only the empty string. Similarly=20 for the other zero-width backslash escapes. This is what I would expect=20 from these constructs from the longstanding documentation. If we instead added a rule to say that a construct that can only match=20 the empty string causes following "*" to ordinary, then \b* and \(\b\)*=20 would both be equivalent to \*. Although consistent, this would be=20 confusing: it would compound the historical-compatibility mistake. Let's=20 keep things simple instead. Also, whatever change we make to the behavior should be documented in=20 the manual and in etc/NEWS.