From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marti Bolivar Newsgroups: gmane.emacs.bugs Subject: bug#28098: 26.0.50; bad C fontification Date: Mon, 21 Aug 2017 12:32:30 -0700 Message-ID: References: <20170816205722.954.qmail@mail.muc.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="001a114592944835770557488a4d" X-Trace: blaine.gmane.org 1503344002 16981 195.159.176.226 (21 Aug 2017 19:33:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 21 Aug 2017 19:33:22 +0000 (UTC) Cc: 28098@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 21 21:33:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djsRi-0003lb-M9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Aug 2017 21:33:10 +0200 Original-Received: from localhost ([::1]:47284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djsRo-0000Wp-RT for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Aug 2017 15:33:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djsRg-0000Ut-DY for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 15:33:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djsRe-0002j1-Q7 for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2017 15:33:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1djsRa-0002hh-HG; Mon, 21 Aug 2017 15:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1djsRa-0000MR-83; Mon, 21 Aug 2017 15:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marti Bolivar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 21 Aug 2017 19:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28098 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 28098-submit@debbugs.gnu.org id=B28098.15033439631362 (code B ref 28098); Mon, 21 Aug 2017 19:33:02 +0000 Original-Received: (at 28098) by debbugs.gnu.org; 21 Aug 2017 19:32:43 +0000 Original-Received: from localhost ([127.0.0.1]:48211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djsRD-0000Lp-KQ for submit@debbugs.gnu.org; Mon, 21 Aug 2017 15:32:43 -0400 Original-Received: from mail-it0-f48.google.com ([209.85.214.48]:36624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djsRC-0000Ld-CA for 28098@debbugs.gnu.org; Mon, 21 Aug 2017 15:32:38 -0400 Original-Received: by mail-it0-f48.google.com with SMTP id 77so35858798itj.1 for <28098@debbugs.gnu.org>; Mon, 21 Aug 2017 12:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9e9Y0Qx5fO3T5lvAXU/4ZBFb2I0C9+Ucs22Z2L+IisQ=; b=KXoLeAGhTADhvjBnT64NBYvgIpPRGNHtNVoMlP6jE9pyV+Cdf/BaavGFBagH44RZw3 ynU3PAS6zDdzTBC7iQw6EpD6ef6hJLQ7r14LCpqThqDJcCtROlS3MOfw44wIxvoY/8xs i7bYg5i4w8IpZAi0WbzFt2GRbGa4bLoGJAPzE3H8MDYg8ahsqzLGuJ0jtUJFXwHSDC0s y/avT9++M94mFrrraFuGK5qsEZZbQ7Ndw221sDJnDbhB5Y/nQVBdKZxk/tTBrJJRWJ3F PVS/llfQRx6qGe2P0mtbW6cxDIV3LvRjhP2EleJ2iaE+q2RjrsTNGYdiDDzLfOGD5+Cq jnkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9e9Y0Qx5fO3T5lvAXU/4ZBFb2I0C9+Ucs22Z2L+IisQ=; b=tZTU2Mbk0pbi6uakY0yDtgRp0sOZgz5dq1AQSmYrc5HQi0KRrvbdbzPgOWjDapv03g TH3kbmgdGJfcTnWMV+hckphbS9CKjF6bwuJdA1VUAMhyqHi5pSSC9m0c0yC3PpgVc8+6 QkhPrFkhM72UDXsguu37sNSz6n66d37W8b0H9kKe//VurmfTeWHFGVBIgIRswnKfWcL2 gzOUuZ+MJ6eaGU2dEwSSKeXaOijZyviHO4KEQW6Lake4Zpf9qqrA//SfQfrqtf5f8+g6 NgBwuyUyEc/txZJRCG6Qqc2Jx+4LCwUezI8TNhSDONNGvoFJt21XF1kdYJruvsVqj8Wy k8NQ== X-Gm-Message-State: AHYfb5h3MDAtKq3SWnHaII2/LS/Vrt46MzsBqzbN+7VRDRKoOMyrZJ+L 1wdoyT+IvfA54igs8SsTRLGJ0IOFSg== X-Received: by 10.36.7.138 with SMTP id f132mr7063371itf.10.1503343952776; Mon, 21 Aug 2017 12:32:32 -0700 (PDT) Original-Received: by 10.107.164.151 with HTTP; Mon, 21 Aug 2017 12:32:30 -0700 (PDT) In-Reply-To: <20170816205722.954.qmail@mail.muc.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136021 Archived-At: --001a114592944835770557488a4d Content-Type: multipart/alternative; boundary="001a114592944835730557488a4b" --001a114592944835730557488a4b Content-Type: text/plain; charset="UTF-8" Hi Alan, Thanks for the patch. On Wed, Aug 16, 2017 at 1:57 PM, Alan Mackenzie wrote: > Hello again, Marti. > > In article 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 > I couldn't manage to get this to apply, but I made the changes manually; git format-patch output for the relevant commit is attached. This did indeed resolve the issue. > > Thanks for taking the trouble to report this bug. > > Thanks for taking the time to investigate and fix it. Marti > > 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). > > --001a114592944835730557488a4b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Alan,

Thanks for the patch.

On Wed, Aug 16, 2017= at 1:57 PM, Alan Mackenzie <acm@muc.de> wrote:
Hello again, Marti.

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

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


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

> 2. Observe incorrect syntax highlighting at beginning of file. Screens= hot:

