branch: scratch/editorconfig-cc
commit f0abc53ff0a8dfae8f8632051d8c6072d82c9bf7
Author: 10sr <8slashes+...@gmail.com>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Fix fnmatch for new cases
---
 editorconfig-fnmatch.el | 50 ++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/editorconfig-fnmatch.el b/editorconfig-fnmatch.el
index 257c2773b8..1d3bb12517 100644
--- a/editorconfig-fnmatch.el
+++ b/editorconfig-fnmatch.el
@@ -190,29 +190,33 @@ translation is found for PATTERN."
           (?\[
            (if in-brackets
                (setq result `(,@result "\\["))
-             (setq pos index
-                   has-slash nil)
-             (while (and (< pos length)
-                         (not (= (aref pattern pos) ?\]))
-                         (not has-slash))
-               (if (and (= (aref pattern pos) ?/)
-                        (not (= (aref pattern (- pos 1)) ?\\)))
-                   (setq has-slash t)
-                 (setq pos (1+ pos))))
-             (if has-slash
-                 (setq result `(,@result ,(concat "\\["
-                                                  (substring pattern
-                                                             index
-                                                             (1+ pos))
-                                                  "\\]"))
-                       index (+ pos 2))
-               (if (and (< index length)
-                        (memq (aref pattern index)
-                              '(?! ?^)))
-                   (setq index (1+ index)
-                         result `(,@result "[^"))
-                 (setq result `(,@result "[")))
-               (setq in-brackets t))))
+             (if (= (aref pattern index) ?/)
+                 ;; Slash after an half-open bracket
+                 (setq result `(,@result "\\[/")
+                       index (+ index 1))
+               (setq pos index
+                     has-slash nil)
+               (while (and (< pos length)
+                           (not (= (aref pattern pos) ?\]))
+                           (not has-slash))
+                 (if (and (= (aref pattern pos) ?/)
+                          (not (= (aref pattern (- pos 1)) ?\\)))
+                     (setq has-slash t)
+                   (setq pos (1+ pos))))
+               (if has-slash
+                   (setq result `(,@result ,(concat "\\["
+                                                    (substring pattern
+                                                               index
+                                                               (1+ pos))
+                                                    "\\]"))
+                         index (+ pos 2))
+                 (if (and (< index length)
+                          (memq (aref pattern index)
+                                '(?! ?^)))
+                     (setq index (1+ index)
+                           result `(,@result "[^"))
+                   (setq result `(,@result "[")))
+                 (setq in-brackets t)))))
 
           (?-
            (if in-brackets

Reply via email to