[前][次][番号順一覧][スレッド一覧]

ruby-changes:35895

From: usa <ko1@a...>
Date: Thu, 16 Oct 2014 16:36:02 +0900 (JST)
Subject: [ruby-changes:35895] usa:r47976 (ruby_2_0_0): * regcomp.c, regexec.c: Optimization should be disabled not only for

usa	2014-10-16 16:35:51 +0900 (Thu, 16 Oct 2014)

  New Revision: 47976

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47976

  Log:
    * regcomp.c, regexec.c: Optimization should be disabled not only for
      /(?<=x).*/ but also for /(?!x).*/.
      (merge r47598 partially. [Bug #9728])

  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/regcomp.c
    branches/ruby_2_0_0/regexec.c
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/regcomp.c
===================================================================
--- ruby_2_0_0/regcomp.c	(revision 47975)
+++ ruby_2_0_0/regcomp.c	(revision 47976)
@@ -4495,6 +4495,9 @@ concat_opt_anc_info(OptAncInfo* to, OptA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regcomp.c#L4495
   if (right_len == 0) {
     to->right_anchor |= left->right_anchor;
   }
+  else {
+    to->right_anchor |= (left->right_anchor & ANCHOR_PREC_READ_NOT);
+  }
 }
 
 static int
@@ -5068,7 +5071,8 @@ optimize_node_left(Node* node, NodeOptIn https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regcomp.c#L5071
     case ANCHOR_END_BUF:
     case ANCHOR_SEMI_END_BUF:
     case ANCHOR_END_LINE:
-    case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */
+    case ANCHOR_LOOK_BEHIND:   /* just for (?<=x).* */
+    case ANCHOR_PREC_READ_NOT: /* just for (?!x).* */
       add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
       break;
 
@@ -5091,7 +5095,6 @@ optimize_node_left(Node* node, NodeOptIn https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regcomp.c#L5095
       }
       break;
 
-    case ANCHOR_PREC_READ_NOT:
     case ANCHOR_LOOK_BEHIND_NOT:
       break;
     }
@@ -5357,7 +5360,8 @@ set_optimize_info_from_tree(Node* node, https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regcomp.c#L5360
         ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML |
         ANCHOR_LOOK_BEHIND);
 
-  reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF);
+  reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF |
+       ANCHOR_PREC_READ_NOT);
 
   if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) {
     reg->anchor_dmin = opt.len.min;
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 47975)
+++ ruby_2_0_0/ChangeLog	(revision 47976)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Thu Oct 16 16:33:51 2014  NAKAMURA Usaku  <usa@r...>
+
+	* regcomp.c, regexec.c: Optimization should be disabled not only for
+	  /(?<=x).*/ but also for /(?!x).*/.
+	  (merge r47598 partially. [Bug #9728])
+
 Thu Oct 16 16:23:03 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* lib/fileutils.rb: handle ENOENT error with symlink targeted to
Index: ruby_2_0_0/regexec.c
===================================================================
--- ruby_2_0_0/regexec.c	(revision 47975)
+++ ruby_2_0_0/regexec.c	(revision 47976)
@@ -4157,7 +4157,7 @@ onig_search_gpos(regex_t* reg, const UCh https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/regexec.c#L4157
             prev = s;
             s += enclen(reg->enc, s, end);
 
-            if ((reg->anchor & ANCHOR_LOOK_BEHIND) == 0) {
+            if ((reg->anchor & (ANCHOR_LOOK_BEHIND | ANCHOR_PREC_READ_NOT)) == 0) {
               while (!ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 0)
                      && s < range) {
                 prev = s;
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 47975)
+++ ruby_2_0_0/version.h	(revision 47976)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-10-16"
-#define RUBY_PATCHLEVEL 586
+#define RUBY_PATCHLEVEL 587
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 10

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]