]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix minor bug in c-syntactic-re-search-forward.
authorAlan Mackenzie <acm@muc.de>
Mon, 15 Aug 2016 16:22:36 +0000 (16:22 +0000)
committerAlan Mackenzie <acm@muc.de>
Mon, 15 Aug 2016 16:22:36 +0000 (16:22 +0000)
Bug was: when NOERROR is neither nil nor t, BOUND is non-nil, PAREN-LEVEL is
non-nil, and the first internal search attempt fails, point wrongly ends up at
BOUND, rather than just before the next closing paren.

* lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): Guard against
the above situation.

lisp/progmodes/cc-engine.el

index 4a29896b4a5ed48ff7110fd048e9d3bfcdaf8dc8..625e87f109d26aef100b16ddbda1e9f3427eb8fe 100644 (file)
@@ -4337,7 +4337,19 @@ comment at the start of cc-engine.el for more info."
            (and
             (progn
               (setq search-pos (point))
-              (re-search-forward regexp bound noerror))
+              (if (re-search-forward regexp bound noerror)
+                  t
+                ;; Without the following, when PAREN-LEVEL it non-nil, and
+                ;; NOERROR is not nil or t, and the very first search above
+                ;; has just failed, point would end up at BOUND rather than
+                ;; just before the next close paren.
+                (when (and (eq search-pos start)
+                           paren-level
+                           (not (memq noerror '(nil t))))
+                  (setq state (parse-partial-sexp start bound -1))
+                  (if (eq (car state) -1)
+                      (setq bound (1- (point)))))
+                nil))
 
             (progn
               (setq state (parse-partial-sexp