From b14957f31fc72a8b69394fc3bccc8df1baf22498 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 14 Feb 2020 15:59:36 +0900 Subject: [PATCH] Prefer keyword arguments --- ext/io/console/console.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/io/console/console.c b/ext/io/console/console.c index bfba1e7..1b899af 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -111,6 +111,11 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t * int argc = *argcp; rawmode_arg_t *optp = NULL; VALUE vopts = Qnil; +#ifdef RB_SCAN_ARGS_PASS_CALLED_KEYWORDS + if (argc > 0) { + argc = rb_scan_args(argc, argv, "*:", NULL, &vopts); + } +#else if (argc > min_argc) { vopts = rb_check_hash_type(argv[argc-1]); if (!NIL_P(vopts)) { @@ -120,6 +125,7 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t * if (!vopts) vopts = Qnil; } } +#endif rb_check_arity(argc, min_argc, max_argc); if (!NIL_P(vopts)) { VALUE vmin = rb_hash_aref(vopts, ID2SYM(id_min));