From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincent Lefevre Newsgroups: gmane.emacs.bugs Subject: bug#50640: 28.0.50; incorrect highlighting in C++ mode Date: Sat, 25 Sep 2021 23:51:17 +0200 Message-ID: <20210925215117.GU7497@zira.vinc17.org> References: <87czp79x6s.fsf@vinc17.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30276"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.1.3+60 (d7d7b4b3) vl-138565 (2021-09-13) Cc: 50640@debbugs.gnu.org, Stefan Kangas To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 25 23:52:24 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUFaq-0007iu-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 23:52:24 +0200 Original-Received: from localhost ([::1]:60966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUFap-0004dn-5w for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 17:52:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUFaU-0004dK-PE for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:52:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUFaU-0007Eb-5N for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mUFaU-0001hV-4e for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincent Lefevre Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Sep 2021 21:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50640 X-GNU-PR-Package: emacs Original-Received: via spool by 50640-submit@debbugs.gnu.org id=B50640.16326066826464 (code B ref 50640); Sat, 25 Sep 2021 21:52:02 +0000 Original-Received: (at 50640) by debbugs.gnu.org; 25 Sep 2021 21:51:22 +0000 Original-Received: from localhost ([127.0.0.1]:34986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUFZq-0001gB-DC for submit@debbugs.gnu.org; Sat, 25 Sep 2021 17:51:22 -0400 Original-Received: from joooj.vinc17.net ([155.133.131.76]:55326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUFZo-0001g0-CK for 50640@debbugs.gnu.org; Sat, 25 Sep 2021 17:51:21 -0400 Original-Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id 81F6A191; Sat, 25 Sep 2021 23:51:18 +0200 (CEST) Original-Received: by zira.vinc17.org (Postfix, from userid 1000) id 83DCEC214DC; Sat, 25 Sep 2021 23:51:17 +0200 (CEST) Content-Disposition: inline In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:215528 Archived-At: On 2021-09-25 21:17:06 +0000, Alan Mackenzie wrote: > Hello, Vincent and Stefan. > > On Sat, Sep 25, 2021 at 11:17:07 -0700, Stefan Kangas wrote: > > Vincent Lefevre writes: > > > > Consider a test.cc file containing: > > > > if (xMin - xt < t3Font->glyphX || > > > yMin - yt < t3Font->glyphY || > > > xMax - xt > t3Font->glyphX + t3Font->glyphW || > > > yMax - yt > t3Font->glyphY + t3Font->glyphH) { > > > } > > > > (this comes from the xpdf source) and open it with "emacs -Q". > > > > The first two "xt" and "yt" are highlighted in green instead of > > > remaining in black. > > Yes. C++ Mode is recognising the < .. < .. > .. > as two nested > templates. The green is font-lock-type-face. :-( > > > > If I remove the last condition as follows and reopen the file: > > > > if (xMin - xt < t3Font->glyphX || > > > yMin - yt < t3Font->glyphY || > > > xMax - xt > t3Font->glyphX + t3Font->glyphW) { > > > } > > > > then only the "yt" is highlighted incorrectly. > > Yes, then only yt opens a "template", there being no closing > to balance > the xt <. > > There's really not much which can be done about this in CC Mode, sorry. > CC Mode's analysis of ambiguous C++ constructs is not very deep, so it > sometimes gets it wrong, as here. Note that when < .. < .. > .. > comparisons occur, there is probably || or && between them. Are C++ nested templates common with || or && inside them? If not, || and && should be forbidden in nested template matching. Alternatively, whitespace characters could also give a hint: AFAIK, for templates, this is usually no whitespace after '<' and no whitespace before '>'. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)