summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-16 23:28:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-16 23:28:31 +0000
commit25fd1d7ff2de52b8670b50be68a5d09a5ddedd38 (patch)
tree3f9afe4bebd166e30e9f9c73cada34d2a51a6b7b /re.c
parentae8463b03c8882da342f0d4318175ab950280f0b (diff)
* object.c (rb_class_allocate_instance): singleton class check
moved to rb_obj_alloc(). (ruby-bugs-ja PR#345) * re.c (rb_reg_quote): should escape white space characters, \t, \f, \n, \r. (ruby-bugs-ja PR#231) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/re.c b/re.c
index 6d08fb81a1..29e2b94e09 100644
--- a/re.c
+++ b/re.c
@@ -1349,6 +1349,7 @@ rb_reg_quote(str)
case '*': case '.': case '\\':
case '?': case '+': case '^': case '$':
case ' ': case '#':
+ case '\t': case '\f': case '\n': case '\r':
goto meta_found;
}
}
@@ -1376,8 +1377,28 @@ rb_reg_quote(str)
case '(': case ')': case '|': case '-':
case '*': case '.': case '\\':
case '?': case '+': case '^': case '$':
- case ' ': case '#':
+ case '#':
+ *t++ = '\\';
+ break;
+ case ' ':
+ *t++ = '\\';
+ *t++ = 's';
+ break;
+ case '\t':
+ *t++ = '\\';
+ *t++ = 't';
+ break;
+ case '\n':
+ *t++ = '\\';
+ *t++ = 'n';
+ break;
+ case '\r':
+ *t++ = '\\';
+ *t++ = 'r';
+ break;
+ case '\f':
*t++ = '\\';
+ *t++ = 'f';
break;
}
*t++ = c;