emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/relint e11b871 12/23: More robust scanning of format st


From: Mattias Engdegård
Subject: [elpa] externals/relint e11b871 12/23: More robust scanning of format strings for mixup check
Date: Sun, 29 Sep 2019 15:34:52 -0400 (EDT)

branch: externals/relint
commit e11b8715488f80758a7de838e7955e628d8218fc
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    More robust scanning of format strings for mixup check
---
 relint.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/relint.el b/relint.el
index 546c311..1c33c8d 100644
--- a/relint.el
+++ b/relint.el
@@ -974,22 +974,26 @@ parameter is regexp-generating."
         (start 0))
     (while (and (< index nargs)
                 (string-match (rx
-                                ;; An unescaped [, and some leading chars
-                               (opt (or bos (not (any "\\")))
-                                    (0+ "\\\\")
-                                    (group "[")
-                                    (0+ (not (any "]"))))
-                               ;; Any %-sequence
                                "%"
                                (opt (1+ digit) "$")
                                (0+ digit)
                                (opt "." (0+ digit))
                                (group (any "%sdioxXefgcS")))
                               template start))
-      (let ((bracket (match-beginning 1))
-            (type (string-to-char (match-string 2 template)))
+      (let ((percent (match-beginning 0))
+            (type (string-to-char (match-string 1 template)))
             (next (match-end 0)))
-        (when (and bracket (eq type ?s))
+        (when (and (eq type ?s)
+                   ;; Find preceding `[' before %s
+                   (string-match-p
+                    (rx
+                     bos
+                     (* (or (not (any "\\" "["))
+                            (seq "\\" anything)))
+                     "["
+                     (* (not (any "]")))
+                     eos)
+                    (substring template start percent)))
           (let ((reg-gen (relint--regexp-generators (nth index args) nil)))
             (when reg-gen
               (relint--report



reply via email to

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