summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-28 14:42:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-28 14:42:46 +0000
commitf0221db4626bb589f230bf239a7f9df83d7e444f (patch)
tree0bd6a2a6dde695b2ac3cf1193419676a78f914b9 /re.c
parentee852ed46d1a2a0f894e20e939b079c31e1cdb4b (diff)
downloadruby-f0221db4626bb589f230bf239a7f9df83d7e444f.tar.gz
* re.c (rb_reg_expr_str): need to process backslashes properly.
* object.c (rb_any_to_a): declare Object#to_a to be obsolete. * object.c (rb_Array): do not convert nil into [] automagically. * object.c (rb_Integer): use "to_int" instead of "to_i". [experimental] * object.c (nil_to_f): new method. * object.c (rb_Integer): Symbols and nil should cause error. * object.c (rb_Float): nil should cause error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/re.c b/re.c
index 6f7967ae65..0cb048be27 100644
--- a/re.c
+++ b/re.c
@@ -236,7 +236,14 @@ rb_reg_expr_str(str, s, len)
else {
p = s;
while (p<pend) {
- if (*p == '/' && (s == p || p[-1] != '\\')) {
+ if (*p == '\\') {
+ rb_str_buf_cat(str, p, 1);
+ p++;
+ rb_str_buf_cat(str, p, mbclen(*p));
+ p += mbclen(*p);
+ continue;
+ }
+ else if (*p == '/') {
char c = '\\';
rb_str_buf_cat(str, &c, 1);
rb_str_buf_cat(str, p, 1);
@@ -244,6 +251,7 @@ rb_reg_expr_str(str, s, len)
else if (ismbchar(*p)) {
rb_str_buf_cat(str, p, mbclen(*p));
p += mbclen(*p);
+ need_escape = 1;
continue;
}
else if (ISPRINT(*p)) {