Projects

Ticket #668 (closed defect: fixed)

Opened 22 months ago

Last modified 13 months ago

Newlines and carriage returns cause erroneous matches in StringScanner

Reported by: mred@… Owned by: mattaimonetti@…
Priority: major Milestone: MacRuby 0.9
Component: MacRuby Keywords:
Cc:

Description (last modified by lsansonetti@…) (diff)

require 'strscan'
["\na", "\ra", " a"].each do |s|
  scanner = StringScanner.new(s)
  scanner.scan(/a/)
  puts scanner.inspect
end

Ruby 1.9.1 results

#<StringScanner 0/2 @ "\na">
#<StringScanner 0/2 @ "\ra">
#<StringScanner 0/2 @ " a">

MacRuby 3968 results

#<StringScanner fin>
#<StringScanner fin>
#<StringScanner 0/2 @ " a">

Change History

Changed 14 months ago by lsansonetti@…

  • description modified (diff)

Still doesn't work as of trunk.

Changed 14 months ago by lsansonetti@…

  • owner changed from lsansonetti@… to mattaimonetti@…
  • milestone set to MacRuby 1.0

Maybe the _scan method in lib/strscan.rb should compile the regexp differently.

instead of

      headonly_pattern = Regexp.new('^' + pattern.source, pattern.options)

do

      headonly_pattern = Regexp.new('^[\n\r]+' + pattern.source, pattern.options)

Assigning to Matt and screening for 1.0.

Changed 13 months ago by mattaimonetti@…

  • status changed from new to closed
  • resolution set to fixed

fixed in r5204 Used \A instead of .

Changed 13 months ago by mattaimonetti@…

  • milestone changed from MacRuby 1.0 to MacRuby 0.9
Note: See TracTickets for help on using tickets.