>=C2=A0 =C2=A0 https://postimg.org/image/tzy8qgjjz/<= br>
>=C2=A0 =C2=A0 (Note that loading a C file with = just the #ifdefs and initial
>=C2=A0 =C2=A0 comment which fail to highlight above doesn't reprodu= ce the issue.)

I think the following patch should fix the bug.=C2=A0 Would you plea= se 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=C2=A0 =C2=A0 =C2=A0 =C2=A0 Thu Jul 27 17:37:02 2017 +0000<= br> +++ b/cc-mode.el=C2=A0 =C2=A0 =C2=A0 =C2=A0 Wed Aug 16 20:48:54 2017 +0000<= br> @@ -1529,10 +1529,13 @@
=C2=A0 =C2=A0 =C2=A0(c-backward-syntactic-ws)
=C2=A0 =C2=A0 =C2=A0(when (setq pos1 (c-on-identifier))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char pos1)
-=C2=A0 =C2=A0 =C2=A0 (when (and (c-forward-declarator)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (eq (c-forward-tok= en-2) 0))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(c-backward-syntactic-ws)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(point)))))
+=C2=A0 =C2=A0 =C2=A0 (let ((lim (save-excursion
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and (c-beg= inning-of-macro)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(progn (c-end-of-macro) (point))))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and (c-forward-declarator lim)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (eq (c-forw= ard-token-2 1 nil lim) 0))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(c-backward-syntactic-ws)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(point))))))

=C2=A0(defun c-change-expand-fl-region (beg end old-len)
=C2=A0 =C2=A0;; Expand the region (c-new-BEG c-new-END) to an after-change = font-lock

I couldn't manage to get = this to apply, but I made the changes manually; git format-patch output for= the relevant commit is attached. This did indeed resolve the issue.
<= div>=C2=A0

Thanks for taking the trouble to report this bug.


Thank= s for taking the time to investigate and fix it.

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

--
Alan Mackenzie (Nuremberg, Germany).


--001a114592944835730557488a4b-- --001a114592944835770557488a4d Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Test-c-fontification-fix.patch" Content-Disposition: attachment; filename="0001-Test-c-fontification-fix.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j6mk4ur00 RnJvbSA5NWEzOWIzMzk1OWI5OGY0YjMxNGMxYzQ0MTA2MDY4MmJmNDlhYTQ0IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXJ0aSBCb2xpdmFyIDxtYXJ0aS5mLmJvbGl2YXJAZ21haWwu Y29tPgpEYXRlOiBNb24sIDIxIEF1ZyAyMDE3IDExOjQ3OjI5IC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gVGVzdCBjIGZvbnRpZmljYXRpb24gZml4CgpGcm9tOiBBbGFuIE1hY2tlbnppZSA8YWNtQG11 Yy5kZT4KLS0tCiBsaXNwL3Byb2dtb2Rlcy9jYy1tb2RlLmVsIHwgMTEgKysrKysrKy0tLS0KIDEg ZmlsZSBjaGFuZ2VkLCA3IGluc2VydGlvbnMoKyksIDQgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0 IGEvbGlzcC9wcm9nbW9kZXMvY2MtbW9kZS5lbCBiL2xpc3AvcHJvZ21vZGVzL2NjLW1vZGUuZWwK aW5kZXggMGJmODliOWEzNi4uZjI3ZWM4NzIyYyAxMDA2NDQKLS0tIGEvbGlzcC9wcm9nbW9kZXMv Y2MtbW9kZS5lbAorKysgYi9saXNwL3Byb2dtb2Rlcy9jYy1tb2RlLmVsCkBAIC0xNTQ5LDEwICsx NTQ5LDEzIEBAIGMtZmwtZGVjbC1lbmQKICAgICAoYy1iYWNrd2FyZC1zeW50YWN0aWMtd3MpCiAg ICAgKHdoZW4gKHNldHEgcG9zMSAoYy1vbi1pZGVudGlmaWVyKSkKICAgICAgIChnb3RvLWNoYXIg cG9zMSkKLSAgICAgICh3aGVuIChhbmQgKGMtZm9yd2FyZC1kZWNsYXJhdG9yKQotCQkgKGVxIChj LWZvcndhcmQtdG9rZW4tMikgMCkpCi0JKGMtYmFja3dhcmQtc3ludGFjdGljLXdzKQotCShwb2lu dCkpKSkpCisgICAgICAobGV0ICgobGltIChzYXZlLWV4Y3Vyc2lvbgorICAgICAgICAgICAgICAg ICAgKGFuZCAoYy1iZWdpbm5pbmctb2YtbWFjcm8pCisgICAgICAgICAgICAgICAgICAgICAgIChw cm9nbiAoYy1lbmQtb2YtbWFjcm8pIChwb2ludCkpKSkpKQorICAgICAgICh3aGVuIChhbmQgKGMt Zm9yd2FyZC1kZWNsYXJhdG9yIGxpbSkKKyAgICAgICAgICAgICAgICAgIChlcSAoYy1mb3J3YXJk LXRva2VuLTIgMSBuaWwgbGltKSAwKSkKKyAgICAgICAgIChjLWJhY2t3YXJkLXN5bnRhY3RpYy13 cykKKyAgICAgICAgIChwb2ludCkpKSkpKQogCiAoZGVmdW4gYy1jaGFuZ2UtZXhwYW5kLWZsLXJl Z2lvbiAoX2JlZyBfZW5kIF9vbGQtbGVuKQogICA7OyBFeHBhbmQgdGhlIHJlZ2lvbiAoYy1uZXct QkVHIGMtbmV3LUVORCkgdG8gYW4gYWZ0ZXItY2hhbmdlIGZvbnQtbG9jawotLSAKMi4xMS4wCgo= --001a114592944835770557488a4d--