aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2023-11-24 12:22:08 +0000
committerAlan Mackenzie2023-11-24 12:22:08 +0000
commit2fca889cfb4fa495a6ffa0c7fe368551ee9a32bc (patch)
tree6b71dc8d5b84bd3a7af1280a3ba611c716c1d66b
parent36d9b8ce84afc8aaae3ce067fd24e172c0f631cf (diff)
downloademacs-2fca889cfb4fa495a6ffa0c7fe368551ee9a32bc.tar.gz
emacs-2fca889cfb4fa495a6ffa0c7fe368551ee9a32bc.zip
CC Mode: Fontify int unsigned Foo;
This fixes bug#59953. Foo now gets fontified when unsigned comes after int. * lisp/progmodes/cc-engine.el (c-forward-type): Refactor nested `if' forms into a cond form. Loop around matches for c-opt-type-component-key, advancing over them.
-rw-r--r--lisp/progmodes/cc-engine.el66
1 files changed, 38 insertions, 28 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index d903dd0694e..018a194ac14 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9440,37 +9440,47 @@ multi-line strings (but not C++, for example)."
9440 (or c-promote-possible-types (eq res t))) 9440 (or c-promote-possible-types (eq res t)))
9441 (c-record-type-id (cons (match-beginning 1) (match-end 1)))) 9441 (c-record-type-id (cons (match-beginning 1) (match-end 1))))
9442 9442
9443 (if (and c-opt-type-component-key 9443 (cond
9444 ((and c-opt-type-component-key
9444 (save-match-data 9445 (save-match-data
9445 (looking-at c-opt-type-component-key))) 9446 (looking-at c-opt-type-component-key)))
9446 ;; There might be more keywords for the type. 9447 ;; There might be more keywords for the type.
9447 (let (safe-pos) 9448 (let (safe-pos)
9448 (c-forward-keyword-clause 1 t) 9449 (c-forward-keyword-clause 1 t)
9449 (while (progn 9450 (while (progn
9450 (setq safe-pos (point)) 9451 (setq safe-pos (point))
9451 (c-forward-syntactic-ws) 9452 (c-forward-syntactic-ws)
9452 (looking-at c-opt-type-component-key)) 9453 (looking-at c-opt-type-component-key))
9453 (when (and c-record-type-identifiers 9454 (when (and c-record-type-identifiers
9454 (looking-at c-primitive-type-key)) 9455 (looking-at c-primitive-type-key))
9455 (c-record-type-id (cons (match-beginning 1) 9456 (c-record-type-id (cons (match-beginning 1)
9456 (match-end 1)))) 9457 (match-end 1))))
9457 (c-forward-keyword-clause 1 t)) 9458 (c-forward-keyword-clause 1 t))
9458 (if (looking-at c-primitive-type-key) 9459 (if (looking-at c-primitive-type-key)
9459 (progn 9460 (progn
9460 (when c-record-type-identifiers 9461 (when c-record-type-identifiers
9461 (c-record-type-id (cons (match-beginning 1) 9462 (c-record-type-id (cons (match-beginning 1)
9462 (match-end 1)))) 9463 (match-end 1))))
9463 (c-forward-keyword-clause 1 t) 9464 (c-forward-keyword-clause 1 t)
9464 (setq res t)) 9465 (setq res t)
9465 (goto-char safe-pos) 9466 (while (progn
9466 (setq res 'prefix)) 9467 (setq safe-pos (point))
9467 (setq pos (point))) 9468 (c-forward-syntactic-ws)
9468 (if (save-match-data (c-forward-keyword-clause 1 t)) 9469 (looking-at c-opt-type-component-key))
9469 (setq pos (point)) 9470 (c-forward-keyword-clause 1 t)))
9470 (if pos 9471 (goto-char safe-pos)
9471 (goto-char pos) 9472 (setq res 'prefix))
9472 (goto-char (match-end 1)) 9473 (setq pos (point))))
9473 (setq pos (point))))) 9474 ((save-match-data (c-forward-keyword-clause 1 t))
9475 (while (progn
9476 (setq pos (point))
9477 (c-forward-syntactic-ws)
9478 (and c-opt-type-component-key
9479 (looking-at c-opt-type-component-key)))
9480 (c-forward-keyword-clause 1 t)))
9481 (pos (goto-char pos))
9482 (t (goto-char (match-end 1))
9483 (setq pos (point))))
9474 (c-forward-syntactic-ws)) 9484 (c-forward-syntactic-ws))
9475 9485
9476 ((and (eq name-res t) 9486 ((and (eq name-res t)