mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
-
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fea9469fc6
commit
20ae8fed6b
7 changed files with 49 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue