From: Alan Mackenzie Date: Tue, 7 Feb 2012 15:19:52 +0000 (+0000) Subject: Fix spurious recognition of c-in-knr-argdecl. X-Git-Tag: emacs-pretest-24.0.94~255 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=98d7371e7a9568f51aa016ec2cbee7d56ff1ad50;p=emacs.git Fix spurious recognition of c-in-knr-argdecl. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0a65a759b7f..60ececebe26 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2012-02-07 Alan Mackenzie + + Fix spurious recognition of c-in-knr-argdecl. + + * progmodes/cc-engine.el (c-in-knr-argdecl): Check for '=' in a + putative K&R region. + 2012-02-07 Alan Mackenzie * progmodes/cc-engine.el (c-forward-objc-directive): Prevent diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 47ceec309f4..be0f86ddd7e 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7592,14 +7592,17 @@ comment at the start of cc-engine.el for more info." (save-restriction ;; If we're in a macro, our search range is restricted to it. Narrow to ;; the searchable range. - (let* ((macro-start (c-query-macro-start)) - (lim (max (or lim (point-min)) (or macro-start (point-min)))) + (let* ((macro-start (save-excursion (and (c-beginning-of-macro) (point)))) + (macro-end (save-excursion (and macro-start (c-end-of-macro) (point)))) + (low-lim (max (or lim (point-min)) (or macro-start (point-min)))) before-lparen after-rparen - (pp-count-out 20)) ; Max number of paren/brace constructs before we give up - (narrow-to-region lim (c-point 'eol)) + (pp-count-out 20)) ; Max number of paren/brace constructs before + ; we give up + (narrow-to-region low-lim (or macro-end (point-max))) ;; Search backwards for the defun's argument list. We give up if we - ;; encounter a "}" (end of a previous defun) or BOB. + ;; encounter a "}" (end of a previous defun) an "=" (which can't be in + ;; a knr region) or BOB. ;; ;; The criterion for a paren structure being the arg list is: ;; o - there is non-WS stuff after it but before any "{"; AND @@ -7619,12 +7622,13 @@ comment at the start of cc-engine.el for more info." (catch 'knr (while (> pp-count-out 0) ; go back one paren/bracket pair each time. (setq pp-count-out (1- pp-count-out)) - (c-syntactic-skip-backward "^)]}") + (c-syntactic-skip-backward "^)]}=") (cond ((eq (char-before) ?\)) (setq after-rparen (point))) ((eq (char-before) ?\]) (setq after-rparen nil)) - (t ; either } (hit previous defun) or no more parens/brackets + (t ; either } (hit previous defun) or = or no more + ; parens/brackets. (throw 'knr nil))) (if after-rparen @@ -7640,18 +7644,18 @@ comment at the start of cc-engine.el for more info." ;; It can't be the arg list if next token is ; or { (progn (goto-char after-rparen) (c-forward-syntactic-ws) - (not (memq (char-after) '(?\; ?\{)))) + (not (memq (char-after) '(?\; ?\{ ?\=)))) ;; Is the thing preceding the list an identifier (the ;; function name), or a macro expansion? (progn (goto-char before-lparen) (eq (c-backward-token-2) 0) - (or (c-on-identifier) + (or (eq (c-on-identifier) (point)) (and (eq (char-after) ?\)) (c-go-up-list-backward) (eq (c-backward-token-2) 0) - (c-on-identifier)))) + (eq (c-on-identifier) (point))))) ;; Have we got a non-empty list of comma-separated ;; identifiers?