Mercurial > emacs
comparison src/syntax.c @ 20674:fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
(back_comment): Don't allow quoting a comment-end.
(scan_lists): Likewise.
| author | Karl Heuer <kwzh@gnu.org> |
|---|---|
| date | Sun, 18 Jan 1998 05:15:48 +0000 |
| parents | a39bcf9c0e1e |
| children | 10eb136ca94b |
comparison
equal
deleted
inserted
replaced
| 20673:e8a304f0d461 | 20674:fa7d4c0ee36c |
|---|---|
| 445 && (temp_byte = inc_bytepos (from_byte), | 445 && (temp_byte = inc_bytepos (from_byte), |
| 446 (SYNTAX_COMSTART_SECOND (FETCH_CHAR (temp_byte)) | 446 (SYNTAX_COMSTART_SECOND (FETCH_CHAR (temp_byte)) |
| 447 && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (temp_byte))))) | 447 && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (temp_byte))))) |
| 448 code = Scomment; | 448 code = Scomment; |
| 449 | 449 |
| 450 /* Ignore escaped characters. */ | 450 /* Ignore escaped characters, except comment-enders. */ |
| 451 if (char_quoted (from, from_byte)) | 451 if (code != Sendcomment && char_quoted (from, from_byte)) |
| 452 continue; | 452 continue; |
| 453 | 453 |
| 454 /* Track parity of quotes. */ | 454 /* Track parity of quotes. */ |
| 455 if (code == Sstring) | 455 if (code == Sstring) |
| 456 { | 456 { |
| 1279 if (string_multibyte) | 1279 if (string_multibyte) |
| 1280 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); | 1280 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); |
| 1281 else | 1281 else |
| 1282 c = XSTRING (string)->data[i++]; | 1282 c = XSTRING (string)->data[i++]; |
| 1283 } | 1283 } |
| 1284 if (i == XSTRING (string)->size && XSTRING (string)->data[i] == '-') | 1284 if (i < XSTRING (string)->size && XSTRING (string)->data[i] == '-') |
| 1285 { | 1285 { |
| 1286 unsigned int c2; | 1286 unsigned int c2; |
| 1287 | 1287 |
| 1288 /* Skip over the dash. */ | 1288 /* Skip over the dash. */ |
| 1289 i++, i_byte++; | 1289 i++, i_byte++; |
| 1919 { | 1919 { |
| 1920 while (from > stop) | 1920 while (from > stop) |
| 1921 { | 1921 { |
| 1922 DEC_BOTH (from, from_byte); | 1922 DEC_BOTH (from, from_byte); |
| 1923 UPDATE_SYNTAX_TABLE_BACKWARD (from); | 1923 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 1924 if (quoted = char_quoted (from, from_byte)) | |
| 1925 { | |
| 1926 DEC_BOTH (from, from_byte); | |
| 1927 UPDATE_SYNTAX_TABLE_BACKWARD (from); | |
| 1928 } | |
| 1929 c = FETCH_CHAR (from_byte); | 1924 c = FETCH_CHAR (from_byte); |
| 1930 code = SYNTAX (c); | 1925 code = SYNTAX (c); |
| 1931 if (depth == min_depth) | 1926 if (depth == min_depth) |
| 1932 last_good = from; | 1927 last_good = from; |
| 1933 comstyle = 0; | 1928 comstyle = 0; |
| 1935 comstyle = SYNTAX_COMMENT_STYLE (c); | 1930 comstyle = SYNTAX_COMMENT_STYLE (c); |
| 1936 temp_pos = from_byte; | 1931 temp_pos = from_byte; |
| 1937 DEC_POS (temp_pos); | 1932 DEC_POS (temp_pos); |
| 1938 if (from > stop && SYNTAX_COMEND_SECOND (c) | 1933 if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1939 && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) | 1934 && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) |
| 1940 && !char_quoted (from - 1, temp_pos) | |
| 1941 && parse_sexp_ignore_comments) | 1935 && parse_sexp_ignore_comments) |
| 1942 { | 1936 { |
| 1943 /* we must record the comment style encountered so that | 1937 /* we must record the comment style encountered so that |
| 1944 later, we can match only the proper comment begin | 1938 later, we can match only the proper comment begin |
| 1945 sequence of the same style */ | 1939 sequence of the same style */ |
| 1946 code = Sendcomment; | 1940 code = Sendcomment; |
| 1947 comstyle = SYNTAX_COMMENT_STYLE (c1); | 1941 comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 1948 DEC_BOTH (from, from_byte); | 1942 DEC_BOTH (from, from_byte); |
| 1949 } | 1943 } |
| 1950 | 1944 |
| 1951 if (SYNTAX_PREFIX (c)) | 1945 /* Quoting turns anything except a comment-ender |
| 1946 into a word character. */ | |
| 1947 if (code != Sendcomment && char_quoted (from, from_byte)) | |
| 1948 code = Sword; | |
| 1949 else if (SYNTAX_PREFIX (c)) | |
| 1952 continue; | 1950 continue; |
| 1953 | 1951 |
| 1954 switch (SWITCH_ENUM_CAST (quoted ? Sword : code)) | 1952 switch (SWITCH_ENUM_CAST (code)) |
| 1955 { | 1953 { |
| 1956 case Sword: | 1954 case Sword: |
| 1957 case Ssymbol: | 1955 case Ssymbol: |
| 1956 case Sescape: | |
| 1957 case Scharquote: | |
| 1958 if (depth || !sexpflag) break; | 1958 if (depth || !sexpflag) break; |
| 1959 /* This word counts as a sexp; count object finished | 1959 /* This word counts as a sexp; count object finished |
| 1960 after passing it. */ | 1960 after passing it. */ |
| 1961 while (from > stop) | 1961 while (from > stop) |
| 1962 { | 1962 { |
| 1963 temp_pos = from_byte; | 1963 temp_pos = from_byte; |
| 1964 DEC_POS (temp_pos); | 1964 DEC_POS (temp_pos); |
| 1965 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 1965 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 1966 c1 = FETCH_CHAR (temp_pos); | |
| 1967 temp_code = SYNTAX (c1); | |
| 1968 /* Don't allow comment-end to be quoted. */ | |
| 1969 if (temp_code == Sendcomment) | |
| 1970 goto done2; | |
| 1966 quoted = char_quoted (from - 1, temp_pos); | 1971 quoted = char_quoted (from - 1, temp_pos); |
| 1967 if (quoted) | 1972 if (quoted) |
| 1968 { | 1973 { |
| 1969 DEC_BOTH (from, from_byte); | 1974 DEC_BOTH (from, from_byte); |
| 1970 DEC_POS (temp_pos); | 1975 DEC_POS (temp_pos); |
