vkarpinsky(a)infospace.com wrote:
The problem is exposed when cc-mode tries to indent
this test C++ text:
void A::a()
{
int a;
/// comment
int b;
}
The definition of second variable is indented incorrectly because of
/// comment line. Set the pointer on beginning of line "int b;"
and execute (forward-comment -1), the pointer moves to the second '/',
instead of the first. This leads to cc-mode incorrect behavior.
The attached patch
fixes the testcase.
Bye
Vasek
--- src/syntax.orig Mon Apr 1 19:43:18 2002
+++ src/syntax.c Tue Apr 2 17:58:59 2002
@@ -645,6 +645,10 @@
c = BUF_FETCH_CHAR (buf, from);
code = SYNTAX_FROM_CACHE (mirrortab, c);
+ /* code is not Smax unless it was set within
+ find_start_of_comment */
+ assert(code < Smax);
+
syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
/* is this a 1-char comment end sequence? if so, try
@@ -700,12 +704,11 @@
if (SYNTAX_CODES_START_P (prev_syncode, syncode))
{
- code = Scomment;
+ /* Smax is like Scomment except from is the
+ position *after* the comment start */
+ code = Smax;
styles_match_p =
SYNTAX_CODES_COMMENT_MASK_START (prev_syncode, syncode) & mask;
- from--;
- UPDATE_SYNTAX_CACHE_BACKWARD (from);
- c = BUF_FETCH_CHAR (buf, from);
}
}
} while (0);
@@ -741,10 +744,18 @@
/* Record comment-starters according to that
quote-parity to the comment-end. */
- if (code == Scomment && styles_match_p)
+ if (styles_match_p)
{
- comstart_parity = parity;
- comstart_pos = from;
+ if (code == Scomment)
+ {
+ comstart_parity = parity;
+ comstart_pos = from;
+ }
+ else if (code == Smax)
+ {
+ comstart_parity = parity;
+ comstart_pos = from - 1;
+ }
}
/* If we find another earlier comment-ender,
2002-04-02 Vaclav Barta <vbar(a)comp.cz>
* syntax.c: changed find_start_of_comment to handle "///"