aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie <[email protected]>2012-02-07 15:19:52 +0000
committerAlan Mackenzie <[email protected]>2012-02-07 15:19:52 +0000
commit98d7371e7a9568f51aa016ec2cbee7d56ff1ad50 (patch)
tree1bc5c9baba953dfb1dc3e82b827afa987768e46e /lisp
parent667ced3a2d224b0f2ab3f2da26468791252c234a (diff)
Fix spurious recognition of c-in-knr-argdecl.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/cc-engine.el24
2 files changed, 21 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0a65a759b7..60ececebe2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
2012-02-07 Alan Mackenzie <[email protected]>
+ 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 <[email protected]>
+
* progmodes/cc-engine.el (c-forward-objc-directive): Prevent
looping in "#pragma mark @implementation".
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 47ceec309f..be0f86ddd7 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?