aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-03-23 05:44:14 +0000
committerKenichi Handa2007-03-23 05:44:14 +0000
commit6482db2eb982c10a91d875719ed5de4d1d994065 (patch)
treeac0cd27c72e355cd0f28c2ebf18e69ba6ff6afae /src
parentd85d38392e338f66053a6a6f1017720660239338 (diff)
downloademacs-6482db2eb982c10a91d875719ed5de4d1d994065.tar.gz
emacs-6482db2eb982c10a91d875719ed5de4d1d994065.zip
(analyse_first): Fix for multibyte characters in "case
charset:" and "case categoryspec:".
Diffstat (limited to 'src')
-rw-r--r--src/regex.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/regex.c b/src/regex.c
index 4fbd80232c6..81c37730a9a 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -4103,17 +4103,21 @@ analyse_first (p, pend, fastmap, multibyte)
4103 if (!!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) ^ not) 4103 if (!!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) ^ not)
4104 fastmap[j] = 1; 4104 fastmap[j] = 1;
4105 4105
4106 if ((not && multibyte) 4106#ifdef emacs
4107 /* Any leading code can possibly start a character 4107 if (/* Any leading code can possibly start a character
4108 which doesn't match the specified set of characters. */ 4108 which doesn't match the specified set of characters. */
4109 || (CHARSET_RANGE_TABLE_EXISTS_P (&p[-2]) 4109 not
4110 && CHARSET_RANGE_TABLE_BITS (&p[-2]) != 0)) 4110 ||
4111 /* If we can match a character class, we can match 4111 /* If we can match a character class, we can match any
4112 any multibyte characters. */ 4112 multibyte characters. */
4113 (CHARSET_RANGE_TABLE_EXISTS_P (&p[-2])
4114 && CHARSET_RANGE_TABLE_BITS (&p[-2]) != 0))
4115
4113 { 4116 {
4114 if (match_any_multibyte_characters == false) 4117 if (match_any_multibyte_characters == false)
4115 { 4118 {
4116 for (j = 0x80; j < (1 << BYTEWIDTH); j++) 4119 for (j = MIN_MULTIBYTE_LEADING_CODE;
4120 j <= MAX_MULTIBYTE_LEADING_CODE; j++)
4117 fastmap[j] = 1; 4121 fastmap[j] = 1;
4118 match_any_multibyte_characters = true; 4122 match_any_multibyte_characters = true;
4119 } 4123 }
@@ -4145,6 +4149,7 @@ analyse_first (p, pend, fastmap, multibyte)
4145 fastmap[j] = 1; 4149 fastmap[j] = 1;
4146 } 4150 }
4147 } 4151 }
4152#endif
4148 break; 4153 break;
4149 4154
4150 case syntaxspec: 4155 case syntaxspec:
@@ -4167,20 +4172,18 @@ analyse_first (p, pend, fastmap, multibyte)
4167 if (!fastmap) break; 4172 if (!fastmap) break;
4168 not = (re_opcode_t)p[-1] == notcategoryspec; 4173 not = (re_opcode_t)p[-1] == notcategoryspec;
4169 k = *p++; 4174 k = *p++;
4170 for (j = (multibyte ? 127 : (1 << BYTEWIDTH)); j >= 0; j--) 4175 for (j = (1 << BYTEWIDTH); j >= 0; j--)
4171 if ((CHAR_HAS_CATEGORY (j, k)) ^ not) 4176 if ((CHAR_HAS_CATEGORY (j, k)) ^ not)
4172 fastmap[j] = 1; 4177 fastmap[j] = 1;
4173 4178
4174 if (multibyte) 4179 /* Any leading code can possibly start a character which
4180 has or doesn't has the specified category. */
4181 if (match_any_multibyte_characters == false)
4175 { 4182 {
4176 /* Any character set can possibly contain a character 4183 for (j = MIN_MULTIBYTE_LEADING_CODE;
4177 whose category is K (or not). */ 4184 j <= MAX_MULTIBYTE_LEADING_CODE; j++)
4178 if (match_any_multibyte_characters == false) 4185 fastmap[j] = 1;
4179 { 4186 match_any_multibyte_characters = true;
4180 for (j = 0x80; j < (1 << BYTEWIDTH); j++)
4181 fastmap[j] = 1;
4182 match_any_multibyte_characters = true;
4183 }
4184 } 4187 }
4185 break; 4188 break;
4186 4189