diff options
| author | Karl Heuer | 1998-11-10 07:03:05 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-11-10 07:03:05 +0000 |
| commit | 3583e969a48791902885423e6c519df329bcebc8 (patch) | |
| tree | 369b8aae510e6cd8d33209f6986082e440dba7f0 /src | |
| parent | c61bca6a2858108256801abf8f87caaa3cee1116 (diff) | |
| download | emacs-3583e969a48791902885423e6c519df329bcebc8.tar.gz emacs-3583e969a48791902885423e6c519df329bcebc8.zip | |
(regex_compile): Handle translation of multibyte
exact-match characters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/regex.c b/src/regex.c index cf89000df11..0dcdedec517 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -2903,8 +2903,12 @@ regex_compile (pattern, size, syntax, bufp) | |||
| 2903 | p1 = p - 1; /* P1 points the head of C. */ | 2903 | p1 = p - 1; /* P1 points the head of C. */ |
| 2904 | #ifdef emacs | 2904 | #ifdef emacs |
| 2905 | if (bufp->multibyte) | 2905 | if (bufp->multibyte) |
| 2906 | /* Set P to the next character boundary. */ | 2906 | { |
| 2907 | p += MULTIBYTE_FORM_LENGTH (p1, pend - p1) - 1; | 2907 | c = STRING_CHAR (p1, pend - p1); |
| 2908 | c = TRANSLATE (c); | ||
| 2909 | /* Set P to the next character boundary. */ | ||
| 2910 | p += MULTIBYTE_FORM_LENGTH (p1, pend - p1) - 1; | ||
| 2911 | } | ||
| 2908 | #endif | 2912 | #endif |
| 2909 | /* If no exactn currently being built. */ | 2913 | /* If no exactn currently being built. */ |
| 2910 | if (!pending_exact | 2914 | if (!pending_exact |
| @@ -2933,16 +2937,23 @@ regex_compile (pattern, size, syntax, bufp) | |||
| 2933 | pending_exact = b - 1; | 2937 | pending_exact = b - 1; |
| 2934 | } | 2938 | } |
| 2935 | 2939 | ||
| 2936 | /* Here, C may translated, therefore C may not equal to *P1. */ | 2940 | #ifdef emacs |
| 2937 | while (1) | 2941 | if (! SINGLE_BYTE_CHAR_P (c)) |
| 2942 | { | ||
| 2943 | unsigned char work[4], *str; | ||
| 2944 | int i = CHAR_STRING (c, work, str); | ||
| 2945 | int j; | ||
| 2946 | for (j = 0; j < i; j++) | ||
| 2947 | { | ||
| 2948 | BUF_PUSH (str[j]); | ||
| 2949 | (*pending_exact)++; | ||
| 2950 | } | ||
| 2951 | } | ||
| 2952 | else | ||
| 2953 | #endif | ||
| 2938 | { | 2954 | { |
| 2939 | BUF_PUSH (c); | 2955 | BUF_PUSH (c); |
| 2940 | (*pending_exact)++; | 2956 | (*pending_exact)++; |
| 2941 | if (++p1 == p) | ||
| 2942 | break; | ||
| 2943 | |||
| 2944 | /* Rest of multibyte form should be copied literally. */ | ||
| 2945 | c = *(unsigned char *)p1; | ||
| 2946 | } | 2957 | } |
| 2947 | break; | 2958 | break; |
| 2948 | } /* switch (c) */ | 2959 | } /* switch (c) */ |