aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog18
-rw-r--r--src/syntax.c43
2 files changed, 45 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6b847d3f35d..b9fcac51fc4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
12000-08-27 Stefan Monnier <monnier@cs.yale.edu>
2
3 * syntax.c (back_comment): Detect cases where a comment-starter is
4 actually inside another comment as in: /* a // b */ c // d \n.
5 Make it clear that `comstart_pos' is unused for nested comments.
6
7 * keymap.c (store_in_keymap, fix_submap_inheritance): New prototypes.
8 (KEYMAPP): New macro.
9 (Fkeymap_parent, Fset_keymap_parent): Use it.
10 (fix_submap_inheritance): Mark it static.
11 (define_as_prefix, describe_buffer_bindings, describe_command)
12 (describe_translation, describe_map): Complete prototypes.
13
14 * lisp.h (store_in_keymap, fix_submap_inheritance): Remove.
15
16 * keyboard.c (menu_bar_item): Detect duplicate entries for all items
17 to better match the key-lookup behavior.
18
12000-08-27 Gerd Moellmann <gerd@gnu.org> 192000-08-27 Gerd Moellmann <gerd@gnu.org>
2 20
3 * xfaces.c (lface_fully_specified_p): Handle :inherit. 21 * xfaces.c (lface_fully_specified_p): Handle :inherit.
diff --git a/src/syntax.c b/src/syntax.c
index 9e5247064ef..189e50d0963 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -469,12 +469,16 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
469 PARITY is current parity of quotes from the comment end. */ 469 PARITY is current parity of quotes from the comment end. */
470 int string_style = -1; /* Presumed outside of any string. */ 470 int string_style = -1; /* Presumed outside of any string. */
471 int string_lossage = 0; 471 int string_lossage = 0;
472 /* Not a real lossage: indicates that we have passed a matching comment
473 starter plus an non-matching comment-ender, meaning that any matching
474 comment-starter we might see later could be a false positive (hidden
475 inside another comment).
476 Test case: { a (* b } c (* d *) */
477 int comment_lossage = 0;
472 int comment_end = from; 478 int comment_end = from;
473 int comment_end_byte = from_byte; 479 int comment_end_byte = from_byte;
474 int comstart_pos = 0; 480 int comstart_pos = 0;
475 int comstart_byte; 481 int comstart_byte;
476 /* Value that PARITY had, when we reached the position
477 in COMSTART_POS. */
478 int scanstart = from - 1; 482 int scanstart = from - 1;
479 /* Place where the containing defun starts, 483 /* Place where the containing defun starts,
480 or 0 if we didn't come across it yet. */ 484 or 0 if we didn't come across it yet. */
@@ -548,23 +552,24 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
548 552
549 case Scomment: 553 case Scomment:
550 /* We've already checked that it is the relevant comstyle. */ 554 /* We've already checked that it is the relevant comstyle. */
551 if (string_style != -1 || string_lossage) 555 if (string_style != -1 || comment_lossage || string_lossage)
552 /* There are odd string quotes involved, so let's be careful. 556 /* There are odd string quotes involved, so let's be careful.
553 Test case in Pascal: " { " a { " } */ 557 Test case in Pascal: " { " a { " } */
554 goto lossage; 558 goto lossage;
555 559
556 if (comnested && --nesting <= 0) 560 if (!comnested)
561 {
562 /* Record best comment-starter so far. */
563 comstart_pos = from;
564 comstart_byte = from_byte;
565 }
566 else if (--nesting <= 0)
557 /* nested comments have to be balanced, so we don't need to 567 /* nested comments have to be balanced, so we don't need to
558 keep looking for earlier ones. We use here the same (slightly 568 keep looking for earlier ones. We use here the same (slightly
559 incorrect) reasoning as below: since it is followed by uniform 569 incorrect) reasoning as below: since it is followed by uniform
560 paired string quotes, this comment-start has to be outside of 570 paired string quotes, this comment-start has to be outside of
561 strings, else the comment-end itself would be inside a string. */ 571 strings, else the comment-end itself would be inside a string. */
562 goto done; 572 goto done;
563
564 /* Record comment-starters according to that
565 quote-parity to the comment-end. */
566 comstart_pos = from;
567 comstart_byte = from_byte;
568 break; 573 break;
569 574
570 case Sendcomment: 575 case Sendcomment:
@@ -578,6 +583,15 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
578 this comment-ender rather than ours. */ 583 this comment-ender rather than ours. */
579 from = stop; /* Break out of the loop. */ 584 from = stop; /* Break out of the loop. */
580 } 585 }
586 else if (comstart_pos != 0 || c != '\n')
587 /* We're mixing comment styles here, so we'd better be careful.
588 The (comstart_pos != 0 || c != '\n') check is not quite correct
589 (we should just always set comment_lossage), but removing it
590 would imply that any multiline comment in C would go through
591 lossage, which seems overkill.
592 The failure should only happen in the rare cases such as
593 { (* } *) */
594 comment_lossage = 1;
581 break; 595 break;
582 596
583 case Sopen: 597 case Sopen:
@@ -594,7 +608,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
594 break; 608 break;
595 609
596 default: 610 default:
597 continue; 611 break;
598 } 612 }
599 } 613 }
600 614
@@ -604,12 +618,9 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
604 from_byte = comment_end_byte; 618 from_byte = comment_end_byte;
605 UPDATE_SYNTAX_TABLE_FORWARD (comment_end - 1); 619 UPDATE_SYNTAX_TABLE_FORWARD (comment_end - 1);
606 } 620 }
607 /* If the earliest comment starter 621 /* If comstart_pos is set and we get here (ie. didn't jump to `lossage'
608 is followed by uniform paired string quotes or none, 622 or `done'), then we've found the beginning of the non-nested comment. */
609 we know it can't be inside a string 623 else if (1) /* !comnested */
610 since if it were then the comment ender would be inside one.
611 So it does start a comment. Skip back to it. */
612 else if (!comnested)
613 { 624 {
614 from = comstart_pos; 625 from = comstart_pos;
615 from_byte = comstart_byte; 626 from_byte = comstart_byte;