From: Alan Mackenzie Date: Mon, 15 Aug 2016 16:22:36 +0000 (+0000) Subject: Fix minor bug in c-syntactic-re-search-forward. X-Git-Tag: emacs-26.0.90~1737 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=15c16a5d3b45c95bcb0855b607f975310a707ee1;p=emacs.git Fix minor bug in c-syntactic-re-search-forward. 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. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 4a29896b4a5..625e87f109d 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -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