diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-05-24 16:51:15 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-06-20 19:35:12 +0900 |
commit | ab2a43265cfdda288d1baaa29936fd408c2a42bc (patch) | |
tree | f70d3b5b1c9ddb1c8a259642f9ede21a25afc173 /re.c | |
parent | a58611dfb1bfc74fb1a51a9cd0ca8ac690c2f1f4 (diff) | |
download | ruby-ab2a43265cfdda288d1baaa29936fd408c2a42bc.tar.gz |
Warn suspicious flag to `Regexp.new`
Now second argument should be `true`, `false`, `nil` or Integer.
This flag is confused with third argument some times.
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -20,6 +20,7 @@ #include "internal/imemo.h" #include "internal/re.h" #include "internal/string.h" +#include "internal/object.h" #include "internal/ractor.h" #include "internal/variable.h" #include "regint.h" @@ -3716,7 +3717,8 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self) else { if (opts != Qundef) { if (FIXNUM_P(opts)) flags = FIX2INT(opts); - else if (RTEST(opts)) flags = ONIG_OPTION_IGNORECASE; + else if (!NIL_P(opts) && rb_bool_expected(opts, "ignorecase", FALSE)) + flags = ONIG_OPTION_IGNORECASE; } if (n_flag != Qundef && !NIL_P(n_flag)) { char *kcode = StringValuePtr(n_flag); |