From: Stefan Monnier Date: Tue, 21 Sep 2010 15:52:13 +0000 (+0200) Subject: * src/syntax.c (back_comment): Detect the case where a 1-char comment X-Git-Tag: emacs-pretest-23.2.90~102 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fbb3da770f233a8e0cf99d5f053b0c31cbbc8db4;p=emacs.git * src/syntax.c (back_comment): Detect the case where a 1-char comment starter is also the 2nd char of a 2-char comment ender. --- diff --git a/src/ChangeLog b/src/ChangeLog index 0329f40d110..36e1fbab2bf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-09-21 Stefan Monnier + + * syntax.c (back_comment): Detect the case where a 1-char comment + starter is also the 2nd char of a 2-char comment ender. + 2010-09-17 Jan Djärv * gtkutil.c (xg_tool_bar_menu_proxy): Set gtk-menu-items to TRUE. diff --git a/src/syntax.c b/src/syntax.c index 47b4caf5ade..4d7dd2ba7a3 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -512,6 +512,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p { int temp_byte, prev_syntax; int com2start, com2end; + int comstart; /* Move back and examine a character. */ DEC_BOTH (from, from_byte); @@ -530,7 +531,8 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); - + comstart = (com2start || code == Scomment); + /* Nasty cases with overlapping 2-char comment markers: - snmp-mode: -- c -- foo -- c -- --- c -- @@ -541,15 +543,16 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p /// */ /* If a 2-char comment sequence partly overlaps with another, - we don't try to be clever. */ - if (from > stop && (com2end || com2start)) + we don't try to be clever. E.g. |*| in C, or }% in modes that + have %..\n and %{..}%. */ + if (from > stop && (com2end || comstart)) { int next = from, next_byte = from_byte, next_c, next_syntax; DEC_BOTH (next, next_byte); UPDATE_SYNTAX_TABLE_BACKWARD (next); next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); next_syntax = SYNTAX_WITH_FLAGS (next_c); - if (((com2start || comnested) + if (((comstart || comnested) && SYNTAX_FLAGS_COMEND_SECOND (syntax) && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) || ((com2end || comnested)