Mercurial > emacs
comparison src/syntax.c @ 18079:5fbb5aef5649
(back_comment): Detect 2-char comment starts properly.
New arg COMSTYLE; callers changed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 31 May 1997 18:16:22 +0000 |
parents | 90d9682afa28 |
children | 55e03c524041 |
comparison
equal
deleted
inserted
replaced
18078:cd5f9bda791e | 18079:5fbb5aef5649 |
---|---|
339 of comment. Global syntax data remains valid for | 339 of comment. Global syntax data remains valid for |
340 backward search starting at the returned value (or at FROM, if | 340 backward search starting at the returned value (or at FROM, if |
341 the search was not successful). */ | 341 the search was not successful). */ |
342 | 342 |
343 static int | 343 static int |
344 back_comment (from, stop) | 344 back_comment (from, stop, comstyle) |
345 int from, stop; | 345 int from, stop, comstyle; |
346 { | 346 { |
347 /* Look back, counting the parity of string-quotes, | 347 /* Look back, counting the parity of string-quotes, |
348 and recording the comment-starters seen. | 348 and recording the comment-starters seen. |
349 When we reach a safe place, assume that's not in a string; | 349 When we reach a safe place, assume that's not in a string; |
350 then step the main scan to the earliest comment-starter seen | 350 then step the main scan to the earliest comment-starter seen |
359 int comment_end = from; | 359 int comment_end = from; |
360 int comstart_pos = 0; | 360 int comstart_pos = 0; |
361 int comstart_parity = 0; | 361 int comstart_parity = 0; |
362 int scanstart = from - 1; | 362 int scanstart = from - 1; |
363 register enum syntaxcode code; | 363 register enum syntaxcode code; |
364 int c, comstyle = 0; | 364 int c; |
365 | 365 |
366 /* At beginning of range to scan, we're outside of strings; | 366 /* At beginning of range to scan, we're outside of strings; |
367 that determines quote parity to the comment-end. */ | 367 that determines quote parity to the comment-end. */ |
368 while (from != stop) | 368 while (from != stop) |
369 { | 369 { |
386 c = FETCH_CHAR (from); | 386 c = FETCH_CHAR (from); |
387 } | 387 } |
388 | 388 |
389 /* If this char starts a 2-char comment start sequence, | 389 /* If this char starts a 2-char comment start sequence, |
390 treat it like a 1-char comment starter. */ | 390 treat it like a 1-char comment starter. */ |
391 if (from < scanstart && SYNTAX_COMSTART_FIRST (c) | 391 if (from < scanstart && SYNTAX_COMSTART_SECOND (c) |
392 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from + 1)) | 392 && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1)) |
393 && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (from + 1))) | 393 && comstyle == SYNTAX_COMMENT_STYLE (c)) |
394 code = Scomment; | 394 { |
395 code = Scomment; | |
396 DEC_POS (from); | |
397 /* This is apparently the best we can do: */ | |
398 UPDATE_SYNTAX_TABLE_BACKWARD (from); | |
399 c = FETCH_CHAR (from); | |
400 } | |
395 | 401 |
396 /* Ignore escaped characters. */ | 402 /* Ignore escaped characters. */ |
397 if (char_quoted (from)) | 403 if (char_quoted (from)) |
398 continue; | 404 continue; |
399 | 405 |
1583 break; | 1589 break; |
1584 } | 1590 } |
1585 break; | 1591 break; |
1586 } | 1592 } |
1587 #endif /* 0 */ | 1593 #endif /* 0 */ |
1588 found = back_comment (from, stop); | 1594 found = back_comment (from, stop, comstyle); |
1589 if (found != -1) from = found; | 1595 if (found != -1) from = found; |
1590 #if 0 | 1596 #if 0 |
1591 /* Look back, counting the parity of string-quotes, | 1597 /* Look back, counting the parity of string-quotes, |
1592 and recording the comment-starters seen. | 1598 and recording the comment-starters seen. |
1593 When we reach a safe place, assume that's not in a string; | 1599 When we reach a safe place, assume that's not in a string; |
2030 break; | 2036 break; |
2031 } | 2037 } |
2032 break; | 2038 break; |
2033 } | 2039 } |
2034 #endif /* 0 */ | 2040 #endif /* 0 */ |
2035 found = back_comment (from, stop); | 2041 found = back_comment (from, stop, comstyle); |
2036 if (found != -1) from = found; | 2042 if (found != -1) from = found; |
2037 #if 0 | 2043 #if 0 |
2038 /* Look back, counting the parity of string-quotes, | 2044 /* Look back, counting the parity of string-quotes, |
2039 and recording the comment-starters seen. | 2045 and recording the comment-starters seen. |
2040 When we reach a safe place, assume that's not in a string; | 2046 When we reach a safe place, assume that's not in a string; |