summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-02 06:41:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-02 06:41:33 +0000
commit776e2693e738975b2bdbeb1ec43e4993a5520665 (patch)
tree7cfe6e46681a24e91c1cfa1d81a017eff06fcb1c /array.c
parentf701792f6f5d21a3762aec4a23a2b134e52ab94e (diff)
* string.c (rb_str_ljust): now takes optional argument to specify
pad string. [ruby-talk:70482] * string.c (rb_str_rjust): ditto. * string.c (rb_str_center): ditto. * string.c (rb_str_justify): utility function. * eval.c (rb_add_method): call singleton_method_added or method_added for every method definition (after ruby_running). [ruby-talk:70471] * array.c (rb_ary_reverse_bang): Array#reverse! should not return nil even for arrays sized less than 2. * io.c (argf_eof): should not block after reading all argument files. (ruby-bugs-ja PR#449) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/array.c b/array.c
index cecf427..8deeaf6 100644
--- a/array.c
+++ b/array.c
@@ -344,9 +344,6 @@ rb_ary_push_m(argc, argv, ary)
VALUE *argv;
VALUE ary;
{
- if (argc <= 0) {
- rb_raise(rb_eArgError, "wrong number arguments (at least 1)");
- }
while (argc--) {
rb_ary_push(ary, *argv++);
}
@@ -431,10 +428,6 @@ rb_ary_unshift_m(argc, argv, ary)
{
long len = RARRAY(ary)->len;
- if (argc <= 0) {
- rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
- }
-
/* make rooms by setting the last item */
rb_ary_store(ary, len + argc - 1, Qnil);
@@ -759,8 +752,8 @@ rb_ary_insert(argc, argv, ary)
{
long pos;
- if (argc < 2) {
- rb_raise(rb_eArgError, "wrong number of arguments (at least 2)");
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
}
pos = NUM2LONG(argv[0]);
if (pos == -1) {
@@ -770,6 +763,7 @@ rb_ary_insert(argc, argv, ary)
pos++;
}
+ if (argc == 1) return ary;
rb_ary_update(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
return ary;
}
@@ -1057,7 +1051,6 @@ static VALUE
rb_ary_reverse_bang(ary)
VALUE ary;
{
- if (RARRAY(ary)->len <= 1) return Qnil;
return rb_ary_reverse(ary);
}