diff options
| author | Alan Mackenzie | 2020-12-12 14:38:38 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2020-12-12 14:41:45 +0000 |
| commit | 7ee0fc0dc1a7cba8a3e965f411aca498a7db3f4f (patch) | |
| tree | a66de851f3d1da433024f8e1572db30e1b2169d4 | |
| parent | 4afef614cd6c93b4d4a57aa5bb211563649abc56 (diff) | |
| download | emacs-7ee0fc0dc1a7cba8a3e965f411aca498a7db3f4f.tar.gz emacs-7ee0fc0dc1a7cba8a3e965f411aca498a7db3f4f.zip | |
CC Mode: Handle several K&R parameters per declaration
This fixes bug #45160.
* lisp/progmodes/cc-engine.el (c-in-knr-argdecl): Reformulate the latter part
of this function using c-do-declarators.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 5e2ce71f536..f14ffb38cde 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -10837,11 +10837,11 @@ comment at the start of cc-engine.el for more info." | |||
| 10837 | (low-lim (max (or lim (point-min)) (or macro-start (point-min)))) | 10837 | (low-lim (max (or lim (point-min)) (or macro-start (point-min)))) |
| 10838 | before-lparen after-rparen | 10838 | before-lparen after-rparen |
| 10839 | (here (point)) | 10839 | (here (point)) |
| 10840 | (pp-count-out 20) ; Max number of paren/brace constructs before | 10840 | (pp-count-out 20) ; Max number of paren/brace constructs before |
| 10841 | ; we give up. | 10841 | ; we give up |
| 10842 | ids ; List of identifiers in the parenthesized list. | 10842 | ids ; List of identifiers in the parenthesized list. |
| 10843 | id-start after-prec-token decl-or-cast decl-res | 10843 | id-start after-prec-token decl-or-cast decl-res |
| 10844 | c-last-identifier-range identifier-ok) | 10844 | c-last-identifier-range semi-position+1) |
| 10845 | (narrow-to-region low-lim (or macro-end (point-max))) | 10845 | (narrow-to-region low-lim (or macro-end (point-max))) |
| 10846 | 10846 | ||
| 10847 | ;; Search backwards for the defun's argument list. We give up if we | 10847 | ;; Search backwards for the defun's argument list. We give up if we |
| @@ -10875,8 +10875,8 @@ comment at the start of cc-engine.el for more info." | |||
| 10875 | (setq after-rparen (point))) | 10875 | (setq after-rparen (point))) |
| 10876 | ((eq (char-before) ?\]) | 10876 | ((eq (char-before) ?\]) |
| 10877 | (setq after-rparen nil)) | 10877 | (setq after-rparen nil)) |
| 10878 | (t ; either } (hit previous defun) or = or no more | 10878 | (t ; either } (hit previous defun) or = or no more |
| 10879 | ; parens/brackets. | 10879 | ; parens/brackets. |
| 10880 | (throw 'knr nil))) | 10880 | (throw 'knr nil))) |
| 10881 | 10881 | ||
| 10882 | (if after-rparen | 10882 | (if after-rparen |
| @@ -10933,31 +10933,35 @@ comment at the start of cc-engine.el for more info." | |||
| 10933 | (forward-char) ; over the ) | 10933 | (forward-char) ; over the ) |
| 10934 | (setq after-prec-token after-rparen) | 10934 | (setq after-prec-token after-rparen) |
| 10935 | (c-forward-syntactic-ws) | 10935 | (c-forward-syntactic-ws) |
| 10936 | ;; Each time around the following checks one | ||
| 10937 | ;; declaration (which may contain several identifiers). | ||
| 10936 | (while (and | 10938 | (while (and |
| 10937 | (or (consp (setq decl-or-cast | 10939 | (consp (setq decl-or-cast |
| 10938 | (c-forward-decl-or-cast-1 | 10940 | (c-forward-decl-or-cast-1 |
| 10939 | after-prec-token | 10941 | after-prec-token |
| 10940 | nil ; Or 'arglist ??? | 10942 | nil ; Or 'arglist ??? |
| 10941 | nil))) | 10943 | nil))) |
| 10942 | (progn | 10944 | (memq (char-after) '(?\; ?\,)) |
| 10943 | (goto-char after-prec-token) | ||
| 10944 | (c-forward-syntactic-ws) | ||
| 10945 | (setq identifier-ok (eq (char-after) ?{)) | ||
| 10946 | nil)) | ||
| 10947 | (eq (char-after) ?\;) | ||
| 10948 | (setq after-prec-token (1+ (point))) | ||
| 10949 | (goto-char (car decl-or-cast)) | 10945 | (goto-char (car decl-or-cast)) |
| 10950 | (setq decl-res (c-forward-declarator)) | 10946 | (save-excursion |
| 10951 | (setq identifier-ok | 10947 | (setq semi-position+1 |
| 10952 | (member (buffer-substring-no-properties | 10948 | (c-syntactic-re-search-forward |
| 10953 | (car decl-res) (cadr decl-res)) | 10949 | ";" (+ (point) 1000) t))) |
| 10954 | ids)) | 10950 | (c-do-declarators |
| 10955 | (progn | 10951 | semi-position+1 t nil nil |
| 10956 | (goto-char after-prec-token) | 10952 | (lambda (id-start id-end _next _not-top |
| 10957 | (prog1 (< (point) here) | 10953 | _func _init) |
| 10958 | (c-forward-syntactic-ws)))) | 10954 | (if (not (member |
| 10959 | (setq identifier-ok nil)) | 10955 | (buffer-substring-no-properties |
| 10960 | identifier-ok)) | 10956 | id-start id-end) |
| 10957 | ids)) | ||
| 10958 | (throw 'knr nil)))) | ||
| 10959 | |||
| 10960 | (progn (forward-char) | ||
| 10961 | (<= (point) here)) | ||
| 10962 | (progn (c-forward-syntactic-ws) | ||
| 10963 | t))) | ||
| 10964 | t)) | ||
| 10961 | ;; ...Yes. We've identified the function's argument list. | 10965 | ;; ...Yes. We've identified the function's argument list. |
| 10962 | (throw 'knr | 10966 | (throw 'knr |
| 10963 | (progn (goto-char after-rparen) | 10967 | (progn (goto-char after-rparen) |