aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/source.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml/source.rb')
-rw-r--r--lib/rexml/source.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index 3f14239a35..d4335138a1 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -147,7 +147,7 @@ module REXML
# the XML spec. If there is one, we can determine the encoding from
# it.
@buffer = ""
- str = @source.read( 2 )
+ str = @source.read( 2 ) || ''
if encoding
self.encoding = encoding
elsif str[0,2] == "\xfe\xff"
@@ -161,7 +161,7 @@ module REXML
else
@line_break = ">"
end
- super str+@source.readline( @line_break )
+ super( @source.eof? ? str : str+@source.readline( @line_break ) )
end
def scan(pattern, cons=false)
@@ -231,7 +231,7 @@ module REXML
end
def position
- @er_source.stat.pipe? ? 0 : @er_source.pos
+ @er_source.pos rescue 0
end
# @return the current line in the source