summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-10 07:03:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-10 07:03:36 +0000
commit1ce6f065b519284a5ad7135a6db77fcbe1aa778a (patch)
tree79c663a365cc039f46e51658f288538eade86658 /re.c
parentef45458e9405c57ab4f59f648c4001ea4df30489 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/re.c b/re.c
index eeb89cf..a69cf1c 100644
--- a/re.c
+++ b/re.c
@@ -1038,7 +1038,7 @@ rb_reg_s_quote(argc, argv)
VALUE str, kcode;
int kcode_saved = reg_kcode;
char *s, *send, *t;
- char *tmp;
+ VALUE tmp;
int len;
rb_scan_args(argc, argv, "11", &str, &kcode);
@@ -1049,8 +1049,8 @@ rb_reg_s_quote(argc, argv)
}
s = rb_str2cstr(str, &len);
send = s + len;
- tmp = ALLOCA_N(char, len*2);
- t = tmp;
+ tmp = rb_str_new(0, len*2);
+ t = RSTRING(tmp)->ptr;
for (; s < send; s++) {
if (ismbchar(*s)) {
@@ -1073,8 +1073,9 @@ rb_reg_s_quote(argc, argv)
*t++ = *s;
}
kcode_reset_option();
+ rb_str_resize(tmp, t - RSTRING(tmp)->ptr);
- return rb_str_new(tmp, t - tmp);
+ return tmp;
}
int