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

ruby-changes:33318

From: nobu <ko1@a...>
Date: Mon, 24 Mar 2014 22:20:02 +0900 (JST)
Subject: [ruby-changes:33318] nobu:r45397 (trunk): parse.y: freeze filename

nobu	2014-03-24 22:19:57 +0900 (Mon, 24 Mar 2014)

  New Revision: 45397

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

  Log:
    parse.y: freeze filename
    
    * parse.y (ripper_initialize): filename can not be modified.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ripper/test_ripper.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45396)
+++ ChangeLog	(revision 45397)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Mar 24 22:19:56 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (ripper_initialize): filename can not be modified.
+
 Mon Mar 24 15:19:47 2014  NARUSE, Yui  <naruse@r...>
 
 	* addr2line.c (rb_dump_backtrace_with_lines): fetch path of the
Index: parse.y
===================================================================
--- parse.y	(revision 45396)
+++ parse.y	(revision 45397)
@@ -11445,9 +11445,11 @@ ripper_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/parse.y#L11445
     parser->eofp = Qfalse;
     if (NIL_P(fname)) {
         fname = STR_NEW2("(ripper)");
+	OBJ_FREEZE(fname);
     }
     else {
         StringValue(fname);
+	fname = rb_str_new_frozen(fname);
     }
     parser_initialize(parser);
 
Index: test/ripper/test_ripper.rb
===================================================================
--- test/ripper/test_ripper.rb	(revision 45396)
+++ test/ripper/test_ripper.rb	(revision 45397)
@@ -26,6 +26,10 @@ class TestRipper::Ripper < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ripper/test_ripper.rb#L26
 
   def test_filename
     assert_equal '(ripper)', @ripper.filename
+    filename = "ripper"
+    ripper = Ripper.new("", filename)
+    filename.clear
+    assert_equal "ripper", ripper.filename
   end
 
   def test_lineno

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

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