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

ruby-changes:26262

From: usa <ko1@a...>
Date: Tue, 11 Dec 2012 19:17:23 +0900 (JST)
Subject: [ruby-changes:26262] usa:r38319 (ruby_1_9_3): merge revision(s) 38235: [Backport #7255]

usa	2012-12-11 19:17:13 +0900 (Tue, 11 Dec 2012)

  New Revision: 38319

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

  Log:
    merge revision(s) 38235: [Backport #7255]
    
    * parse.y (parser_here_document): flush string content between new
      line and :string_embexpr.  [ruby-core:48703] [Bug #7255]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/parse.y
    branches/ruby_1_9_3/test/ripper/test_scanner_events.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 38318)
+++ ruby_1_9_3/ChangeLog	(revision 38319)
@@ -1,3 +1,8 @@
+Tue Dec 11 19:15:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_here_document): flush string content between new
+	  line and :string_embexpr.  [ruby-core:48703] [Bug #7255]
+
 Tue Dec 11 19:01:45 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/erb.rb (ERB#run, ERB#result): eval under isolated bindings for
Index: ruby_1_9_3/parse.y
===================================================================
--- ruby_1_9_3/parse.y	(revision 38318)
+++ ruby_1_9_3/parse.y	(revision 38319)
@@ -5985,6 +5985,25 @@
 #define NEW_STRTERM(func, term, paren) \
 	rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
 
+#ifdef RIPPER
+static void
+ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc)
+{
+    if (!NIL_P(parser->delayed)) {
+	ptrdiff_t len = lex_p - parser->tokp;
+	if (len > 0) {
+	    rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc);
+	}
+	ripper_dispatch_delayed_token(parser, tSTRING_CONTENT);
+	parser->tokp = lex_p;
+    }
+}
+
+#define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
+#else
+#define flush_string_content(enc) ((void)(enc))
+#endif
+
 static int
 parser_parse_string(struct parser_params *parser, NODE *quote)
 {
@@ -6043,18 +6062,8 @@
 
     tokfix();
     set_yylval_str(STR_NEW3(tok(), toklen(), enc, func));
+    flush_string_content(enc);
 
-#ifdef RIPPER
-    if (!NIL_P(parser->delayed)) {
-	ptrdiff_t len = lex_p - parser->tokp;
-	if (len > 0) {
-	    rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc);
-	}
-	ripper_dispatch_delayed_token(parser, tSTRING_CONTENT);
-	parser->tokp = lex_p;
-    }
-#endif
-
     return tSTRING_CONTENT;
 }
 
@@ -6258,6 +6267,7 @@
 	    }
 	    if (c != '\n') {
 		set_yylval_str(STR_NEW3(tok(), toklen(), enc, func));
+		flush_string_content(enc);
 		return tSTRING_CONTENT;
 	    }
 	    tokadd(nextc());
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 38318)
+++ ruby_1_9_3/version.h	(revision 38319)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 337
+#define RUBY_PATCHLEVEL 338
 
 #define RUBY_RELEASE_DATE "2012-12-11"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/test/ripper/test_scanner_events.rb
===================================================================
--- ruby_1_9_3/test/ripper/test_scanner_events.rb	(revision 38318)
+++ ruby_1_9_3/test/ripper/test_scanner_events.rb	(revision 38319)
@@ -657,6 +657,13 @@
                  scan('tstring_content', "<<EOS\nhere\ndoc \nEOS \n")
     assert_equal ["heredoc\n\tEOS \n"],
                  scan('tstring_content', "<<-EOS\nheredoc\n\tEOS \n")
+    bug7255 = '[ruby-core:48703]'
+    assert_equal ["there\n""heredoc", "\n"],
+                 scan('tstring_content', "<<""EOS\n""there\n""heredoc\#{foo}\nEOS"),
+                 bug7255
+    assert_equal ["there\n""heredoc", "\n"],
+                 scan('tstring_content', "<<""EOS\n""there\n""heredoc\#@foo\nEOS"),
+                 bug7255
   end
 
   def test_heredoc_end

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r38235


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

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