GNU bug report logs - #28098
26.0.50; bad C fontification

Previous Next

Packages: emacs, cc-mode;

Reported by: Marti Bolivar <marti.f.bolivar <at> gmail.com>

Date: Tue, 15 Aug 2017 15:28:01 UTC

Severity: minor

Found in version 26.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 28098 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Marti Bolivar <marti.f.bolivar <at> gmail.com>
Cc: 28098 <at> debbugs.gnu.org
Subject: Re: bug#28098: 26.0.50; bad C fontification
Date: 16 Aug 2017 20:57:22 -0000
Hello again, Marti.

In article <mailman.13159.1502810889.21957.bug-gnu-emacs <at> gnu.org> you wrote:
> [-- text/plain, encoding 7bit, charset: UTF-8, 98 lines --]

> 1. From emacs -Q, open this file:


> https://github.com/zephyrproject-rtos/zephyr/blob/2de59023dc726e61244eb7cca17252294016c65a/subsys/net/lib/http/http_client.c

> 2. Observe incorrect syntax highlighting at beginning of file. Screenshot:

>    https://postimg.org/image/tzy8qgjjz/

>    (Note that loading a C file with just the #ifdefs and initial
>    comment which fail to highlight above doesn't reproduce the issue.)

I think the following patch should fix the bug.  Would you please apply
it, try it out, and either confirm to me that it fixes the bug, or tell
me what's still wrong:


diff -r 9533dc4cbda3 cc-mode.el
--- a/cc-mode.el	Thu Jul 27 17:37:02 2017 +0000
+++ b/cc-mode.el	Wed Aug 16 20:48:54 2017 +0000
@@ -1529,10 +1529,13 @@
     (c-backward-syntactic-ws)
     (when (setq pos1 (c-on-identifier))
       (goto-char pos1)
-      (when (and (c-forward-declarator)
-		 (eq (c-forward-token-2) 0))
-	(c-backward-syntactic-ws)
-	(point)))))
+      (let ((lim (save-excursion
+		   (and (c-beginning-of-macro)
+			(progn (c-end-of-macro) (point))))))
+	(when (and (c-forward-declarator lim)
+		   (eq (c-forward-token-2 1 nil lim) 0))
+	  (c-backward-syntactic-ws)
+	  (point))))))
 
 (defun c-change-expand-fl-region (beg end old-len)
   ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock

Thanks for taking the trouble to report this bug.

> In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
>  of 2017-08-10 built on plop
> Repository revision: 81656add8117e8d1b7faab18b330d0706462b433
> Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
> System Description: Ubuntu 17.04

-- 
Alan Mackenzie (Nuremberg, Germany).





This bug report was last modified 7 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.