Subject: bug#43558: closed (Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 23 Sep 2020 08:58:02 +0000

Your bug report

#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
43558: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=43558
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped.
From: Alan Mackenzie <[email-masked]>
To: [email-masked]
Date: Wed, 23 Sep 2020 08:57:46 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Bug fixed in master.

-- 
Alan Mackenzie (Nuremberg, Germany).

Subject: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped.
From: Alan Mackenzie <[email-masked]>
To: [email-masked], Stefan Monnier <[email-masked]>
Date: Tue, 22 Sep 2020 09:35:50 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Emacs and Stefan.

In the following C comment:

1   /*
2     \*/
3   /**/

, with point at BOL 1, do M-: (forward-comment 1).  This leaves point
wrongly at EOL 2.  It should end up at EOL 3, since the apparent comment
ender on L2 is actually escaped.

The following patch fixes this.  Are there any objections to me
installing it?

diff --git a/src/syntax.c b/src/syntax.c
index e6af8a377b..066972e6d8 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -2354,6 +2354,13 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
 	/* We have encountered a nested comment of the same style
 	   as the comment sequence which began this comment section.  */
 	nesting++;
+      if (comment_end_can_be_escaped
+          && (code == Sescape || code == Scharquote))
+        {
+          inc_both (&from, &from_byte);
+          UPDATE_SYNTAX_TABLE_FORWARD (from);
+          if (from == stop) continue; /* Failure */
+        }
       inc_both (&from, &from_byte);
       UPDATE_SYNTAX_TABLE_FORWARD (from);

-- 
Alan Mackenzie (Nuremberg, Germany).