* 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
This commit is contained in:
marcandre 2012-03-14 21:10:34 +00:00
parent 35c356ea72
commit 7316302483
20 changed files with 130 additions and 137 deletions

View file

@ -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));
}