diff options
| author | Alan Mackenzie | 2012-02-07 15:19:52 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2012-02-07 15:19:52 +0000 |
| commit | 98d7371e7a9568f51aa016ec2cbee7d56ff1ad50 (patch) | |
| tree | 1bc5c9baba953dfb1dc3e82b827afa987768e46e | |
| parent | 667ced3a2d224b0f2ab3f2da26468791252c234a (diff) | |
| download | emacs-98d7371e7a9568f51aa016ec2cbee7d56ff1ad50.tar.gz emacs-98d7371e7a9568f51aa016ec2cbee7d56ff1ad50.zip | |
Fix spurious recognition of c-in-knr-argdecl.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 24 |
2 files changed, 21 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0a65a759b7f..60ececebe26 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2012-02-07 Alan Mackenzie <acm@muc.de> | 1 | 2012-02-07 Alan Mackenzie <acm@muc.de> |
| 2 | 2 | ||
| 3 | Fix spurious recognition of c-in-knr-argdecl. | ||
| 4 | |||
| 5 | * progmodes/cc-engine.el (c-in-knr-argdecl): Check for '=' in a | ||
| 6 | putative K&R region. | ||
| 7 | |||
| 8 | 2012-02-07 Alan Mackenzie <acm@muc.de> | ||
| 9 | |||
| 3 | * progmodes/cc-engine.el (c-forward-objc-directive): Prevent | 10 | * progmodes/cc-engine.el (c-forward-objc-directive): Prevent |
| 4 | looping in "#pragma mark @implementation". | 11 | looping in "#pragma mark @implementation". |
| 5 | 12 | ||
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." | |||
| 7592 | (save-restriction | 7592 | (save-restriction |
| 7593 | ;; If we're in a macro, our search range is restricted to it. Narrow to | 7593 | ;; If we're in a macro, our search range is restricted to it. Narrow to |
| 7594 | ;; the searchable range. | 7594 | ;; the searchable range. |
| 7595 | (let* ((macro-start (c-query-macro-start)) | 7595 | (let* ((macro-start (save-excursion (and (c-beginning-of-macro) (point)))) |
| 7596 | (lim (max (or lim (point-min)) (or macro-start (point-min)))) | 7596 | (macro-end (save-excursion (and macro-start (c-end-of-macro) (point)))) |
| 7597 | (low-lim (max (or lim (point-min)) (or macro-start (point-min)))) | ||
| 7597 | before-lparen after-rparen | 7598 | before-lparen after-rparen |
| 7598 | (pp-count-out 20)) ; Max number of paren/brace constructs before we give up | 7599 | (pp-count-out 20)) ; Max number of paren/brace constructs before |
| 7599 | (narrow-to-region lim (c-point 'eol)) | 7600 | ; we give up |
| 7601 | (narrow-to-region low-lim (or macro-end (point-max))) | ||
| 7600 | 7602 | ||
| 7601 | ;; Search backwards for the defun's argument list. We give up if we | 7603 | ;; Search backwards for the defun's argument list. We give up if we |
| 7602 | ;; encounter a "}" (end of a previous defun) or BOB. | 7604 | ;; encounter a "}" (end of a previous defun) an "=" (which can't be in |
| 7605 | ;; a knr region) or BOB. | ||
| 7603 | ;; | 7606 | ;; |
| 7604 | ;; The criterion for a paren structure being the arg list is: | 7607 | ;; The criterion for a paren structure being the arg list is: |
| 7605 | ;; o - there is non-WS stuff after it but before any "{"; AND | 7608 | ;; 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." | |||
| 7619 | (catch 'knr | 7622 | (catch 'knr |
| 7620 | (while (> pp-count-out 0) ; go back one paren/bracket pair each time. | 7623 | (while (> pp-count-out 0) ; go back one paren/bracket pair each time. |
| 7621 | (setq pp-count-out (1- pp-count-out)) | 7624 | (setq pp-count-out (1- pp-count-out)) |
| 7622 | (c-syntactic-skip-backward "^)]}") | 7625 | (c-syntactic-skip-backward "^)]}=") |
| 7623 | (cond ((eq (char-before) ?\)) | 7626 | (cond ((eq (char-before) ?\)) |
| 7624 | (setq after-rparen (point))) | 7627 | (setq after-rparen (point))) |
| 7625 | ((eq (char-before) ?\]) | 7628 | ((eq (char-before) ?\]) |
| 7626 | (setq after-rparen nil)) | 7629 | (setq after-rparen nil)) |
| 7627 | (t ; either } (hit previous defun) or no more parens/brackets | 7630 | (t ; either } (hit previous defun) or = or no more |
| 7631 | ; parens/brackets. | ||
| 7628 | (throw 'knr nil))) | 7632 | (throw 'knr nil))) |
| 7629 | 7633 | ||
| 7630 | (if after-rparen | 7634 | (if after-rparen |
| @@ -7640,18 +7644,18 @@ comment at the start of cc-engine.el for more info." | |||
| 7640 | ;; It can't be the arg list if next token is ; or { | 7644 | ;; It can't be the arg list if next token is ; or { |
| 7641 | (progn (goto-char after-rparen) | 7645 | (progn (goto-char after-rparen) |
| 7642 | (c-forward-syntactic-ws) | 7646 | (c-forward-syntactic-ws) |
| 7643 | (not (memq (char-after) '(?\; ?\{)))) | 7647 | (not (memq (char-after) '(?\; ?\{ ?\=)))) |
| 7644 | 7648 | ||
| 7645 | ;; Is the thing preceding the list an identifier (the | 7649 | ;; Is the thing preceding the list an identifier (the |
| 7646 | ;; function name), or a macro expansion? | 7650 | ;; function name), or a macro expansion? |
| 7647 | (progn | 7651 | (progn |
| 7648 | (goto-char before-lparen) | 7652 | (goto-char before-lparen) |
| 7649 | (eq (c-backward-token-2) 0) | 7653 | (eq (c-backward-token-2) 0) |
| 7650 | (or (c-on-identifier) | 7654 | (or (eq (c-on-identifier) (point)) |
| 7651 | (and (eq (char-after) ?\)) | 7655 | (and (eq (char-after) ?\)) |
| 7652 | (c-go-up-list-backward) | 7656 | (c-go-up-list-backward) |
| 7653 | (eq (c-backward-token-2) 0) | 7657 | (eq (c-backward-token-2) 0) |
| 7654 | (c-on-identifier)))) | 7658 | (eq (c-on-identifier) (point))))) |
| 7655 | 7659 | ||
| 7656 | ;; Have we got a non-empty list of comma-separated | 7660 | ;; Have we got a non-empty list of comma-separated |
| 7657 | ;; identifiers? | 7661 | ;; identifiers? |