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

ruby-changes:27931

From: usa <ko1@a...>
Date: Thu, 28 Mar 2013 18:57:59 +0900 (JST)
Subject: [ruby-changes:27931] usa:r39983 (ruby_1_9_3): * regcomp.c (optimize_node_left, set_optimize_info_from_tree): right

usa	2013-03-28 18:57:47 +0900 (Thu, 28 Mar 2013)

  New Revision: 39983

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

  Log:
    * regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
      handling for look behind anchor.
    
    * regexec.c (onig_search): ditto.
      [Backport #8076]
    
    this patch is derived from Onigmo base tree.

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/regcomp.c
    branches/ruby_1_9_3/regexec.c

Index: ruby_1_9_3/regcomp.c
===================================================================
--- ruby_1_9_3/regcomp.c	(revision 39982)
+++ ruby_1_9_3/regcomp.c	(revision 39983)
@@ -4735,6 +4735,7 @@ optimize_node_left(Node* node, NodeOptIn https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/regcomp.c#L4735
     case ANCHOR_END_BUF:
     case ANCHOR_SEMI_END_BUF:
     case ANCHOR_END_LINE:
+    case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */
       add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
       break;
 
@@ -4758,7 +4759,6 @@ optimize_node_left(Node* node, NodeOptIn https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/regcomp.c#L4759
       break;
 
     case ANCHOR_PREC_READ_NOT:
-    case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */
     case ANCHOR_LOOK_BEHIND_NOT:
       break;
     }
@@ -5010,7 +5010,8 @@ set_optimize_info_from_tree(Node* node, https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/regcomp.c#L5010
   if (r) return r;
 
   reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF |
-        ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML);
+        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);
 
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 39982)
+++ ruby_1_9_3/ChangeLog	(revision 39983)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Thu Mar 28 18:54:31 2013  NAKAMURA Usaku  <usa@r...>
+
+	* regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
+	  handling for look behind anchor.
+
+	* regexec.c (onig_search): ditto.
+	  [Backport #8076]
+
+	this patch is derived from Onigmo base tree.
+
 Thu Mar 28 18:35:01 2013  Luis Lavena  <luislavena@g...>
 
 	* win32/file.c (get_user_from_path):  add internal function that retrieves
Index: ruby_1_9_3/regexec.c
===================================================================
--- ruby_1_9_3/regexec.c	(revision 39982)
+++ ruby_1_9_3/regexec.c	(revision 39983)
@@ -3560,7 +3560,9 @@ onig_search(regex_t* reg, const UChar* s https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/regexec.c#L3560
       }
     }
     else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) {
-      goto begin_position;
+      if (!(reg->anchor & ANCHOR_LOOK_BEHIND)) {
+	goto begin_position;
+      }
     }
   }
   else if (str == end) { /* empty string */

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

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