summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-11-25 08:01:41 +0900
committerGitHub <[email protected]>2016-11-25 08:01:41 +0900
commitb4d501750cc5c98ed0a04f56d5eb95fb178bcca3 (patch)
treeebf09e0708230bd6298ead4a6c6c8136d497d520 /src
parent54921aa671f91d24e4025c0a54b4c622fc2f6db2 (diff)
parent76a1bdfa29469576112a41b78a132b785616a3f9 (diff)
downloadmruby-b4d501750cc5c98ed0a04f56d5eb95fb178bcca3.tar.gz
mruby-b4d501750cc5c98ed0a04f56d5eb95fb178bcca3.zip
Merge pull request #3288 from bouk/chomp-bang-len
Get String length after args in String#chomp!
Diffstat (limited to 'src')
-rw-r--r--src/string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index 5e490bf03..f47294291 100644
--- a/src/string.c
+++ b/src/string.c
@@ -1235,11 +1235,13 @@ mrb_str_chomp_bang(mrb_state *mrb, mrb_value str)
char *p, *pp;
mrb_int rslen;
mrb_int len;
+ mrb_int argc;
struct RString *s = mrb_str_ptr(str);
mrb_str_modify(mrb, s);
+ argc = mrb_get_args(mrb, "|S", &rs);
len = RSTR_LEN(s);
- if (mrb_get_args(mrb, "|S", &rs) == 0) {
+ if (argc == 0) {
if (len == 0) return mrb_nil_value();
smart_chomp:
if (RSTR_PTR(s)[len-1] == '\n') {