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

ruby-changes:36592

From: nobu <ko1@a...>
Date: Tue, 2 Dec 2014 06:31:44 +0900 (JST)
Subject: [ruby-changes:36592] nobu:r48673 (trunk): parse.y: check single regexp only

nobu	2014-12-02 06:31:33 +0900 (Tue, 02 Dec 2014)

  New Revision: 48673

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

  Log:
    parse.y: check single regexp only
    
    * parse.y (regexp_contents): check in ripper only if the whole
      content is a single regexp without interpolation.
      [ruby-dev:48714] [Bug #10437]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48672)
+++ ChangeLog	(revision 48673)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec  2 06:31:31 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (regexp_contents): check in ripper only if the whole
+	  content is a single regexp without interpolation.
+	  [ruby-dev:48714] [Bug #10437]
+
 Tue Dec  2 06:30:55 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* re.c (rb_reg_region_copy): new function to try with GC if copy
Index: parse.y
===================================================================
--- parse.y	(revision 48672)
+++ parse.y	(revision 48673)
@@ -4259,7 +4259,7 @@ regexp_contents: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L4259
 			    $$ = list_append(head, tail);
 			}
 		    /*%
-		        VALUE s1 = 0, s2 = 0, n1 = $1, n2 = $2;
+		        VALUE s1 = 1, s2 = 0, n1 = $1, n2 = $2;
 			if (ripper_is_node_yylval(n1)) {
 			    s1 = RNODE(n1)->nd_cval;
 			    n1 = RNODE(n1)->nd_rval;
@@ -4269,9 +4269,8 @@ regexp_contents: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L4269
 			    n2 = RNODE(n2)->nd_rval;
 			}
 			$$ = dispatch2(regexp_add, n1, n2);
-			if (s1 || s2) {
-			    VALUE s = !s1 ? s2 : !s2 ? s1 : rb_str_plus(s1, s2);
-			    $$ = ripper_new_yylval(0, $$, s);
+			if (!s1 && s2) {
+			    $$ = ripper_new_yylval(0, $$, s2);
 			}
 		    %*/
 		    }

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

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