From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Date: Thu, 24 Sep 2020 19:57:42 +0000 Message-ID: <20200924195742.GC4714@ACM> References: <20200923144824.GD6178@ACM> <87v9g3yplr.fsf@md5i.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10117"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43558@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Stefan Monnier To: Michael Welsh Duggan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 24 21:58:15 2020 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 1kLXNe-0002VZ-9U for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Sep 2020 21:58:14 +0200 Original-Received: from localhost ([::1]:55958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLXNd-0000M2-Aq for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Sep 2020 15:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLXNS-0000IP-Ps for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 15:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLXNS-000232-F4 for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 15:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLXNS-0001wi-Dx for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 15:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 19:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43558 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43558-submit@debbugs.gnu.org id=B43558.16009774717462 (code B ref 43558); Thu, 24 Sep 2020 19:58:02 +0000 Original-Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 19:57:51 +0000 Original-Received: from localhost ([127.0.0.1]:41811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLXNG-0001wH-RJ for submit@debbugs.gnu.org; Thu, 24 Sep 2020 15:57:51 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:41804 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kLXNF-0001w3-8K for 43558@debbugs.gnu.org; Thu, 24 Sep 2020 15:57:49 -0400 Original-Received: (qmail 78094 invoked by uid 3782); 24 Sep 2020 19:57:42 -0000 Original-Received: from acm.muc.de (p4fe15b66.dip0.t-ipconnect.de [79.225.91.102]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Sep 2020 21:57:42 +0200 Original-Received: (qmail 31210 invoked by uid 1000); 24 Sep 2020 19:57:42 -0000 Content-Disposition: inline In-Reply-To: <87v9g3yplr.fsf@md5i.com> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:188903 Archived-At: Hello, Michael. On Thu, Sep 24, 2020 at 14:52:16 -0400, Michael Welsh Duggan wrote: > Alan Mackenzie writes: > > On Wed, Sep 23, 2020 at 11:01:59 +0200, Mattias Engdegård wrote: > >> Sorry if I misunderstood, but since when do backslashes escape */ in C? > > Since forever, but only in the CC Mode test suite. :-( > > I just tried it out with gcc, and it seems that \*/ does indeed end a > > block comment. But an escaped newline doesn't end a line comment, > > instead continuing it to the next line. So I got confused. Thanks for > > pointing out the mistake. > > It seems that as well as the existing variable > > comment-end-can-be-escaped, we need a new one, say > > line-comment-end-can-be-escaped, too. In C and C++ modes, these would > > be nil and t respectively. > But where does it say that backslashes escape */ in C++? Nowhere. :-( There has been a test in the CC Mode test suite for many years which assumed this (but was disabled for existing (X)Emacs versions, waiting for a new Emacs version to be "fixed"). > The C++ 14 standard (and it hasn't changed through C++ 20) says: > 2.7 Comments [lex.comment] > The characters /* start a comment, which terminates with the > characters */. These comments do not nest. The characters // start > a comment, which terminates immediately before the next new-line > character. For all the difference it makes, Emacs assumes the comment ends _after_ the NL. > If there is a form-feed or a vertical-tab character in such a > comment, only white-space characters shall appear between it and > the new-line that terminates the comment; no diagnostic is > required. I didn't know that. Emacs/CC Mode doesn't code up this subtlety. It probably isn't worth bothering about. > [ Note: The comment characters //, /*, and */ have no special > meaning within a // comment and are treated just like other > characters. Similarly, the comment characters // and /* have no > special meaning within a /* comment. — end note ] Additionally, an escaped newline continues a comment onto the next line. This happens, notionally, at a very early stage of compilation where a backslash followed by NL anywhere get replaced by a space. I think that even two backslashes followed by NL would get replaced by backslash, space. > -- > Michael Welsh Duggan > (md5i@md5i.com) -- Alan Mackenzie (Nuremberg, Germany).