mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* regex.c (re_compile_pattern): fix [:name:] handling.
/[\[:digit:]]/ was treated as /[[:digit:]]/. /[[:-@]/ was treated as /[\[:\-@]/. /[%-[:digit:]]/ was treated as /[%-\[:digit:]\]/. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
313579f507
commit
576f18654d
2 changed files with 39 additions and 34 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Thu Mar 27 12:10:15 2003 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* regex.c (re_compile_pattern): fix [:name:] handling.
|
||||||
|
/[\[:digit:]]/ was treated as /[[:digit:]]/.
|
||||||
|
/[[:-@]/ was treated as /[\[:\-@]/.
|
||||||
|
/[%-[:digit:]]/ was treated as /[%-\[:digit:]\]/.
|
||||||
|
|
||||||
Thu Mar 27 03:26:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Thu Mar 27 03:26:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* string.c (rb_str_capitalize_bang): check length before upcase
|
* string.c (rb_str_capitalize_bang): check length before upcase
|
||||||
|
|
66
regex.c
66
regex.c
|
@ -1593,32 +1593,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (c == '[' && *p == ':') { /* [:...:] */
|
||||||
/* Get a range. */
|
|
||||||
if (range) {
|
|
||||||
if (last > c)
|
|
||||||
goto invalid_pattern;
|
|
||||||
|
|
||||||
range = 0;
|
|
||||||
if (had_mbchar == 0) {
|
|
||||||
for (;last<=c;last++)
|
|
||||||
SET_LIST_BIT(last);
|
|
||||||
}
|
|
||||||
else if (had_mbchar == 2) {
|
|
||||||
set_list_bits(last, c, b);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* restriction: range between sbc and mbc */
|
|
||||||
goto invalid_pattern;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (p[0] == '-' && p[1] != ']') {
|
|
||||||
last = c;
|
|
||||||
PATFETCH(c1);
|
|
||||||
range = 1;
|
|
||||||
goto range_retry;
|
|
||||||
}
|
|
||||||
else if (c == '[' && *p == ':') {
|
|
||||||
/* Leave room for the null. */
|
/* Leave room for the null. */
|
||||||
char str[CHAR_CLASS_MAX_LENGTH + 1];
|
char str[CHAR_CLASS_MAX_LENGTH + 1];
|
||||||
|
|
||||||
|
@ -1638,9 +1613,9 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
}
|
}
|
||||||
str[c1] = '\0';
|
str[c1] = '\0';
|
||||||
|
|
||||||
/* If isn't a word bracketed by `[:' and:`]':
|
/* If isn't a word bracketed by `[:' and `:]':
|
||||||
undo the ending character, the letters, and leave
|
undo the ending character, the letters, and
|
||||||
the leading `:' and `[' (but set bits for them). */
|
the leading `:' and `['. */
|
||||||
if (c == ':' && *p == ']') {
|
if (c == ':' && *p == ']') {
|
||||||
int ch;
|
int ch;
|
||||||
char is_alnum = STREQ(str, "alnum");
|
char is_alnum = STREQ(str, "alnum");
|
||||||
|
@ -1684,18 +1659,41 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
SET_LIST_BIT(ch);
|
SET_LIST_BIT(ch);
|
||||||
}
|
}
|
||||||
had_char_class = 1;
|
had_char_class = 1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c1++;
|
c1 += 2;
|
||||||
while (c1--)
|
while (c1--)
|
||||||
PATUNFETCH;
|
PATUNFETCH;
|
||||||
re_warning("character class has `[' without escape");
|
re_warning("character class has `[' without escape");
|
||||||
SET_LIST_BIT(TRANSLATE_P()?translate['[']:'[');
|
c = '[';
|
||||||
SET_LIST_BIT(TRANSLATE_P()?translate[':']:':');
|
|
||||||
had_char_class = 0;
|
|
||||||
last = ':';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get a range. */
|
||||||
|
if (range) {
|
||||||
|
if (last > c)
|
||||||
|
goto invalid_pattern;
|
||||||
|
|
||||||
|
range = 0;
|
||||||
|
if (had_mbchar == 0) {
|
||||||
|
for (;last<=c;last++)
|
||||||
|
SET_LIST_BIT(last);
|
||||||
|
}
|
||||||
|
else if (had_mbchar == 2) {
|
||||||
|
set_list_bits(last, c, b);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* restriction: range between sbc and mbc */
|
||||||
|
goto invalid_pattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (p[0] == '-' && p[1] != ']') {
|
||||||
|
last = c;
|
||||||
|
PATFETCH(c1);
|
||||||
|
range = 1;
|
||||||
|
goto range_retry;
|
||||||
|
}
|
||||||
else if (had_mbchar == 0 && (!current_mbctype || !had_num_literal)) {
|
else if (had_mbchar == 0 && (!current_mbctype || !had_num_literal)) {
|
||||||
SET_LIST_BIT(c);
|
SET_LIST_BIT(c);
|
||||||
had_num_literal = 0;
|
had_num_literal = 0;
|
||||||
|
|
Loading…
Reference in a new issue