Mercurial > emacs
changeset 20905:e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
(Fforward_comment): Always use both FROM and FROM_BYTE to set point.
Use dec_bytepos not DEC_POS.
(scan_lists): Handle unibyte buffers when decrementing temp_pos.
(INC_FROM): Use INC_BOTH.
(inc_bytepos, dec_bytepos): In unibyte mode, just increment bytepos.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 16 Feb 1998 03:02:53 +0000 |
parents | 79d73f468e38 |
children | 64a8cdbdef42 |
files | src/syntax.c |
diffstat | 1 files changed, 36 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/syntax.c Mon Feb 16 03:01:16 1998 +0000 +++ b/src/syntax.c Mon Feb 16 03:02:53 1998 +0000 @@ -294,6 +294,9 @@ inc_bytepos (bytepos) int bytepos; { + if (NILP (current_buffer->enable_multibyte_characters)) + return bytepos + 1; + INC_POS (bytepos); return bytepos; } @@ -305,6 +308,9 @@ dec_bytepos (bytepos) int bytepos; { + if (NILP (current_buffer->enable_multibyte_characters)) + return bytepos - 1; + DEC_POS (bytepos); return bytepos; } @@ -1367,7 +1373,10 @@ while (pos < XINT (lim) && fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) { - INC_BOTH (pos, pos_byte); + /* Since we already checked for multibyteness, + avoid using INC_BOTH which checks again. */ + INC_POS (pos_byte); + pos++; UPDATE_SYNTAX_TABLE_FORWARD (pos); } } @@ -1388,7 +1397,10 @@ while (pos > XINT (lim)) { int savepos = pos_byte; - DEC_BOTH (pos, pos_byte); + /* Since we already checked for multibyteness, + avoid using DEC_BOTH which checks again. */ + pos--; + DEC_POS (pos_byte); UPDATE_SYNTAX_TABLE_BACKWARD (pos); if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) { @@ -1547,10 +1559,7 @@ { if (from == stop) { - if (! NILP (current_buffer->enable_multibyte_characters)) - SET_PT_BOTH (from, from_byte); - else - SET_PT_BOTH (from_byte, from_byte); + SET_PT_BOTH (from, from_byte); immediate_quit = 0; return Qnil; } @@ -1579,10 +1588,7 @@ { immediate_quit = 0; DEC_BOTH (from, from_byte); - if (! NILP (current_buffer->enable_multibyte_characters)) - SET_PT_BOTH (from, from_byte); - else - SET_PT_BOTH (from_byte, from_byte); + SET_PT_BOTH (from, from_byte); return Qnil; } /* We're at the start of a comment. */ @@ -1591,10 +1597,7 @@ if (from == stop) { immediate_quit = 0; - if (! NILP (current_buffer->enable_multibyte_characters)) - SET_PT_BOTH (from, from_byte); - else - SET_PT_BOTH (from_byte, from_byte); + SET_PT_BOTH (from, from_byte); return Qnil; } UPDATE_SYNTAX_TABLE_FORWARD (from); @@ -1653,8 +1656,7 @@ comstyle = 0; if (code == Sendcomment) comstyle = SYNTAX_COMMENT_STYLE (c); - temp_pos = from_byte; - DEC_POS (temp_pos); + temp_pos = dec_bytepos (from_byte); if (from > stop && SYNTAX_COMEND_SECOND (c) && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) @@ -1719,10 +1721,7 @@ leave: immediate_quit = 0; INC_BOTH (from, from_byte); - if (! NILP (current_buffer->enable_multibyte_characters)) - SET_PT_BOTH (from, from_byte); - else - SET_PT_BOTH (from_byte, from_byte); + SET_PT_BOTH (from, from_byte); return Qnil; } } @@ -1730,10 +1729,7 @@ count1++; } - if (! NILP (current_buffer->enable_multibyte_characters)) - SET_PT_BOTH (from, from_byte); - else - SET_PT_BOTH (from_byte, from_byte); + SET_PT_BOTH (from, from_byte); immediate_quit = 0; return Qt; } @@ -1891,8 +1887,7 @@ case Sstring: case Sstring_fence: - temp_pos = from_byte; - DEC_POS (temp_pos); + temp_pos = dec_bytepos (from_byte); stringterm = FETCH_CHAR (temp_pos); while (1) { @@ -1941,7 +1936,10 @@ if (code == Sendcomment) comstyle = SYNTAX_COMMENT_STYLE (c); temp_pos = from_byte; - DEC_POS (temp_pos); + 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)) && parse_sexp_ignore_comments) @@ -1973,7 +1971,10 @@ while (from > stop) { temp_pos = from_byte; - DEC_POS (temp_pos); + if (! NILP (current_buffer->enable_multibyte_characters)) + DEC_POS (temp_pos); + else + temp_pos--; UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); c1 = FETCH_CHAR (temp_pos); temp_code = SYNTAX (c1); @@ -1984,7 +1985,7 @@ if (quoted) { DEC_BOTH (from, from_byte); - DEC_POS (temp_pos); + temp_pos = dec_bytepos (temp_pos); UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); } c1 = FETCH_CHAR (temp_pos); @@ -2000,8 +2001,7 @@ case Smath: if (!sexpflag) break; - temp_pos = from_byte; - DEC_POS (temp_pos); + temp_pos = dec_bytepos (from_byte); UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); if (from != stop && c == FETCH_CHAR (temp_pos)) DEC_BOTH (from, from_byte); @@ -2055,7 +2055,10 @@ { if (from == stop) goto lose; temp_pos = from_byte; - DEC_POS (temp_pos); + if (! NILP (current_buffer->enable_multibyte_characters)) + DEC_POS (temp_pos); + else + temp_pos--; UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); if (!char_quoted (from - 1, temp_pos) && stringterm == FETCH_CHAR (temp_pos)) @@ -2214,8 +2217,7 @@ #define INC_FROM \ do { prev_from = from; \ prev_from_byte = from_byte; \ - from++; \ - INC_POS (from_byte); \ + INC_BOTH (from, from_byte); \ } while (0) immediate_quit = 1;