Ticket #158: rexml-pretty-formatter-wrap-fix.patch

File rexml-pretty-formatter-wrap-fix.patch, 1.0 kB (added by alk, 5 months ago)
  • src/rexml/formatters/pretty.rb

    diff -Naurd rexml_3.1.7.3-orig/src/rexml/formatters/pretty.rb rexml_3.1.7.3/src/rexml/formatters/pretty.rb
    old new  
    126126      end 
    127127 
    128128      def wrap(string, width) 
    129         # Recursivly wrap string at width. 
     129        # non-recursively wrap string at width. 
    130130        return string if string.length <= width 
    131         place = string.rindex(' ', width) # Position in string with last ' ' before cutoff 
    132         return string[0,place] + "\n" + wrap(string[place+1..-1], width) 
     131        acc = '' 
     132        begin 
     133          place = string.rindex(' ', width) # Position in string with last ' ' before cutoff 
     134          break unless place 
     135          acc << string[0,place] << "\n" 
     136          string = string[place+1..-1] 
     137        end while string.length > width 
     138        acc << string 
    133139      end 
    134  
    135140    end 
    136141  end 
    137142end