Commit a6b59851 authored by Mattias Engdegård's avatar Mattias Engdegård

Avoid duplicated character classes in rx

For example, (any digit digit) should produce "[[:digit:]]",
not "[[:digit:][:digit:]]".

* lisp/emacs-lisp/rx.el (rx--translate-any): Deduplicate character classes.
* test/lisp/emacs-lisp/rx-tests.el (rx-any): Add test case.
parent a05bafff
Pipeline #4226 failed with stage
in 65 minutes and 18 seconds
......@@ -376,7 +376,9 @@ If NEGATED, negate the sense."
(push (cons arg arg) conses))
((and (symbolp arg)
(let ((class (cdr (assq arg rx--char-classes))))
(and class (push class classes)))))
(and class
(or (memq class classes)
(push class classes))))))
(t (error "Invalid rx `any' argument: %s" arg))))
(let ((items
;; Translate strings and conses into nonoverlapping intervals,
......@@ -128,7 +128,9 @@
(should (equal (rx (any) (not (any)))
(should (equal (rx (any "") (not (any "")))
(should (equal (rx (any space ?a digit space))
(ert-deftest rx-pcase ()
(should (equal (pcase "a 1 2 3 1 1 b"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment