From: John Doxey Date: 2009-05-06T09:57:21+09:00 Subject: Re: REXML (1.8.6-p110) backwards compatibility problem with Roy Truelove wrote: > Sean Hussey wrote: >> Nice catch! >> >> After applying both fixes, I now get this: >> >> /usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no >> implicit conversion from nil to integer (TypeError) > > Hey Sean, it looks like the rexml code is assuming that there'll be a ' > ' somewhere in the code to wrap on. I was able to fix this with the > following patch to the pretty.rb file : > > --- /opt/ruby-1.8.7-p72/lib/ruby/1.8/rexml/formatters/pretty.rb.OLD > 2009-02-15 14:47:32.000000000 -0600 > +++ /opt/ruby-1.8.7-p72/lib/ruby/1.8/rexml/formatters/pretty.rb > 2009-02-15 14:48:50.000000000 -0600 > @@ -126,10 +126,11 @@ > > def wrap(string, width) > # Recursively wrap string at width. > return string if string.length <= width > place = string.rindex(' ', width) # Position in string with > last ' ' before cutoff > + return string if place.nil? # there aren't any ' 's before > cutoff, nothing to split on. > return string[0,place] + "\n" + wrap(string[place+1..-1], > width) > end > > end > end There might still be spaces in the string, how about, --- pretty.rb.old 2009-05-06 10:50:37.000000000 +1000 +++ pretty.rb 2009-05-06 10:55:37.000000000 +1000 @@ -128,6 +128,8 @@ # Recursively wrap string at width. return string if string.length <= width place = string.rindex(' ', width) # Position in string with last ' ' before cutoff + place = string.index(' ') if place.nil? + return string if place.nil? # there aren't any ' 's before cutoff, nothing to split on. return string[0,place] + "\n" + wrap(string[place+1..-1], width) end -- Posted via http://www.ruby-forum.com/.