summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-14 15:38:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-14 15:56:37 +0900
commit9bc815aa5fd14f26d62ff1d6189157d7f09e23cb (patch)
treec6938973e9c20f90d11518ba588a0759db179f1f /class.c
parent0742585e7eaf9ccc292cc077caa38f7cf584de9e (diff)
Hoisted out `rb_scan_args_result`
Diffstat (limited to 'class.c')
-rw-r--r--class.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/class.c b/class.c
index c2abce1..f181f33 100644
--- a/class.c
+++ b/class.c
@@ -2079,6 +2079,15 @@ rb_scan_args_assign(const struct rb_scan_args_t *arg, int argc, const VALUE *con
return argc;
}
+static int
+rb_scan_args_result(const struct rb_scan_args_t *const arg, int argc)
+{
+ if (argc < 0) {
+ rb_error_arity(-1-argc, arg->n_mand, arg->f_var ? UNLIMITED_ARGUMENTS : arg->n_mand + arg->n_opt);
+ }
+ return argc;
+}
+
#undef rb_scan_args
int
rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
@@ -2089,10 +2098,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
va_start(vargs,fmt);
argc = rb_scan_args_assign(&arg, argc, argv, vargs);
va_end(vargs);
- if (argc < 0) {
- rb_error_arity(-1-argc, arg.n_mand, arg.f_var ? UNLIMITED_ARGUMENTS : arg.n_mand + arg.n_opt);
- }
- return argc;
+ return rb_scan_args_result(&arg, argc);
}
#undef rb_scan_args_kw
@@ -2105,10 +2111,7 @@ rb_scan_args_kw(int kw_flag, int argc, const VALUE *argv, const char *fmt, ...)
va_start(vargs,fmt);
argc = rb_scan_args_assign(&arg, argc, argv, vargs);
va_end(vargs);
- if (argc < 0) {
- rb_error_arity(-1-argc, arg.n_mand, arg.f_var ? UNLIMITED_ARGUMENTS : arg.n_mand + arg.n_opt);
- }
- return argc;
+ return rb_scan_args_result(&arg, argc);
}
int