Bug #4067 ยป rexml_fix.diff
lib/rexml/formatters/pretty.rb | ||
---|---|---|
126 | 126 |
end |
127 | 127 | |
128 | 128 |
def wrap(string, width) |
129 |
# Recursively wrap string at width. |
|
130 |
return string if string.length <= width |
|
131 |
place = string.rindex(' ', width) # Position in string with last ' ' before cutoff |
|
132 |
return string if place.nil? |
|
133 |
return string[0,place] + "\n" + wrap(string[place+1..-1], width) |
|
129 |
parts = [] |
|
130 |
last_place = 0 |
|
131 |
while string.length > width and place = string.rindex(' ', width) |
|
132 |
parts << string[0...place] |
|
133 |
string = string[place+1..-1] |
|
134 |
end |
|
135 |
parts << string |
|
136 |
parts.join("\n") |
|
134 | 137 |
end |
135 | 138 | |
136 | 139 |
end |
test/rexml/test_core.rb | ||
---|---|---|
1151 | 1151 |
assert_not_equal( c, d ) |
1152 | 1152 |
end |
1153 | 1153 | |
1154 |
def test_long_text |
|
1155 |
aaaa = 'aaaa ' * 1_000_000 |
|
1156 |
a = "<doc>#{aaaa}</doc>" |
|
1157 |
f = REXML::Formatters::Pretty.new |
|
1158 |
xmldoc = REXML::Document.new( a ) |
|
1159 |
assert_nothing_raised{f.write(xmldoc, b="")} |
|
1160 |
end |
|
1154 | 1161 | |
1155 | 1162 |
def test_ticket_58 |
1156 | 1163 |
doc = REXML::Document.new |
1157 |
- |