invalidate = 0;
if (NULL_INTERVAL_P (i))
return;
- /* interval_of () updates only ->position of the return value,
+ /* interval_of updates only ->position of the return value, so
update the parents manually to speed up update_interval. */
while (!NULL_PARENT (i))
{
else if (charpos < i->position) /* Move left. */
{
if (count > 0)
- error ("Error in syntax_table logic for intervals <-.");
+ error ("Error in syntax_table logic for intervals <-");
/* Update the interval. */
i = update_interval (i, charpos);
if (oldi->position != INTERVAL_LAST_POS (i))
else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */
{
if (count < 0)
- error ("Error in syntax_table logic for intervals ->.");
+ error ("Error in syntax_table logic for intervals ->");
/* Update the interval. */
i = update_interval (i, charpos);
if (i->position != INTERVAL_LAST_POS (oldi))
return find_start_value;
}
\f
+/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
+
+static int
+prev_char_comend_first (pos, pos_byte)
+ int pos, pos_byte;
+{
+ int c, val;
+
+ DEC_BOTH (pos, pos_byte);
+ UPDATE_SYNTAX_TABLE_BACKWARD (pos);
+ c = FETCH_CHAR (pos_byte);
+ val = SYNTAX_COMEND_FIRST (c);
+ UPDATE_SYNTAX_TABLE_FORWARD (pos + 1);
+ return val;
+}
+
+/* Return the SYNTAX_COMSTART_FIRST of the character before POS, POS_BYTE. */
+
+static int
+prev_char_comstart_first (pos, pos_byte)
+ int pos, pos_byte;
+{
+ int c, val;
+
+ DEC_BOTH (pos, pos_byte);
+ UPDATE_SYNTAX_TABLE_BACKWARD (pos);
+ c = FETCH_CHAR (pos_byte);
+ val = SYNTAX_COMSTART_FIRST (c);
+ UPDATE_SYNTAX_TABLE_FORWARD (pos + 1);
+ return val;
+}
+
/* Checks whether charpos FROM is at the end of a comment.
FROM_BYTE is the bytepos corresponding to FROM.
Do not move back before STOP.
that determines quote parity to the comment-end. */
while (from != stop)
{
- int temp_byte;
+ int temp_byte, prev_comend_second;
/* Move back and examine a character. */
DEC_BOTH (from, from_byte);
/* If this char is the second of a 2-char comment end sequence,
back up and give the pair the appropriate syntax. */
if (from > stop && SYNTAX_COMEND_SECOND (c)
- && (temp_byte = dec_bytepos (from_byte),
- SYNTAX_COMEND_FIRST (FETCH_CHAR (temp_byte))))
+ && prev_char_comend_first (from, from_byte))
{
code = Sendcomment;
DEC_BOTH (from, from_byte);
- /* This is apparently the best we can do: */
UPDATE_SYNTAX_TABLE_BACKWARD (from);
c = FETCH_CHAR (from_byte);
}
/* If this char starts a 2-char comment start sequence,
treat it like a 1-char comment starter. */
- if (from < scanstart && SYNTAX_COMSTART_FIRST (c)
- && (temp_byte = inc_bytepos (from_byte),
- (SYNTAX_COMSTART_SECOND (FETCH_CHAR (temp_byte))
- && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (temp_byte)))))
- code = Scomment;
+ if (from < scanstart && SYNTAX_COMSTART_FIRST (c))
+ {
+ temp_byte = inc_bytepos (from_byte);
+ UPDATE_SYNTAX_TABLE_FORWARD (from + 1);
+ if (SYNTAX_COMSTART_SECOND (FETCH_CHAR (temp_byte))
+ && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (temp_byte)))
+ code = Scomment;
+ UPDATE_SYNTAX_TABLE_BACKWARD (from);
+ }
/* Ignore escaped characters, except comment-enders. */
if (code != Sendcomment && char_quoted (from, from_byte))
{
do
{
+ int comstart_first;
+
if (from == stop)
{
SET_PT_BOTH (from, from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);
c = FETCH_CHAR (from_byte);
code = SYNTAX (c);
+ comstart_first = SYNTAX_COMSTART_FIRST (c);
INC_BOTH (from, from_byte);
+ UPDATE_SYNTAX_TABLE_FORWARD (from);
comstyle = 0;
- if (from < stop && SYNTAX_COMSTART_FIRST (c)
+ if (from < stop && comstart_first
&& (c1 = FETCH_CHAR (from_byte),
SYNTAX_COMSTART_SECOND (c1)))
{
section. */
break;
if (from < stop && SYNTAX_COMEND_FIRST (c)
+ && SYNTAX_COMMENT_STYLE (c) == comstyle
&& (c1 = FETCH_CHAR (from_byte),
- SYNTAX_COMEND_SECOND (c1))
- && SYNTAX_COMMENT_STYLE (c) == comstyle)
+ UPDATE_SYNTAX_TABLE_FORWARD (from),
+ SYNTAX_COMEND_SECOND (c1)))
/* we have encountered a comment end of the same style
as the comment sequence which began this comment
section */
{
while (1)
{
- int quoted;
+ int quoted, comstart_second;
+
if (from <= stop)
{
SET_PT_BOTH (BEGV, BEGV_BYTE);
}
DEC_BOTH (from, from_byte);
+ /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */
quoted = char_quoted (from, from_byte);
if (quoted)
{
DEC_BOTH (from, from_byte);
goto leave;
}
- UPDATE_SYNTAX_TABLE_BACKWARD (from);
c = FETCH_CHAR (from_byte);
code = SYNTAX (c);
comstyle = 0;
if (code == Sendcomment)
comstyle = SYNTAX_COMMENT_STYLE (c);
- temp_pos = dec_bytepos (from_byte);
+ comstart_second = SYNTAX_COMSTART_SECOND (c);
if (from > stop && SYNTAX_COMEND_SECOND (c)
- && (c1 = FETCH_CHAR (temp_pos),
- SYNTAX_COMEND_FIRST (c1))
+ && prev_char_comend_first (from, from_byte)
&& !char_quoted (from - 1, temp_pos))
{
/* We must record the comment style encountered so that
later, we can match only the proper comment begin
sequence of the same style. */
- code = Sendcomment;
- comstyle = SYNTAX_COMMENT_STYLE (c1);
DEC_BOTH (from, from_byte);
+ code = Sendcomment;
+ /* Calling char_quoted, above, set up global syntax position
+ at the new value of FROM. */
+ comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte));
}
- if (from > stop && SYNTAX_COMSTART_SECOND (c)
- && (c1 = FETCH_CHAR (temp_pos),
- SYNTAX_COMSTART_FIRST (c1))
+ if (from > stop && comstart_second
+ && prev_char_comstart_first (from, from_byte)
&& !char_quoted (from - 1, temp_pos))
{
/* We must record the comment style encountered so that
{
while (from < stop)
{
+ int comstart_first, prefix;
UPDATE_SYNTAX_TABLE_FORWARD (from);
c = FETCH_CHAR (from_byte);
code = SYNTAX (c);
+ comstart_first = SYNTAX_COMSTART_FIRST (c);
+ prefix = SYNTAX_PREFIX (c);
if (depth == min_depth)
last_good = from;
INC_BOTH (from, from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);
- if (from < stop && SYNTAX_COMSTART_FIRST (c)
+ if (from < stop && comstart_first
&& SYNTAX_COMSTART_SECOND (FETCH_CHAR (from_byte))
&& parse_sexp_ignore_comments)
{
code = Scomment;
comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte));
INC_BOTH (from, from_byte);
+ UPDATE_SYNTAX_TABLE_FORWARD (from);
}
- UPDATE_SYNTAX_TABLE_FORWARD (from);
- if (SYNTAX_PREFIX (c))
+ if (prefix)
continue;
switch (SWITCH_ENUM_CAST (code))
}
UPDATE_SYNTAX_TABLE_FORWARD (from);
c = FETCH_CHAR (from_byte);
+ INC_BOTH (from, from_byte);
if (code == Scomment
? (SYNTAX (c) == Sendcomment
&& SYNTAX_COMMENT_STYLE (c) == comstyle)
as the comment sequence which began this comment
section */
break;
- INC_BOTH (from, from_byte);
if (from < stop && SYNTAX_COMEND_FIRST (c)
- && SYNTAX_COMEND_SECOND (FETCH_CHAR (from_byte))
&& SYNTAX_COMMENT_STYLE (c) == comstyle
+ && (UPDATE_SYNTAX_TABLE_FORWARD (from),
+ SYNTAX_COMEND_SECOND (FETCH_CHAR (from_byte)))
&& code == Scomment)
/* we have encountered a comment end of the same style
as the comment sequence which began this comment
comstyle = 0;
if (code == Sendcomment)
comstyle = SYNTAX_COMMENT_STYLE (c);
- temp_pos = from_byte;
- if (! NILP (current_buffer->enable_multibyte_characters))
- DEC_POS (temp_pos);
- else
- temp_pos--;
if (from > stop && SYNTAX_COMEND_SECOND (c)
- && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1))
+ && prev_char_comstart_first (from, from_byte)
&& parse_sexp_ignore_comments)
{
- /* we must record the comment style encountered so that
+ /* We must record the comment style encountered so that
later, we can match only the proper comment begin
- sequence of the same style */
- code = Sendcomment;
- comstyle = SYNTAX_COMMENT_STYLE (c1);
+ sequence of the same style. */
DEC_BOTH (from, from_byte);
+ UPDATE_SYNTAX_TABLE_BACKWARD (from);
+ code = Sendcomment;
+ comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte));
}
/* Quoting turns anything except a comment-ender
- into a word character. */
+ into a word character. Note that this if cannot be true
+ if we decremented FROM in the if-statement above. */
if (code != Sendcomment && char_quoted (from, from_byte))
code = Sword;
else if (SYNTAX_PREFIX (c))
int pos_byte = PT_BYTE;
int c;
- if (pos > beg)
+ if (pos <= beg)
{
- SETUP_SYNTAX_TABLE (pos, -1);
+ SET_PT_BOTH (opoint, opoint_byte);
+
+ return Qnil;
}
+ SETUP_SYNTAX_TABLE (pos, -1);
+
DEC_BOTH (pos, pos_byte);
while (!char_quoted (pos, pos_byte)