summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-16 17:37:34 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-16 17:37:34 +0000
commit12196ee24fce0e601106036e67526819cac07291 (patch)
treeae07656a3a4947347acbd875a9496430fecb6c77 /regex.c
parenta59f05a4559ac7634bf3c8f469af69ba18070751 (diff)
* regex.c (re_compile_pattern): should not translate character
class range edge. [ruby-list:38393] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/regex.c b/regex.c
index e9f382f0a4..fea8bf9f7e 100644
--- a/regex.c
+++ b/regex.c
@@ -1464,7 +1464,7 @@ re_compile_pattern(pattern, size, bufp)
if (range && had_char_class) {
FREE_AND_RETURN(stackb, "invalid regular expression; can't use character class as an end value of range");
}
- PATFETCH(c);
+ PATFETCH_RAW(c);
if (c == ']') {
if (p == p0 + 1) {
@@ -1608,7 +1608,7 @@ re_compile_pattern(pattern, size, bufp)
FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'");
for (;;) {
- PATFETCH (c);
+ PATFETCH_RAW(c);
if (c == ':' || c == ']' || p == pend
|| c1 == CHAR_CLASS_MAX_LENGTH)
break;
@@ -1680,8 +1680,14 @@ re_compile_pattern(pattern, size, bufp)
range = 0;
if (had_mbchar == 0) {
- for (;last<=c;last++)
- SET_LIST_BIT(last);
+ if (TRANSLATE_P()) {
+ for (;last<=c;last++)
+ SET_LIST_BIT(translate[last]);
+ }
+ else {
+ for (;last<=c;last++)
+ SET_LIST_BIT(last);
+ }
}
else if (had_mbchar == 2) {
set_list_bits(last, c, b);
@@ -1693,16 +1699,20 @@ re_compile_pattern(pattern, size, bufp)
}
else if (p[0] == '-' && p[1] != ']') {
last = c;
- PATFETCH(c1);
+ PATFETCH_RAW(c1);
range = 1;
goto range_retry;
}
- else if (had_mbchar == 0 && (!current_mbctype || !had_num_literal)) {
- SET_LIST_BIT(c);
- had_num_literal = 0;
+ else {
+ if (TRANSLATE_P()) c = (unsigned char)translate[c];
+ if (had_mbchar == 0 && (!current_mbctype || !had_num_literal)) {
+ SET_LIST_BIT(c);
+ had_num_literal = 0;
+ }
+ else {
+ set_list_bits(c, c, b);
+ }
}
- else
- set_list_bits(c, c, b);
had_mbchar = 0;
}