From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.bugs Subject: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Date: Thu, 24 Sep 2020 16:27:48 -0400 Message-ID: References: <20200923144824.GD6178@ACM> <87v9g3yplr.fsf@md5i.com> <20200924195742.GC4714@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25388"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Michael Welsh Duggan , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , "43558@debbugs.gnu.org" <43558@debbugs.gnu.org>, Stefan Monnier To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 24 22:29:20 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 1kLXrj-0006T6-H3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Sep 2020 22:29:19 +0200 Original-Received: from localhost ([::1]:54126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLXri-0004t4-Ir for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Sep 2020 16:29:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLXrS-0004r9-Tg for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:29:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLXrS-0005se-KQ for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLXrS-0002j8-HF for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Welsh Duggan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 20:29: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.160097928710407 (code B ref 43558); Thu, 24 Sep 2020 20:29:02 +0000 Original-Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 20:28:07 +0000 Original-Received: from localhost ([127.0.0.1]:41899 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLXqY-0002hn-MO for submit@debbugs.gnu.org; Thu, 24 Sep 2020 16:28:06 -0400 Original-Received: from veto.sei.cmu.edu ([147.72.252.17]:56112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLXqT-0002hE-BE for 43558@debbugs.gnu.org; Thu, 24 Sep 2020 16:28:04 -0400 Original-Received: from korb.sei.cmu.edu (korb.sei.cmu.edu [10.64.21.30]) by veto.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRpRQ004974; Thu, 24 Sep 2020 16:27:51 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 veto.sei.cmu.edu 08OKRpRQ004974 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cert.org; s=yc2bmwvrj62m; t=1600979272; bh=vlj8poS9fa2fSE/vU43Rz9kFRxlSgMC2A8WUTyv4tls=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CGpsxJQ/AftZ/FGc+D4Dhzsfa6jIsLxsAFm3XdJuoU4xdlfqqUFbZWG880nRRF4Eq +Jc6vLdjv4AsiF9+kV7ctwV5farNqRhHaPdLz39Ao0uUMyrxK2gO4bD8Z37Y2CgiT/ FWSpxDCzykOWnJ4cynh243vpqVZDwVH2JPofxggs= Original-Received: from lx-birch.ad.sei.cmu.edu (lx-birch.ad.sei.cmu.edu [10.64.53.120]) by korb.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRnrk022482; Thu, 24 Sep 2020 16:27:49 -0400 Original-Received: from lx-birch.ad.sei.cmu.edu (localhost [127.0.0.1]) by lx-birch.ad.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRmkP026517; Thu, 24 Sep 2020 16:27:48 -0400 Original-Received: (from mwd@localhost) by lx-birch.ad.sei.cmu.edu (8.14.7/8.14.7) id 08OKRmSW026514; Thu, 24 Sep 2020 16:27:48 -0400 X-Authentication-Warning: lx-birch.ad.sei.cmu.edu: mwd set sender to mwd@cert.org using -f In-Reply-To: <20200924195742.GC4714@ACM> (Alan Mackenzie's message of "Thu, 24 Sep 2020 15:57:42 -0400") 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:188908 Archived-At: Alan Mackenzie writes: > 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=C3=A5rd 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] >=20=20=20=20=20 >> 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. =E2=80=94 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. Almost. A backslash followed by a newline is elided completely, joining the lines. (Not replaced by a space. Otherwise, I concur. --=20 Michael Welsh Duggan (mwd@cert.org)