diff options
| author | Richard M. Stallman | 1998-02-16 03:02:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-02-16 03:02:53 +0000 |
| commit | ef316cf0139856c787fe154297d142cc60245b6b (patch) | |
| tree | 81efd8405568e307b12c27fcccdcebc07837db9f /src/syntax.c | |
| parent | d619ee06f24e8487f40040805be945e979c111d3 (diff) | |
| download | emacs-ef316cf0139856c787fe154297d142cc60245b6b.tar.gz emacs-ef316cf0139856c787fe154297d142cc60245b6b.zip | |
(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.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/src/syntax.c b/src/syntax.c index 9f0495401dc..68ef32828c4 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -294,6 +294,9 @@ INLINE int | |||
| 294 | inc_bytepos (bytepos) | 294 | inc_bytepos (bytepos) |
| 295 | int bytepos; | 295 | int bytepos; |
| 296 | { | 296 | { |
| 297 | if (NILP (current_buffer->enable_multibyte_characters)) | ||
| 298 | return bytepos + 1; | ||
| 299 | |||
| 297 | INC_POS (bytepos); | 300 | INC_POS (bytepos); |
| 298 | return bytepos; | 301 | return bytepos; |
| 299 | } | 302 | } |
| @@ -305,6 +308,9 @@ INLINE int | |||
| 305 | dec_bytepos (bytepos) | 308 | dec_bytepos (bytepos) |
| 306 | int bytepos; | 309 | int bytepos; |
| 307 | { | 310 | { |
| 311 | if (NILP (current_buffer->enable_multibyte_characters)) | ||
| 312 | return bytepos - 1; | ||
| 313 | |||
| 308 | DEC_POS (bytepos); | 314 | DEC_POS (bytepos); |
| 309 | return bytepos; | 315 | return bytepos; |
| 310 | } | 316 | } |
| @@ -1367,7 +1373,10 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1367 | while (pos < XINT (lim) | 1373 | while (pos < XINT (lim) |
| 1368 | && fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) | 1374 | && fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
| 1369 | { | 1375 | { |
| 1370 | INC_BOTH (pos, pos_byte); | 1376 | /* Since we already checked for multibyteness, |
| 1377 | avoid using INC_BOTH which checks again. */ | ||
| 1378 | INC_POS (pos_byte); | ||
| 1379 | pos++; | ||
| 1371 | UPDATE_SYNTAX_TABLE_FORWARD (pos); | 1380 | UPDATE_SYNTAX_TABLE_FORWARD (pos); |
| 1372 | } | 1381 | } |
| 1373 | } | 1382 | } |
| @@ -1388,7 +1397,10 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1388 | while (pos > XINT (lim)) | 1397 | while (pos > XINT (lim)) |
| 1389 | { | 1398 | { |
| 1390 | int savepos = pos_byte; | 1399 | int savepos = pos_byte; |
| 1391 | DEC_BOTH (pos, pos_byte); | 1400 | /* Since we already checked for multibyteness, |
| 1401 | avoid using DEC_BOTH which checks again. */ | ||
| 1402 | pos--; | ||
| 1403 | DEC_POS (pos_byte); | ||
| 1392 | UPDATE_SYNTAX_TABLE_BACKWARD (pos); | 1404 | UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
| 1393 | if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) | 1405 | if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
| 1394 | { | 1406 | { |
| @@ -1547,10 +1559,7 @@ between them, return t; otherwise return nil.") | |||
| 1547 | { | 1559 | { |
| 1548 | if (from == stop) | 1560 | if (from == stop) |
| 1549 | { | 1561 | { |
| 1550 | if (! NILP (current_buffer->enable_multibyte_characters)) | 1562 | SET_PT_BOTH (from, from_byte); |
| 1551 | SET_PT_BOTH (from, from_byte); | ||
| 1552 | else | ||
| 1553 | SET_PT_BOTH (from_byte, from_byte); | ||
| 1554 | immediate_quit = 0; | 1563 | immediate_quit = 0; |
| 1555 | return Qnil; | 1564 | return Qnil; |
| 1556 | } | 1565 | } |
| @@ -1579,10 +1588,7 @@ between them, return t; otherwise return nil.") | |||
| 1579 | { | 1588 | { |
| 1580 | immediate_quit = 0; | 1589 | immediate_quit = 0; |
| 1581 | DEC_BOTH (from, from_byte); | 1590 | DEC_BOTH (from, from_byte); |
| 1582 | if (! NILP (current_buffer->enable_multibyte_characters)) | 1591 | SET_PT_BOTH (from, from_byte); |
| 1583 | SET_PT_BOTH (from, from_byte); | ||
| 1584 | else | ||
| 1585 | SET_PT_BOTH (from_byte, from_byte); | ||
| 1586 | return Qnil; | 1592 | return Qnil; |
| 1587 | } | 1593 | } |
| 1588 | /* We're at the start of a comment. */ | 1594 | /* We're at the start of a comment. */ |
| @@ -1591,10 +1597,7 @@ between them, return t; otherwise return nil.") | |||
| 1591 | if (from == stop) | 1597 | if (from == stop) |
| 1592 | { | 1598 | { |
| 1593 | immediate_quit = 0; | 1599 | immediate_quit = 0; |
| 1594 | if (! NILP (current_buffer->enable_multibyte_characters)) | 1600 | SET_PT_BOTH (from, from_byte); |
| 1595 | SET_PT_BOTH (from, from_byte); | ||
| 1596 | else | ||
| 1597 | SET_PT_BOTH (from_byte, from_byte); | ||
| 1598 | return Qnil; | 1601 | return Qnil; |
| 1599 | } | 1602 | } |
| 1600 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1603 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| @@ -1653,8 +1656,7 @@ between them, return t; otherwise return nil.") | |||
| 1653 | comstyle = 0; | 1656 | comstyle = 0; |
| 1654 | if (code == Sendcomment) | 1657 | if (code == Sendcomment) |
| 1655 | comstyle = SYNTAX_COMMENT_STYLE (c); | 1658 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 1656 | temp_pos = from_byte; | 1659 | temp_pos = dec_bytepos (from_byte); |
| 1657 | DEC_POS (temp_pos); | ||
| 1658 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 1660 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1659 | && (c1 = FETCH_CHAR (temp_pos), | 1661 | && (c1 = FETCH_CHAR (temp_pos), |
| 1660 | SYNTAX_COMEND_FIRST (c1)) | 1662 | SYNTAX_COMEND_FIRST (c1)) |
| @@ -1719,10 +1721,7 @@ between them, return t; otherwise return nil.") | |||
| 1719 | leave: | 1721 | leave: |
| 1720 | immediate_quit = 0; | 1722 | immediate_quit = 0; |
| 1721 | INC_BOTH (from, from_byte); | 1723 | INC_BOTH (from, from_byte); |
| 1722 | if (! NILP (current_buffer->enable_multibyte_characters)) | 1724 | SET_PT_BOTH (from, from_byte); |
| 1723 | SET_PT_BOTH (from, from_byte); | ||
| 1724 | else | ||
| 1725 | SET_PT_BOTH (from_byte, from_byte); | ||
| 1726 | return Qnil; | 1725 | return Qnil; |
| 1727 | } | 1726 | } |
| 1728 | } | 1727 | } |
| @@ -1730,10 +1729,7 @@ between them, return t; otherwise return nil.") | |||
| 1730 | count1++; | 1729 | count1++; |
| 1731 | } | 1730 | } |
| 1732 | 1731 | ||
| 1733 | if (! NILP (current_buffer->enable_multibyte_characters)) | 1732 | SET_PT_BOTH (from, from_byte); |
| 1734 | SET_PT_BOTH (from, from_byte); | ||
| 1735 | else | ||
| 1736 | SET_PT_BOTH (from_byte, from_byte); | ||
| 1737 | immediate_quit = 0; | 1733 | immediate_quit = 0; |
| 1738 | return Qt; | 1734 | return Qt; |
| 1739 | } | 1735 | } |
| @@ -1891,8 +1887,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1891 | 1887 | ||
| 1892 | case Sstring: | 1888 | case Sstring: |
| 1893 | case Sstring_fence: | 1889 | case Sstring_fence: |
| 1894 | temp_pos = from_byte; | 1890 | temp_pos = dec_bytepos (from_byte); |
| 1895 | DEC_POS (temp_pos); | ||
| 1896 | stringterm = FETCH_CHAR (temp_pos); | 1891 | stringterm = FETCH_CHAR (temp_pos); |
| 1897 | while (1) | 1892 | while (1) |
| 1898 | { | 1893 | { |
| @@ -1941,7 +1936,10 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1941 | if (code == Sendcomment) | 1936 | if (code == Sendcomment) |
| 1942 | comstyle = SYNTAX_COMMENT_STYLE (c); | 1937 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 1943 | temp_pos = from_byte; | 1938 | temp_pos = from_byte; |
| 1944 | DEC_POS (temp_pos); | 1939 | if (! NILP (current_buffer->enable_multibyte_characters)) |
| 1940 | DEC_POS (temp_pos); | ||
| 1941 | else | ||
| 1942 | temp_pos--; | ||
| 1945 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 1943 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1946 | && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) | 1944 | && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) |
| 1947 | && parse_sexp_ignore_comments) | 1945 | && parse_sexp_ignore_comments) |
| @@ -1973,7 +1971,10 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1973 | while (from > stop) | 1971 | while (from > stop) |
| 1974 | { | 1972 | { |
| 1975 | temp_pos = from_byte; | 1973 | temp_pos = from_byte; |
| 1976 | DEC_POS (temp_pos); | 1974 | if (! NILP (current_buffer->enable_multibyte_characters)) |
| 1975 | DEC_POS (temp_pos); | ||
| 1976 | else | ||
| 1977 | temp_pos--; | ||
| 1977 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 1978 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 1978 | c1 = FETCH_CHAR (temp_pos); | 1979 | c1 = FETCH_CHAR (temp_pos); |
| 1979 | temp_code = SYNTAX (c1); | 1980 | temp_code = SYNTAX (c1); |
| @@ -1984,7 +1985,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1984 | if (quoted) | 1985 | if (quoted) |
| 1985 | { | 1986 | { |
| 1986 | DEC_BOTH (from, from_byte); | 1987 | DEC_BOTH (from, from_byte); |
| 1987 | DEC_POS (temp_pos); | 1988 | temp_pos = dec_bytepos (temp_pos); |
| 1988 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 1989 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 1989 | } | 1990 | } |
| 1990 | c1 = FETCH_CHAR (temp_pos); | 1991 | c1 = FETCH_CHAR (temp_pos); |
| @@ -2000,8 +2001,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 2000 | case Smath: | 2001 | case Smath: |
| 2001 | if (!sexpflag) | 2002 | if (!sexpflag) |
| 2002 | break; | 2003 | break; |
| 2003 | temp_pos = from_byte; | 2004 | temp_pos = dec_bytepos (from_byte); |
| 2004 | DEC_POS (temp_pos); | ||
| 2005 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 2005 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 2006 | if (from != stop && c == FETCH_CHAR (temp_pos)) | 2006 | if (from != stop && c == FETCH_CHAR (temp_pos)) |
| 2007 | DEC_BOTH (from, from_byte); | 2007 | DEC_BOTH (from, from_byte); |
| @@ -2055,7 +2055,10 @@ scan_lists (from, count, depth, sexpflag) | |||
| 2055 | { | 2055 | { |
| 2056 | if (from == stop) goto lose; | 2056 | if (from == stop) goto lose; |
| 2057 | temp_pos = from_byte; | 2057 | temp_pos = from_byte; |
| 2058 | DEC_POS (temp_pos); | 2058 | if (! NILP (current_buffer->enable_multibyte_characters)) |
| 2059 | DEC_POS (temp_pos); | ||
| 2060 | else | ||
| 2061 | temp_pos--; | ||
| 2059 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 2062 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 2060 | if (!char_quoted (from - 1, temp_pos) | 2063 | if (!char_quoted (from - 1, temp_pos) |
| 2061 | && stringterm == FETCH_CHAR (temp_pos)) | 2064 | && stringterm == FETCH_CHAR (temp_pos)) |
| @@ -2214,8 +2217,7 @@ scan_sexps_forward (stateptr, from, from_byte, end, targetdepth, | |||
| 2214 | #define INC_FROM \ | 2217 | #define INC_FROM \ |
| 2215 | do { prev_from = from; \ | 2218 | do { prev_from = from; \ |
| 2216 | prev_from_byte = from_byte; \ | 2219 | prev_from_byte = from_byte; \ |
| 2217 | from++; \ | 2220 | INC_BOTH (from, from_byte); \ |
| 2218 | INC_POS (from_byte); \ | ||
| 2219 | } while (0) | 2221 | } while (0) |
| 2220 | 2222 | ||
| 2221 | immediate_quit = 1; | 2223 | immediate_quit = 1; |