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

ruby-changes:30893

From: drbrain <ko1@a...>
Date: Thu, 19 Sep 2013 09:00:07 +0900 (JST)
Subject: [ruby-changes:30893] drbrain:r42972 (trunk): * lib/rdoc/markdown/literals_1_9.rb: Fix trailing whitespace.

drbrain	2013-09-19 09:00:01 +0900 (Thu, 19 Sep 2013)

  New Revision: 42972

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

  Log:
    * lib/rdoc/markdown/literals_1_9.rb:  Fix trailing whitespace.
    
      Previously kpeg (which generates this file) added trailing
      whitespace, but this bug is now fixed.
    
    * lib/rdoc/markdown.rb:  ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/markdown/literals_1_9.rb
    trunk/lib/rdoc/markdown.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42971)
+++ ChangeLog	(revision 42972)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Sep 19 08:59:41 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rdoc/markdown/literals_1_9.rb:  Fix trailing whitespace.
+
+	  Previously kpeg (which generates this file) added trailing
+	  whitespace, but this bug is now fixed.
+
+	* lib/rdoc/markdown.rb:  ditto.
+
 Thu Sep 19 08:33:14 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rdoc:  Update to RDoc 4.1.0.preview.1
Index: lib/rdoc/markdown.rb
===================================================================
--- lib/rdoc/markdown.rb	(revision 42971)
+++ lib/rdoc/markdown.rb	(revision 42972)
@@ -194,7 +194,6 @@ class RDoc::Markdown https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown.rb#L194
     attr_reader :failing_rule_offset
     attr_accessor :result, :pos
 
-    
     def current_column(target=pos)
       if c = string.rindex("\n", target-1)
         return target - c - 1
Index: lib/rdoc/markdown/literals_1_9.rb
===================================================================
--- lib/rdoc/markdown/literals_1_9.rb	(revision 42971)
+++ lib/rdoc/markdown/literals_1_9.rb	(revision 42972)
@@ -23,8 +23,7 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L23
     # Prepares for parsing +str+.  If you define a custom initialize you must
     # call this method before #parse
     def setup_parser(str, debug=false)
-      @string = str
-      @pos = 0
+      set_string str, 0
       @memoizations = Hash.new { |h,k| h[k] = {} }
       @result = nil
       @failed_rule = nil
@@ -37,7 +36,6 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L36
     attr_reader :failing_rule_offset
     attr_accessor :result, :pos
 
-    
     def current_column(target=pos)
       if c = string.rindex("\n", target-1)
         return target - c - 1
@@ -71,6 +69,13 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L69
       @string[start..@pos-1]
     end
 
+    # Sets the string and current parsing position for the parser.
+    def set_string string, pos
+      @string = string
+      @string_size = string ? string.size : 0
+      @pos = pos
+    end
+
     def show_pos
       width = 10
       if @pos < width
@@ -177,19 +182,19 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L182
       return nil
     end
 
-    if "".respond_to? :getbyte
+    if "".respond_to? :ord
       def get_byte
-        if @pos >= @string.size
+        if @pos >= @string_size
           return nil
         end
 
-        s = @string.getbyte @pos
+        s = @string[@pos].ord
         @pos += 1
         s
       end
     else
       def get_byte
-        if @pos >= @string.size
+        if @pos >= @string_size
           return nil
         end
 
@@ -238,8 +243,7 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L243
       old_pos = @pos
       old_string = @string
 
-      @pos = other.pos
-      @string = other.string
+      set_string other.string, other.pos
 
       begin
         if val = __send__(rule, *args)
@@ -250,8 +254,7 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals_1_9.rb#L254
         end
         val
       ensure
-        @pos = old_pos
-        @string = old_string
+        set_string old_string, old_pos
       end
     end
 

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

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