Subject: bug#34100: closed (Re: bug#34100: Acknowledgement (26.1; Incomplete ? and ?? handling in rx))

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 01 Feb 2019 09:45:02 +0000

Your bug report

#34100: 26.1; Incomplete ? and ?? handling in rx

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
34100: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34100
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#34100: Acknowledgement (26.1; Incomplete ? and ?? handling in rx)
From: Eli Zaretskii <[email-masked]>
To: [email-masked]
Cc: Michael Heerdegen <[email-masked]>, [email-masked]
Date: Fri, 01 Feb 2019 11:44:20 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Michael Heerdegen <[email-masked]>
> Date: Mon, 28 Jan 2019 16:53:28 +0100
> Cc: [email-masked]
> 
> Mattias Engdegård <[email-masked]> writes:
> 
> > Anything more I can do? I thought this one would be rather
> > straightforward.  I do understand that there are more pressing
> > matters.
> 
> I guess you just have to be patient until someone has a look.  That can
> sometimes take some time, there are a lot of open bug reports...
> 
> For me what you suggest looks like a good idea btw.

Sorry for the long delay, Mattias.  I've now pushed your changes to
the master branch, and I'm marking this bug done.

Thanks.

Subject: 26.1; Incomplete ? and ?? handling in rx
From: Mattias Engdegård <[email-masked]>
To: [email-masked]
Date: Wed, 16 Jan 2019 12:39:58 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

In rx, the ? and ?? operators can be written verbatim as ? and ?? (space and ? character), or by using symbols whose leading character needs to be escaped, \? and \?? respectively. The names come from Olin Shivers's SRE, but ? is not a special character in Scheme syntax, hence the character syntax hack.

However, the symbols only partially work:

(rx (\? "x") (\?? "y"))       --> "x?y?"  ; expected "x?y??"
(rx (minimal-match (\? "x"))) --> "x??"   ; expected "x?"

While it could be argued that only the character-based syntax should be used, the fact is that the symbols are accepted and seem to work, just in a subtly broken way.

The documentation is also not clear on this point, and a programmer knowing the elisp syntax might very well assume that the symbols are the ones to use.

Suggested fix:

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index a39fe55c32..8b4551d0d3 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -733,8 +733,8 @@
 is non-nil."
   (rx-check form)
   (setq form (rx-trans-forms form))
-  (let ((suffix (cond ((memq (car form) '(* + ?\s)) "")
-		      ((memq (car form) '(*? +? ??)) "?")
+  (let ((suffix (cond ((memq (car form) '(* + \? ?\s)) "")
+		      ((memq (car form) '(*? +? \?? ??)) "?")
 		      (rx-greedy-flag "")
 		      (t "?")))
 	(op (cond ((memq (car form) '(* *? 0+ zero-or-more)) "*")