summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-03 10:22:38 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-04-03 10:22:38 +0900
commitd27a3d47cdd114cfcf450bf4d54664430dfce29d (patch)
tree44151682b4cee25c614f46cc0c6e99713f3ccefd /src/string.c
parenta14a930c800aa50a191922580d53a2ce09287912 (diff)
downloadmruby-d27a3d47cdd114cfcf450bf4d54664430dfce29d.tar.gz
mruby-d27a3d47cdd114cfcf450bf4d54664430dfce29d.zip
String#initialize to make a string empty; ref #3574
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/string.c b/src/string.c
index c36b7524a..11abdc051 100644
--- a/src/string.c
+++ b/src/string.c
@@ -1665,9 +1665,11 @@ mrb_str_init(mrb_state *mrb, mrb_value self)
{
mrb_value str2;
- if (mrb_get_args(mrb, "|S", &str2) == 1) {
- str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
+ if (mrb_get_args(mrb, "|S", &str2) == 0) {
+ struct RString *s = str_new(mrb, 0, 0);
+ str2 = mrb_obj_value(s);
}
+ str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
return self;
}