[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr f3b61ef 05/10: Fix false negative in empty string re
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/xr f3b61ef 05/10: Fix false negative in empty string repetition check |
Date: |
Sun, 3 May 2020 11:13:08 -0400 (EDT) |
branch: externals/xr
commit f3b61ef7450afd7726e509509f5b3042af23a051
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Fix false negative in empty string repetition check
We forgot to check for non-greedy inner repetitions.
---
xr-test.el | 14 ++++++++++----
xr.el | 4 ++--
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/xr-test.el b/xr-test.el
index 88e68f7..2724e0d 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -404,16 +404,22 @@
(xr-lint "[-A-Z][A-Z-][A-Z-a][^-A-Z][]-a][A-Z---.]")
'((16 .
"Literal `-' not first or last in character alternative"))))
- (should (equal
- (xr-lint "\\(?:a*b?\\)*\\(c\\|d\\|\\)+\\(^\\|e\\)*\\(?:\\)*")
- '((10 . "Repetition of expression matching an empty string")
- (21 . "Repetition of expression matching an empty string"))))
(should (equal (xr-lint "\\'*\\<?\\(?:$\\)+")
'((2 . "Repetition of zero-width assertion")
(5 . "Repetition of zero-width assertion")
(13 . "Repetition of zero-width assertion"))))
))
+(ert-deftest xr-lint-repetition-of-empty ()
+ (let ((text-quoting-style 'grave))
+ (should (equal
+ (xr-lint "\\(?:a*b?\\)*\\(c\\|d\\|\\)+\\(^\\|e\\)*\\(?:\\)*")
+ '((10 . "Repetition of expression matching an empty string")
+ (21 . "Repetition of expression matching an empty string"))))
+ (should (equal
+ (xr-lint "\\(?:a*?b??\\)+?")
+ '((12 . "Repetition of expression matching an empty string"))))))
+
(ert-deftest xr-lint-branch-subsumption ()
(let ((text-quoting-style 'grave))
(should (equal (xr-lint "a.cde*f?g\\|g\\|abcdefg")
diff --git a/xr.el b/xr.el
index 03b5f0a..eccbf3f 100644
--- a/xr.el
+++ b/xr.el
@@ -424,13 +424,13 @@ UPPER may be nil, meaning infinity."
(defun xr--matches-empty-p (rx)
"Whether RX can match the empty string regardless of context."
(pcase rx
- (`(,(or 'seq 'one-or-more 'group) . ,body)
+ (`(,(or 'seq 'one-or-more '+? 'group) . ,body)
(cl-every #'xr--matches-empty-p body))
(`(or . ,body)
(cl-some #'xr--matches-empty-p body))
(`(group-n ,_ . ,body)
(cl-every #'xr--matches-empty-p body))
- (`(,(or 'opt 'zero-or-more) . ,_)
+ (`(,(or 'opt 'zero-or-more ?? '*?) . ,_)
t)
(`(repeat ,from ,_ . ,body)
(or (= from 0)
- [elpa] externals/xr updated (434b300 -> 35dbbeb), Mattias Engdegård, 2020/05/03
- [elpa] externals/xr e5b51bf 01/10: Add wrapped subsumption in repeated forms, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr f3b61ef 05/10: Fix false negative in empty string repetition check,
Mattias Engdegård <=
- [elpa] externals/xr c98bb7b 03/10: Handle whitespace and word syntax subsumption in one place, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr c7e7557 07/10: Broaden anchor check to check more paths, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr d752aab 09/10: Use "option" instead of "repetition" in diagnostics for ? and ??, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr c6e12b7 04/10: Handle \w and \W in subsumption checks, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 21eab3c 06/10: Check for bol, eol and eos in conflict with other expressions, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 7160235 02/10: Refactor repetition subsumption check to avoid code duplication, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr d0b09e1 08/10: Add filename-specific checks, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 35dbbeb 10/10: Increment version to 1.19, Mattias Engdegård, 2020/05/03