summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-18 06:59:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-18 06:59:36 +0000
commit3d6fde336547463461180b9be5b1730194764d9c (patch)
treec268af56267dcc487f65cec821380293b37f4749 /class.c
parentf0886df4a4d017ed3655b1e1a4a4df2ebaa8c71e (diff)
2000-02-18
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/class.c b/class.c
index 19171d7..19f700b 100644
--- a/class.c
+++ b/class.c
@@ -598,19 +598,13 @@ rb_scan_args(argc, argv, fmt, va_alist)
va_dcl
#endif
{
- int n, i;
+ int n, i = 0;
const char *p = fmt;
VALUE *var;
va_list vargs;
va_init_list(vargs, fmt);
- if (*p == '*') {
- var = va_arg(vargs, VALUE*);
- *var = rb_ary_new4(argc, argv);
- return argc;
- }
-
if (ISDIGIT(*p)) {
n = *p - '0';
if (n > argc)
@@ -643,21 +637,34 @@ rb_scan_args(argc, argv, fmt, va_alist)
var = va_arg(vargs, VALUE*);
if (argc > i) {
if (var) *var = rb_ary_new4(argc-i, argv+i);
+ i = argc;
}
else {
if (var) *var = rb_ary_new();
}
+ p++;
}
- else if (*p == '\0') {
- if (argc > i) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
+
+ if (*p == '&') {
+ var = va_arg(vargs, VALUE*);
+ if (rb_iterator_p()) {
+ *var = rb_f_lambda();
+ }
+ else {
+ *var = Qnil;
}
+ p++;
}
- else {
+ va_end(vargs);
+
+ if (*p != '\0') {
goto error;
}
- va_end(vargs);
+ if (argc > i) {
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
+ }
+
return argc;
error: