emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9233865: Fix (rx-to-string (and (literal STR) (rege


From: Noam Postavsky
Subject: [Emacs-diffs] master 9233865: Fix (rx-to-string (and (literal STR) (regexp STR)) regression
Date: Wed, 26 Jun 2019 08:53:15 -0400 (EDT)

branch: master
commit 9233865b7005831e63755eb84ae7da060f878a55
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Fix (rx-to-string (and (literal STR) (regexp STR)) regression
    
    * lisp/emacs-lisp/rx.el (rx-regexp, rx-literal): Check the cadr of the
    form for stringness, not the form itself.
    * test/lisp/emacs-lisp/rx-tests.el (rx-to-string-lisp-forms): New test.
---
 lisp/emacs-lisp/rx.el            | 4 ++--
 test/lisp/emacs-lisp/rx-tests.el | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 1b5afe7..24dd6cb 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -874,7 +874,7 @@ If FORM is `(minimal-match FORM1)', non-greedy versions of 
`*',
 
 (defun rx-regexp (form)
   "Parse and produce code from FORM, which is `(regexp STRING)'."
-  (cond ((stringp form)
+  (cond ((stringp (cadr form))
          (rx-group-if (cadr form) rx-parent))
         (rx--compile-to-lisp
          ;; Always group non-string forms, since we can't be sure they
@@ -884,7 +884,7 @@ If FORM is `(minimal-match FORM1)', non-greedy versions of 
`*',
 
 (defun rx-literal (form)
   "Parse and produce code from FORM, which is `(literal STRING-EXP)'."
-  (cond ((stringp form)
+  (cond ((stringp (cadr form))
          ;; This is allowed, but makes little sense, you could just
          ;; use STRING directly.
          (rx-group-if (regexp-quote (cadr form)) rx-parent))
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index bab71b5..8845ebf 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -156,5 +156,9 @@
     (rx-tests--match (rx "c" (minimal-match (0+ (regexp ad))) "a") "cdaaada" 
"cda")
     (rx-tests--match (rx "c" (maximal-match (0+ (regexp ad))) "a") "cdaaada" 
"cdaaada")))
 
+(ert-deftest rx-to-string-lisp-forms ()
+  (rx-tests--match (rx-to-string '(seq "a" (literal "b") "c")) "abc")
+  (rx-tests--match (rx-to-string '(seq "a" (regexp "b") "c")) "abc"))
+
 (provide 'rx-tests)
 ;; rx-tests.el ends here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]