(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
(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
;; 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?