summaryrefslogtreecommitdiffstats
path: root/lib/rexml/source.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-24 02:04:10 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-24 02:04:10 +0000
commit555b6807e3c3d58107eaba7cb6030105ac9bf7aa (patch)
tree47bfabacac5fcad2f67cffa5f2b0eb80f064d4c6 /lib/rexml/source.rb
parent3a7438b8b8ffea931a81a43a15a395aa3df80491 (diff)
downloadruby-555b6807e3c3d58107eaba7cb6030105ac9bf7aa.tar.gz
ruby-555b6807e3c3d58107eaba7cb6030105ac9bf7aa.tar.xz
ruby-555b6807e3c3d58107eaba7cb6030105ac9bf7aa.zip
-
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/source.rb')
-rw-r--r--lib/rexml/source.rb31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index a524e483e..ce10d03a6 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -150,7 +150,7 @@ module REXML
def read
begin
- str = @source.readline('>')
+ str = @source.readline(@line_break)
str = decode(str) if @to_utf and str
@buffer << str
rescue Exception, NameError
@@ -167,7 +167,7 @@ module REXML
@buffer = $' if cons and rv
while !rv and @source
begin
- str = @source.readline('>')
+ str = @source.readline(@line_break)
str = decode(str) if @to_utf and str
@buffer << str
rv = pattern.match(@buffer)
@@ -186,17 +186,22 @@ module REXML
# @return the current line in the source
def current_line
- pos = @er_source.pos # The byte position in the source
- lineno = @er_source.lineno # The XML < position in the source
- @er_source.rewind
- line = 0 # The \r\n position in the source
- begin
- while @er_source.pos < pos
- @er_source.readline
- line += 1
- end
- rescue
- end
+ begin
+ pos = @er_source.pos # The byte position in the source
+ lineno = @er_source.lineno # The XML < position in the source
+ @er_source.rewind
+ line = 0 # The \r\n position in the source
+ begin
+ while @er_source.pos < pos
+ @er_source.readline
+ line += 1
+ end
+ rescue
+ end
+ rescue IOError
+ pos = -1
+ line = -1
+ end
[pos, lineno, line]
end
end