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

ruby-changes:28400

From: nobu <ko1@a...>
Date: Thu, 25 Apr 2013 01:22:04 +0900 (JST)
Subject: [ruby-changes:28400] nobu:r40452 (trunk): debug.rb: Fix debug listing

nobu	2013-04-25 01:21:54 +0900 (Thu, 25 Apr 2013)

  New Revision: 40452

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

  Log:
    debug.rb: Fix debug listing
    
    * lib/debug.rb (script_lines): get source lines from SCRIPT_LINES__ or
      read from the file.
    * lib/debug.rb (display_list): use script_lines instead of recursion.
      [Bug #8318]
    * lib/debug.rb (line_at): use script_lines same as display_list.

  Modified files:
    trunk/ChangeLog
    trunk/lib/debug.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40451)
+++ ChangeLog	(revision 40452)
@@ -1,4 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Thu Apr 25 01:18:55 2013  Nobuyoshi Nakada  <nobu@r...>
+Thu Apr 25 01:21:51 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/debug.rb (script_lines): get source lines from SCRIPT_LINES__ or
+	  read from the file.
+
+	* lib/debug.rb (display_list): use script_lines instead of recursion.
+	  [Bug #8318]
+
+	* lib/debug.rb (line_at): use script_lines same as display_list.
 
 	* lib/debug.rb (display_list): Fix debug listing when called from the
 	  same file it has been required.  patch by Dario Bertini <berdario AT
Index: lib/debug.rb
===================================================================
--- lib/debug.rb	(revision 40451)
+++ lib/debug.rb	(revision 40452)
@@ -752,8 +752,17 @@ EOHELP https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L752
         (id ? ":in `#{id.id2name}'" : "")
     end
 
+    def script_lines(file, line)
+      unless (lines = SCRIPT_LINES__[file]) and lines != true
+        Tracer::Single.get_line(file, line) if File.exist?(file)
+        lines = SCRIPT_LINES__[file]
+        lines = nil if lines == true
+      end
+      lines
+    end
+
     def display_list(b, e, file, line)
-      if lines = SCRIPT_LINES__[file] and lines != true
+      if lines = script_lines(file, line)
         stdout.printf "[%d, %d] in %s\n", b, e, file
         b.upto(e) do |n|
           if n > 0 && lines[n-1]
@@ -764,20 +773,14 @@ EOHELP https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L773
             end
           end
         end
-      elsif File.exists? file
-        Tracer::Single.get_line(file, line)
-        display_list(b, e, file, line)
       else
         stdout.printf "No sourcefile available for %s\n", file
       end
     end
 
     def line_at(file, line)
-      lines = SCRIPT_LINES__[file]
-      if lines
-        return "\n" if lines == true
-        line = lines[line-1]
-        return "\n" unless line
+      lines = script_lines(file, line)
+      if lines and line = lines[line-1]
         return line
       end
       return "\n"

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

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