all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#34100: 26.1; Incomplete ? and ?? handling in rx
@ 2019-01-16 11:39 Mattias Engdegård
  2019-01-16 14:06 ` bug#34100: rx \? and \??: patch Mattias Engdegård
       [not found] ` <handler.34100.B.154763885119611.ack@debbugs.gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Mattias Engdegård @ 2019-01-16 11:39 UTC (permalink / raw)
  To: 34100

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)) "*")







^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-01  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-16 11:39 bug#34100: 26.1; Incomplete ? and ?? handling in rx Mattias Engdegård
2019-01-16 14:06 ` bug#34100: rx \? and \??: patch Mattias Engdegård
     [not found] ` <handler.34100.B.154763885119611.ack@debbugs.gnu.org>
2019-01-25 10:09   ` bug#34100: Acknowledgement (26.1; Incomplete ? and ?? handling in rx) Mattias Engdegård
2019-01-28 15:53     ` Michael Heerdegen
2019-02-01  9:44       ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.