[#35446] [Ruby 1.9 - Bug #4477][Open] Kernel:exec and backtick (`) don't work for certain system commands — Joachim Wuttke <j.wuttke@...>

10 messages 2011/03/07

[#35476] [Ruby 1.9 - Bug #4489][Open] [PATCH] Encodings with /-(unix|dos|mac)\Z/ — "James M. Lawrence" <quixoticsycophant@...>

20 messages 2011/03/10

[#35552] [Ruby 1.9 - Feature #4523][Open] Kernel#require to return the path of the loaded file — Alex Young <alex@...>

14 messages 2011/03/24

[#35565] [Ruby 1.9 - Feature #4531][Open] [PATCH 0/7] use poll() instead of select() in certain cases — Eric Wong <normalperson@...>

33 messages 2011/03/28

[#35566] [Ruby 1.9 - Feature #4532][Open] [PATCH] add IO#pread and IO#pwrite methods — Eric Wong <normalperson@...>

12 messages 2011/03/28

[#35586] [Ruby 1.9 - Feature #4538][Open] [PATCH (cleanup)] avoid unnecessary select() calls before doing I/O — Eric Wong <normalperson@...>

9 messages 2011/03/29

[ruby-core:35551] [Ruby 1.8 - Bug #4498][Open] [Patch] REXML Pretty formater does use specified 'width' to wrap lines

From: Michael Frasca <michael.frasca@...>
Date: 2011-03-24 21:04:09 UTC
List: ruby-core #35551
REXML::Formatters::Pretty has 'width' attribute used to wrap lines.
This is not used when the wrap method is invoked.

The pretty formatter within the REXML library is used to nicely indent
xml files for viewing. I use this feature to present XML files to a
user for editing. The width attribute is available to set a maximum
line width, and force text wrapping for nodes with long text values.

There are two modes for the pretty formatter - @compact =3D { true |
false }. When compact is on, @width is used for text wrapping under
the condition that ...

"If compact and all children are text, and if the formatted output is
less than the specified width, then try to print everything on one
line"

But in the case when @compact =3D false, I believe that the node text
should still be wrapped based on user specification. In the current
state, max width is hard coded to 80 chars.

# lib/rexml/formatters/pretty.rb
def write_text( node, output )
=A0 s =3D node.to_s()
=A0 s.gsub!(/\s/,' ')
=A0 s.squeeze!(" ")
=A0 s =3D wrap(s, 80-@level)     ##  <-- HERE: is hard coded, value should
depend on @width and @level (e.g. @width - @level)
=A0 s =3D indent_text(s, @level, " ", true)
=A0 output << (' '*@level + s)
end

I've attached a patch for this issue. I've raised bug #4497 for the
same issue in 1.8.7 branch

-Michael Frasca

Attachments (1)

ruby-core-bug-4498.patch (465 Bytes, text/x-diff)
Index: lib/rexml/formatters/pretty.rb
===================================================================
--- lib/rexml/formatters/pretty.rb	(revision 31103)
+++ lib/rexml/formatters/pretty.rb	(working copy)
@@ -88,7 +88,7 @@
         s = node.to_s()
         s.gsub!(/\s/,' ')
         s.squeeze!(" ")
-        s = wrap(s, 80-@level)
+        s = wrap(s, @width-@level)
         s = indent_text(s, @level, " ", true)
         output << (' '*@level + s)
       end

In This Thread

Prev Next