diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-25 04:38:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-25 04:38:42 +0000 |
commit | 8bf7568f3d30b5b22968ed0ba7463e78e1dad72b (patch) | |
tree | 380e68c3277b995f38e425e54c31424cfc6224d3 /re.c | |
parent | 6a5aa582afd4cf9d627502fd4563a765c7274479 (diff) | |
download | ruby-8bf7568f3d30b5b22968ed0ba7463e78e1dad72b.tar.gz ruby-8bf7568f3d30b5b22968ed0ba7463e78e1dad72b.tar.xz ruby-8bf7568f3d30b5b22968ed0ba7463e78e1dad72b.zip |
* re.c (rb_reg_options_m): use rb_reg_options() to mask internal
flags.
* re.c (rb_reg_initialize_m): allow nil as third argument and
ignore, and mask code flags if the argument is given.
[ruby-dev:20885]
* re.c (rb_reg_options): get common flags directly.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -502,8 +502,8 @@ static VALUE rb_reg_options_m(re) VALUE re; { - rb_reg_check(re); - return INT2NUM(RREGEXP(re)->ptr->options); + int options = rb_reg_options(re); + return INT2NUM(options); } static VALUE @@ -1303,9 +1303,10 @@ rb_reg_initialize_m(argc, argv, self) if (FIXNUM_P(argv[1])) flags = FIX2INT(argv[1]); else if (RTEST(argv[1])) flags = RE_OPTION_IGNORECASE; } - if (argc == 3) { + if (argc == 3 && !NIL_P(argv[2])) { char *kcode = StringValuePtr(argv[2]); + flags &= ~0x70; switch (kcode[0]) { case 'n': case 'N': flags |= 16; @@ -1471,15 +1472,11 @@ int rb_reg_options(re) VALUE re; { - int options = 0; + int options; rb_reg_check(re); - if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE) - options |= RE_OPTION_IGNORECASE; - if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE) - options |= RE_OPTION_MULTILINE; - if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED) - options |= RE_OPTION_EXTENDED; + options = RREGEXP(re)->ptr->options & + (RE_OPTION_IGNORECASE|RE_OPTION_MULTILINE|RE_OPTION_EXTENDED); if (FL_TEST(re, KCODE_FIXED)) { options |= rb_reg_get_kcode(re); } |