Mercurial > emacs
comparison src/syntax.c @ 29823:5a736b07dbf2
(scan_sexps_forward):
Check the comstyle of single-char comment-starters.
Clarify control-flow around the Scomment case.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 20 Jun 2000 22:48:26 +0000 |
parents | 819dfcbd36c7 |
children | 5dec8ee96c0c |
comparison
equal
deleted
inserted
replaced
29822:d24cc3dc6bbc | 29823:5a736b07dbf2 |
---|---|
2565 INC_FROM; | 2565 INC_FROM; |
2566 code = prev_from_syntax & 0xff; | 2566 code = prev_from_syntax & 0xff; |
2567 | 2567 |
2568 if (code == Scomment) | 2568 if (code == Scomment) |
2569 { | 2569 { |
2570 state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); | |
2570 state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? | 2571 state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? |
2571 1 : -1); | 2572 1 : -1); |
2572 state.comstr_start = prev_from; | 2573 state.comstr_start = prev_from; |
2573 } | 2574 } |
2574 else if (code == Scomment_fence) | 2575 else if (code == Scomment_fence) |
2640 } | 2641 } |
2641 symdone: | 2642 symdone: |
2642 curlevel->prev = curlevel->last; | 2643 curlevel->prev = curlevel->last; |
2643 break; | 2644 break; |
2644 | 2645 |
2646 case Scomment: | |
2647 if (commentstop || boundary_stop) goto done; | |
2645 startincomment: | 2648 startincomment: |
2646 if (commentstop == 1) | 2649 /* The (from == BEGV) test was to enter the loop in the middle so |
2647 goto done; | |
2648 goto commentloop; | |
2649 | |
2650 case Scomment: | |
2651 if (! state.incomment) | |
2652 abort (); | |
2653 if (commentstop || boundary_stop) goto done; | |
2654 commentloop: | |
2655 /* The (from == BEGV) test is to enter the loop in the middle so | |
2656 that we find a 2-char comment ender even if we start in the | 2650 that we find a 2-char comment ender even if we start in the |
2657 middle of it. We don't want to do that if we're just at the | 2651 middle of it. We don't want to do that if we're just at the |
2658 beginning of the comment (think of (*) ... (*)). | 2652 beginning of the comment (think of (*) ... (*)). */ |
2659 Actually, the current code still doesn't handle such cases right | |
2660 when the comment style allows nesting. */ | |
2661 found = forw_comment (from, from_byte, end, | 2653 found = forw_comment (from, from_byte, end, |
2662 state.incomment, state.comstyle, | 2654 state.incomment, state.comstyle, |
2663 (from == BEGV || from < state.comstr_start + 3) | 2655 (from == BEGV || from < state.comstr_start + 3) |
2664 ? 0 : prev_from_syntax, | 2656 ? 0 : prev_from_syntax, |
2665 &out_charpos, &out_bytepos, &state.incomment); | 2657 &out_charpos, &out_bytepos, &state.incomment); |
2666 from = out_charpos; from_byte = out_bytepos; | 2658 from = out_charpos; from_byte = out_bytepos; |
2667 /* Beware! prev_from and friends are invalid now. | 2659 /* Beware! prev_from and friends are invalid now. |
2668 Luckily, the `done' doesn't use them and the INC_FROM | 2660 Luckily, the `done' doesn't use them and the INC_FROM |
2669 sets them to a sane value without looking at them. */ | 2661 sets them to a sane value without looking at them. */ |
2670 if (!found) goto done; | 2662 if (!found) goto done; |
2671 INC_FROM; | 2663 INC_FROM; |
2672 state.incomment = 0; | 2664 state.incomment = 0; |
2673 state.comstyle = 0; /* reset the comment style */ | 2665 state.comstyle = 0; /* reset the comment style */ |
2674 if (boundary_stop) goto done; | 2666 if (boundary_stop) goto done; |
2675 break; | 2667 break; |
2676 | 2668 |