summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-09 15:45:28 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-09 15:45:28 +0000
commit80d5af6a709260d563524329431004ef58b5b0e4 (patch)
tree967fe556afcd146d5d3d19595cc3ec505ecd7e44 /regex.c
parent43372b8fe973f6c85e83d750d6f845314cb6bdc2 (diff)
downloadruby-80d5af6a709260d563524329431004ef58b5b0e4.tar.gz
ruby-80d5af6a709260d563524329431004ef58b5b0e4.tar.xz
ruby-80d5af6a709260d563524329431004ef58b5b0e4.zip
* regex.c (re_compile_pattern): /[\--\-]/ was warned. warn /]/.
* mkconfig.rb: escape `]' in regexp. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/regex.c b/regex.c
index b7245d449..2e51365ec 100644
--- a/regex.c
+++ b/regex.c
@@ -1487,7 +1487,9 @@ re_compile_pattern(pattern, size, bufp)
}
had_char_class = 0;
- if (c == '-' && p != p0 + 1 && *p != ']')
+ if (c == '-' && ((p != p0 + 1 && *p != ']') ||
+ (p[0] == '-' && p[1] != ']') ||
+ range))
re_warning("character class has `-' without escape");
if (c == '[' && *p != ':')
re_warning("character class has `[' without escape");
@@ -1675,8 +1677,6 @@ re_compile_pattern(pattern, size, bufp)
if (last > c)
goto invalid_pattern;
- if (last == '-' || c == '-')
- re_warning("character class has `-' without escape");
range = 0;
if (had_mbchar == 0) {
for (;last<=c;last++)
@@ -2350,6 +2350,8 @@ re_compile_pattern(pattern, size, bufp)
break;
default:
+ if (c == ']')
+ re_warning("regexp has `]' without escape");
normal_char: /* Expects the character in `c'. */
had_mbchar = 0;
if (ismbchar(c)) {