File: 808_rexml_document_transitive.patch

package info (click to toggle)
ruby1.8 1.8.7.302-2squeeze5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 26,692 kB
  • ctags: 38,616
  • sloc: ruby: 245,002; ansic: 144,156; yacc: 5,890; sh: 2,677; lisp: 1,626; tcl: 949; makefile: 358; sed: 129; xml: 122; awk: 36; cpp: 28; asm: 25; perl: 18; python: 6
file content (44 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Author: akira yamada <akira@debian.org>
Description: REXML::Document#write(io, 1, true, true) raises NameError/ArgumentError
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -186,6 +186,7 @@ module REXML
       end
       formatter = if indent > -1
           if trans
+            require "rexml/formatters/transitive"
             REXML::Formatters::Transitive.new( indent, ie_hack )
           else
             REXML::Formatters::Pretty.new( indent, ie_hack )
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -675,6 +675,7 @@ module REXML
       Kernel.warn("#{self.class.name}.write is deprecated.  See REXML::Formatters")
       formatter = if indent > -1
           if transitive
+            require "rexml/formatters/transitive"
             REXML::Formatters::Transitive.new( indent, ie_hack )
           else
             REXML::Formatters::Pretty.new( indent, ie_hack )
--- a/lib/rexml/formatters/transitive.rb
+++ b/lib/rexml/formatters/transitive.rb
@@ -12,9 +12,10 @@ module REXML
     # formatted.  Since this formatter does not alter whitespace nodes, the
     # results of formatting already formatted XML will be odd.
     class Transitive < Default
-      def initialize( indentation=2 )
+      def initialize( indentation=2, ie_hack=false )
         @indentation = indentation
         @level = 0
+        @ie_hack = ie_hack
       end
 
       protected
@@ -29,6 +30,7 @@ module REXML
         output << "\n"
         output << ' '*@level
         if node.children.empty?
+          output << " " if @ie_hack
           output << "/" 
         else
           output << ">"