branch: externals/xr commit ccc76c8c0b836bbf26b94edfd33d5bb3e8e2a021 Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
More careful character class parsing [[:random rubbish:]] is an error, not a valid regexp. --- xr-test.el | 11 +++++++++++ xr.el | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/xr-test.el b/xr-test.el index 4a24ef3..d4e2d48 100644 --- a/xr-test.el +++ b/xr-test.el @@ -176,6 +176,17 @@ '(not (any "A-FI-Ma-eg-ns-t" "G")))) (should (equal (xr "[z-a][^z-a]") '(seq (any) anything))) + (should (equal (xr "[[:alpha]]") + '(seq (any ":[ahlp") "]"))) + (should (equal (xr "[:alpha:]") + '(any ":ahlp"))) + (should (equal (xr "[[:digit:]-z]") + '(any "z-" digit))) + (should (equal (xr "[A-[:digit:]]") + '(seq (any "A-[" ":dgit") "]"))) + (should-error (xr "[[::]]")) + (should-error (xr "[[:=:]]")) + (should-error (xr "[[:letter:]]")) ) (ert-deftest xr-empty () diff --git a/xr.el b/xr.el index 9db27b3..1fd9324 100644 --- a/xr.el +++ b/xr.el @@ -97,13 +97,13 @@ (while (not (looking-at "]")) (cond ;; character class - ((looking-at (rx "[:" (group (one-or-more letter)) ":]")) + ((looking-at (rx "[:" (group (*? anything)) ":]")) (let ((sym (intern (match-string 1)))) - (when (not (memq sym - '(ascii alnum alpha blank cntrl digit graph - lower multibyte nonascii print punct space - unibyte upper word xdigit))) - (error "No character class `%s'" sym)) + (unless (memq sym + '(ascii alnum alpha blank cntrl digit graph + lower multibyte nonascii print punct space + unibyte upper word xdigit)) + (error "No character class `%s'" (match-string 0))) (if (memq sym classes) (xr--report warnings (point) (format "Duplicated character class `[:%s:]'" sym))