# HG changeset patch # User Richard M. Stallman # Date 772494736 0 # Node ID 18c2ad4ddc83ee9882bc5692c465f09b9b0da7bb # Parent 6cc76dc79853decc56ba61345ddadb06961f9bcb (scan_lists, Fforward_comment): When moving backward over a comment, ignore a comment-starter that overlaps the comment-ender. diff -r 6cc76dc79853 -r 18c2ad4ddc83 src/syntax.c --- a/src/syntax.c Fri Jun 24 18:50:03 1994 +0000 +++ b/src/syntax.c Fri Jun 24 21:52:16 1994 +0000 @@ -746,6 +746,7 @@ int comment_end = from; int comstart_pos = 0; int comstart_parity = 0; + int scanstart = from - 1; /* At beginning of range to scan, we're outside of strings; that determines quote parity to the comment-end. */ @@ -764,15 +765,15 @@ { code = Sendcomment; from--; + c = FETCH_CHAR (from); } - else if (from > stop && SYNTAX_COMSTART_SECOND (c) - && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1)) - && comstyle == SYNTAX_COMMENT_STYLE (c)) - { - code = Scomment; - from--; - } + /* If this char starts a 2-char comment start sequence, + treat it like a 1-char comment starter. */ + if (from < scanstart && SYNTAX_COMSTART_FIRST (c) + && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from + 1)) + && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (from + 1))) + code = Scomment; /* Ignore escaped characters. */ if (char_quoted (from)) @@ -1150,6 +1151,7 @@ int comment_end = from; int comstart_pos = 0; int comstart_parity = 0; + int scanstart = from - 1; /* At beginning of range to scan, we're outside of strings; that determines quote parity to the comment-end. */ @@ -1168,15 +1170,15 @@ { code = Sendcomment; from--; + c = FETCH_CHAR (from); } - else if (from > stop && SYNTAX_COMSTART_SECOND (c) - && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1)) - && comstyle == SYNTAX_COMMENT_STYLE (c)) - { - code = Scomment; - from--; - } + /* If this char starts a 2-char comment start sequence, + treat it like a 1-char comment starter. */ + if (from < scanstart && SYNTAX_COMSTART_FIRST (c) + && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from + 1)) + && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (from + 1))) + code = Scomment; /* Ignore escaped characters. */ if (char_quoted (from))