Backport #1182

Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  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?