diff options
| author | Kenichi Handa | 2002-03-01 01:46:12 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-03-01 01:46:12 +0000 |
| commit | 9117d724bbbbf01bd039d891910f7a8ee79081a1 (patch) | |
| tree | 2d814efbda7640c5bee9f3557a2162faa284f7ba /src | |
| parent | 404061ebe66da4e7e8944c537de7628b0653c767 (diff) | |
| download | emacs-9117d724bbbbf01bd039d891910f7a8ee79081a1.tar.gz emacs-9117d724bbbbf01bd039d891910f7a8ee79081a1.zip | |
* regex.c: Include "character.h" instead of "charset.h".
(BYTE8_TO_CHAR, CHAR_BYTE8_P) [not emacs]: New dummy macros.
(regex_compile): Accept a range whose starting and ending
character have different leading bytes.
(analyse_first): Adjusted for the above change.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/src/regex.c b/src/regex.c index 37436fffba0..9974b2d41ec 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -125,7 +125,7 @@ | |||
| 125 | # define SYNTAX_ENTRY_VIA_PROPERTY | 125 | # define SYNTAX_ENTRY_VIA_PROPERTY |
| 126 | 126 | ||
| 127 | # include "syntax.h" | 127 | # include "syntax.h" |
| 128 | # include "charset.h" | 128 | # include "character.h" |
| 129 | # include "category.h" | 129 | # include "category.h" |
| 130 | 130 | ||
| 131 | # ifdef malloc | 131 | # ifdef malloc |
| @@ -246,6 +246,8 @@ enum syntaxcode { Swhitespace = 0, Sword = 1 }; | |||
| 246 | # define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ | 246 | # define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ |
| 247 | (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1))) | 247 | (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1))) |
| 248 | # define MAKE_CHAR(charset, c1, c2) (c1) | 248 | # define MAKE_CHAR(charset, c1, c2) (c1) |
| 249 | # define BYTE8_TO_CHAR(c) (c) | ||
| 250 | # define CHAR_BYTE8_P(c) (0) | ||
| 249 | #endif /* not emacs */ | 251 | #endif /* not emacs */ |
| 250 | 252 | ||
| 251 | #ifndef RE_TRANSLATE | 253 | #ifndef RE_TRANSLATE |
| @@ -2609,27 +2611,22 @@ regex_compile (pattern, size, syntax, bufp) | |||
| 2609 | /* Fetch the character which ends the range. */ | 2611 | /* Fetch the character which ends the range. */ |
| 2610 | PATFETCH (c1); | 2612 | PATFETCH (c1); |
| 2611 | 2613 | ||
| 2612 | if (SINGLE_BYTE_CHAR_P (c)) | 2614 | if (SINGLE_BYTE_CHAR_P (c) |
| 2615 | && ! SINGLE_BYTE_CHAR_P (c1)) | ||
| 2613 | { | 2616 | { |
| 2614 | if (! SINGLE_BYTE_CHAR_P (c1)) | 2617 | /* Handle a range starting with a character |
| 2615 | { | 2618 | fitting in a bitmap to a character not |
| 2616 | /* Handle a range starting with a | 2619 | fitting in a bitmap (thus require range |
| 2617 | character of less than 256, and ending | 2620 | table). We use both a bitmap (for the |
| 2618 | with a character of not less than 256. | 2621 | range from C to 255) and a range table (for |
| 2619 | Split that into two ranges, the low one | 2622 | the remaining range). Here, we setup only |
| 2620 | ending at 0377, and the high one | 2623 | a range table. A bitmap is setup later. */ |
| 2621 | starting at the smallest character in | 2624 | re_wchar_t c2 |
| 2622 | the charset of C1 and ending at C1. */ | 2625 | = CHAR_BYTE8_P (c1) ? BYTE8_TO_CHAR (0x80) : 256; |
| 2623 | int charset = CHAR_CHARSET (c1); | 2626 | |
| 2624 | int c2 = MAKE_CHAR (charset, 0, 0); | 2627 | SET_RANGE_TABLE_WORK_AREA (range_table_work, c2, c1); |
| 2625 | 2628 | c1 = 255; | |
| 2626 | SET_RANGE_TABLE_WORK_AREA (range_table_work, | ||
| 2627 | c2, c1); | ||
| 2628 | c1 = 0377; | ||
| 2629 | } | ||
| 2630 | } | 2629 | } |
| 2631 | else if (!SAME_CHARSET_P (c, c1)) | ||
| 2632 | FREE_STACK_RETURN (REG_ERANGE); | ||
| 2633 | } | 2630 | } |
| 2634 | else | 2631 | else |
| 2635 | /* Range from C to C. */ | 2632 | /* Range from C to C. */ |
| @@ -3555,7 +3552,7 @@ analyse_first (p, pend, fastmap, multibyte) | |||
| 3555 | set_fastmap_for_multibyte_characters: | 3552 | set_fastmap_for_multibyte_characters: |
| 3556 | if (match_any_multibyte_characters == false) | 3553 | if (match_any_multibyte_characters == false) |
| 3557 | { | 3554 | { |
| 3558 | for (j = 0x80; j < 0xA0; j++) /* XXX */ | 3555 | for (j = 0x80; j < 0x100; j++) /* XXX */ |
| 3559 | if (BASE_LEADING_CODE_P (j)) | 3556 | if (BASE_LEADING_CODE_P (j)) |
| 3560 | fastmap[j] = 1; | 3557 | fastmap[j] = 1; |
| 3561 | match_any_multibyte_characters = true; | 3558 | match_any_multibyte_characters = true; |
| @@ -3565,9 +3562,11 @@ analyse_first (p, pend, fastmap, multibyte) | |||
| 3565 | else if (!not && CHARSET_RANGE_TABLE_EXISTS_P (&p[-2]) | 3562 | else if (!not && CHARSET_RANGE_TABLE_EXISTS_P (&p[-2]) |
| 3566 | && match_any_multibyte_characters == false) | 3563 | && match_any_multibyte_characters == false) |
| 3567 | { | 3564 | { |
| 3568 | /* Set fastmap[I] 1 where I is a base leading code of each | 3565 | /* Set fastmap[I] to 1 where I is a base leading code of each |
| 3569 | multibyte character in the range table. */ | 3566 | multibyte characer in the range table. */ |
| 3570 | int c, count; | 3567 | int c, count; |
| 3568 | unsigned char buf1[MAX_MULTIBYTE_LENGTH]; | ||
| 3569 | unsigned char buf2[MAX_MULTIBYTE_LENGTH]; | ||
| 3571 | 3570 | ||
| 3572 | /* Make P points the range table. `+ 2' is to skip flag | 3571 | /* Make P points the range table. `+ 2' is to skip flag |
| 3573 | bits for a character class. */ | 3572 | bits for a character class. */ |
| @@ -3577,10 +3576,14 @@ analyse_first (p, pend, fastmap, multibyte) | |||
| 3577 | EXTRACT_NUMBER_AND_INCR (count, p); | 3576 | EXTRACT_NUMBER_AND_INCR (count, p); |
| 3578 | for (; count > 0; count--, p += 2 * 3) /* XXX */ | 3577 | for (; count > 0; count--, p += 2 * 3) /* XXX */ |
| 3579 | { | 3578 | { |
| 3580 | /* Extract the start of each range. */ | 3579 | /* Extract the start and end of each range. */ |
| 3580 | EXTRACT_CHARACTER (c, p); | ||
| 3581 | CHAR_STRING (c, buf1); | ||
| 3582 | p += 3; | ||
| 3581 | EXTRACT_CHARACTER (c, p); | 3583 | EXTRACT_CHARACTER (c, p); |
| 3582 | j = CHAR_CHARSET (c); | 3584 | CHAR_STRING (c, buf2); |
| 3583 | fastmap[CHARSET_LEADING_CODE_BASE (j)] = 1; | 3585 | for (j = buf1[0]; j <= buf2[0]; j++) |
| 3586 | fastmap[j] = 1; | ||
| 3584 | } | 3587 | } |
| 3585 | } | 3588 | } |
| 3586 | break; | 3589 | break; |