diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-14 21:10:34 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-14 21:10:34 +0000 |
commit | 7316302483182a73136b00ad368585e551cbd86f (patch) | |
tree | d32188711001581a5e7e21d6669f6c4e91fcb497 /transcode.c | |
parent | 35c356ea72094dbbf1397d8f5acd065bd23d1177 (diff) |
* include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity
* class.c: ditto
* enumerator.c: ditto
* eval.c: ditto
* file.c: ditto
* hash.c: ditto
* numeric.c: ditto
* proc.c: ditto
* process.c: ditto
* random.c: ditto
* re.c: ditto
* signal.c: ditto
* string.c: ditto
* struct.c: ditto
* transcode.c: ditto
* vm_eval.c: ditto
* vm_insnhelper.c: ditto & implementation of rb_error_arity
* test/ruby/test_arity.rb: tests for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r-- | transcode.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/transcode.c b/transcode.c index ec5f93ce1e..c0049fd932 100644 --- a/transcode.c +++ b/transcode.c @@ -2665,9 +2665,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts) const char *sname, *dname; int dencidx; - if (argc <0 || argc > 2) { - rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc); - } + rb_check_arity(argc, 0, 2); if (argc == 0) { arg1 = rb_enc_default_internal(); @@ -2984,8 +2982,7 @@ econv_args(int argc, VALUE *argv, if (!NIL_P(flags_v)) { if (!NIL_P(opt)) { - rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..3)", - argc + 1); + rb_error_arity(argc + 1, 2, 3); } ecflags = NUM2INT(rb_to_int(flags_v)); ecopts = Qnil; @@ -3672,8 +3669,7 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self) if (!NIL_P(flags_v)) { if (!NIL_P(opt)) { - rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..5)", - argc + 1); + rb_error_arity(argc + 1, 2, 5); } flags = NUM2INT(rb_to_int(flags_v)); } |