Bug #2052 [ruby-core:25411]

Regexp Equality When Multiple Encoding Options Are Present

Added by Run Paint Run Run 327 days ago. Updated 275 days ago.

Status :Closed Start :09/06/2009
Priority :Low Due date :
Assigned to :- % 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

09/07/2009 12:44 AM - Yui NARUSE

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();

10/28/2009 03:23 AM - Yui NARUSE

  • Status changed from Open to Closed
this is implemented.

Also available in: Atom PDF