Bug #2052

Regexp Equality When Multiple Encoding Options Are Present

Added by Run Paint Run Run over 2 years ago. Updated 9 months ago.

[ruby-core:25411]
Status:Closed Start date:09/06/2009
Priority:Low Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
ruby -v:ruby 1.9.2dev (2009-09-05 trunk 24754) [i686-linux]

Description

$ cat /tmp/r.rb 
  # Options include 'n'
  p /foo/esnuesues == /foo/s
  # Options don't include 'n'
  p /foo/esuesues == /foo/s

1.8:

  $ ruby8 /tmp/r.rb 
  true
  true

1.9:

  $ ruby /tmp/r.rb 
  false
  true

Is this intentional? Is 'n' the exception to the rule that all but the last encoding specifier are ignored?

History

Updated by Yui NARUSE over 2 years ago

diff --git a/parse.y b/parse.y
index 754b363..85b7e79 100644
--- a/parse.y
+++ b/parse.y
@@ -5588,6 +5588,7 @@ static int
 parser_regx_options(struct parser_params *parser)
 {
     int kcode = 0;
+    int kopt = 0;
     int options = 0;
     int c, opt, kc;

@@ -5597,13 +5598,14 @@ parser_regx_options(struct parser_params *parser)
             options |= RE_OPTION_ONCE;
         }
         else if (rb_char_to_option_kcode(c, &opt, &kc)) {
-            options |= opt;
+            kopt = opt;
            if (kc >= 0) kcode = c;
         }
         else {
            tokadd(c);
         }
     }
+    options |= kopt;
     pushback(c);
     if (toklen()) {
        tokfix();

Updated by Yui NARUSE over 2 years ago

  • Status changed from Open to Closed
this is implemented.

Also available in: Atom PDF