Project

General

Profile

Bug #1182

REXML::Source#position badly implemented and other related issues

Added by gettalong (Thomas Leitner) over 10 years ago. Updated about 8 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin8.11.1]
[ruby-core:22284]

Description

=begin
The implementation of REXML::Source#position works sometimes but most of the time it doesn't. Here is the source for the method:

  119     def position
  120       @orig.index( @buffer )
  121     end

The @buffer holds everything after the current position and @orig is the original string. It often occurs that @buffer is so short that multiple matches in @orig are possible and therefore a correct position cannot be obtained.

The easiest way to remedy the situation (I think) is to introduce an instance variable @pos that holds the current position (I have attached a fixed version of the REXML::Source class based on the 1.9.1 file rexml/source.rb).

This bug applies to Ruby 1.8 and 1.9 altough it seems that the REXML::Source class isn't used there anymore (the SourceFactory uses a StringIO object when presented a string and therefore uses REXML::SourceIO instead of REXML::Source) - so maybe in 1.9 the REXML::Source class can be removed?
=end


Files

fixed_source.rb (3.24 KB) fixed_source.rb Fixed REXML::Source class based on rexml/source.rb from 1.9.1 gettalong (Thomas Leitner), 02/20/2009 04:35 PM

History

#1

Updated by mame (Yusuke Endoh) about 9 years ago

=begin
Hi,

2009/2/20 Thomas Leitner redmine@ruby-lang.org:

The implementation of REXML::Source#position works sometimes but most of the time it doesn't.
snip
This bug applies to Ruby 1.8 and 1.9 altough it seems that the REXML::Source class isn't used there anymore

As you said, 1.9 does not use REXML::Source. This issue
actually occurs only on 1.8, I think. Than, I move the
ticket to ruby 1.8 subproject.

Indeed, REXML::Source can be removed from 1.9.
But rexml shall not be changed until actual problem occurs
because there is no maintainer for rexml.

--
Yusuke ENDOH mame@tsg.ne.jp
=end

Also available in: Atom PDF