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

ruby-changes:12527

From: keiju <ko1@a...>
Date: Wed, 22 Jul 2009 00:40:17 +0900 (JST)
Subject: [ruby-changes:12527] Ruby:r24229 (trunk): * lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add

keiju	2009-07-22 00:39:51 +0900 (Wed, 22 Jul 2009)

  New Revision: 24229

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

  Log:
     * lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
       IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb/ext/save-history.rb
    trunk/lib/irb/init.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24228)
+++ ChangeLog	(revision 24229)
@@ -1,3 +1,8 @@
+Wed Jul 22 00:34:39 2009  Keiju Ishitsuka  <keiju@r...>
+
+	* lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
+	  IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]
+
 Tue Jul 21 23:47:38 2009  Yusuke Endoh  <mame@t...>
 
 	* random.c (rand_init): array length of random seed was broken, which
@@ -5,11 +10,11 @@
 
 	* test/ruby/test_rand.c: test for above.
 
-Tue Jul 21 21:37:19 2009  Keiju Ishitsuka  <keiju@e...>
+Tue Jul 21 21:37:19 2009  Keiju Ishitsuka  <keiju@r...>
 
 	* lib/irb/cmd/help.rb: fixed irb's "help" command. [ruby-core:22310].
 
-Tue Jul 21 20:41:20 2009  Keiju Ishitsuka  <keiju@e...>
+Tue Jul 21 20:41:20 2009  Keiju Ishitsuka  <keiju@r...>
 
 	* lib/tracer.rb: no show lines unkonwn line number. [ruby-core:22096],
           no trace display  c-call and c-return as default.
@@ -618,7 +623,7 @@
 
 	* complex.c (nucomp_div): omitted zero division check.
 
-Wed Jul  8 21:00:37 2009  Keiju Ishitsuka  <keiju@e...>
+Wed Jul  8 21:00:37 2009  Keiju Ishitsuka  <keiju@r...>
 
 	* lib/irb/inspector.rb: forget svn add.
 
Index: lib/irb/ext/save-history.rb
===================================================================
--- lib/irb/ext/save-history.rb	(revision 24228)
+++ lib/irb/ext/save-history.rb	(revision 24229)
@@ -47,23 +47,24 @@
   module HistorySavingAbility
     include Readline
 
-    def HistorySavingAbility.create_finalizer
-      proc do
-	if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
-	  if history_file = IRB.conf[:HISTORY_FILE]
-	    history_file = File.expand_path(history_file)
-	  end
-	  history_file = IRB.rc_file("_history") unless history_file
-	  open(history_file, 'w' ) do |f|
-	    hist = HISTORY.to_a
-	    f.puts(hist[-num..-1] || hist)
-	  end
-	end
-      end
-    end
+#     def HistorySavingAbility.create_finalizer
+#       proc do
+# 	if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
+# 	  if hf = IRB.conf[:HISTORY_FILE]
+# 	    file = File.expand_path(hf)
+# 	  end
+# 	  file = IRB.rc_file("_history") unless file
+# 	  open(file, 'w' ) do |f|
+# 	    hist = HISTORY.to_a
+# 	    f.puts(hist[-num..-1] || hist)
+# 	  end
+# 	end
+#       end
+#     end
 
     def HistorySavingAbility.extended(obj)
-      ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
+#      ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
+      IRB.conf[:AT_EXIT].push proc{obj.save_history}
       obj.load_history
       obj
     end
@@ -79,5 +80,18 @@
 	end
       end
     end
+
+    def save_history
+      if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
+	if history_file = IRB.conf[:HISTORY_FILE]
+	  history_file = File.expand_path(history_file)
+	end
+	history_file = IRB.rc_file("_history") unless history_file
+	open(history_file, 'w' ) do |f|
+	  hist = HISTORY.to_a
+	  f.puts(hist[-num..-1] || hist)
+	end
+      end
+    end
   end
 end
Index: lib/irb/init.rb
===================================================================
--- lib/irb/init.rb	(revision 24228)
+++ lib/irb/init.rb	(revision 24229)
@@ -112,7 +112,9 @@
 
 #    @CONF[:LC_MESSAGES] = "en"
     @CONF[:LC_MESSAGES] = Locale.new
-
+    
+    @CONF[:AT_EXIT] = []
+    
     @CONF[:DEBUG_LEVEL] = 1
   end
 

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

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