From 40fb20061e6b9b2b22aeee5b7e9f038dc9ba843b Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Thu, 5 Mar 2020 12:10:51 +0100 Subject: * lisp/emacs-lisp/rx.el (rx--string-to-intervals): Fix error string. --- lisp/emacs-lisp/rx.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index a0b2444346a..d4a91710273 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -360,7 +360,7 @@ character X becomes (?X . ?X). Return the intervals in a list." (push (cons start end) intervals)) (t (error "Invalid rx `any' range: %s" - (substring str i 3)))) + (substring str i (+ i 3))))) (setq i (+ i 3)))) (t ;; Single character. -- cgit v1.2.3 From 1814c7e158685045278f991de5eba4e40e8c8199 Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Thu, 5 Mar 2020 12:49:26 +0100 Subject: Fix rx error with ? and ?? The ? and ?? rx operators are special in that they can be written as characters (space and '?' respectively). This confused the definition look-up mechanism in rare cases. * lisp/emacs-lisp/rx.el (rx--expand-def): Don't look up non-symbols. * test/lisp/emacs-lisp/rx-tests.el (rx-charset-or): Test. --- lisp/emacs-lisp/rx.el | 2 +- test/lisp/emacs-lisp/rx-tests.el | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index d4a91710273..aa4b2addd47 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -134,7 +134,7 @@ Each entry is: (if (cdr def) (error "Not an `rx' symbol definition: %s" form) (car def))))) - ((consp form) + ((and (consp form) (symbolp (car form))) (let* ((op (car form)) (def (rx--lookup-def op))) (and def diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 4888e1d9d1e..0fece4004bd 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -316,7 +316,9 @@ (should (equal (rx (not (or (in "abc") (char "bcd")))) "[^a-d]")) (should (equal (rx (or (not (in "abc")) (not (char "bcd")))) - "[^bc]"))) + "[^bc]")) + (should (equal (rx (or "x" (? "yz"))) + "x\\|\\(?:yz\\)?"))) (ert-deftest rx-def-in-charset-or () (rx-let ((a (any "badc")) -- cgit v1.2.3