Handle raw bytes, and LF in ranges, in rx `any' argument strings

* lisp/emacs-lisp/rx.el (rx-check-any-string): Rewrite to handle raw bytes
in unibyte strings and accept LF as range endpoints (Bug#33205).
* test/lisp/emacs-lisp/rx-tests.el: Add tests for the above.
This commit is contained in:
Mattias Engdegård 2018-12-29 11:09:27 +01:00 committed by Eli Zaretskii
parent fb10834a60
commit b71d4ce056
2 changed files with 51 additions and 22 deletions

View file

@ -33,6 +33,28 @@
(number-sequence ?< ?\])
(number-sequence ?- ?:))))))
(ert-deftest rx-char-any-range-nl ()
"Test character alternatives with LF as a range endpoint."
(should (equal (rx (any "\n-\r"))
"[\n-\r]"))
(should (equal (rx (any "\a-\n"))
"[\a-\n]")))
(ert-deftest rx-char-any-raw-byte ()
"Test raw bytes in character alternatives."
;; Separate raw characters.
(should (equal (string-match-p (rx (any "\326A\333B"))
"X\326\333")
1))
;; Range of raw characters, unibyte.
(should (equal (string-match-p (rx (any "\200-\377"))
"ÿA\310B")
2))
;; Range of raw characters, multibyte.
(should (equal (string-match-p (rx (any "Å\211\326-\377\177"))
"XY\355\177\327")
2)))
(ert-deftest rx-pcase ()
(should (equal (pcase "a 1 2 3 1 1 b"
((rx (let u (+ digit)) space