Simon Strandgaard
11/18/2004 9:35:00 PM
On Thursday 18 November 2004 22:20, Joel VanderWerf wrote:
> rnicz wrote:
> > /^-{128}/
> >
> > hangs interpreter. Is it a bug or not?
>
> Fwiw, I can reproduce the hang in 1.8.2 but not in 1.9.0. Maybe it's
> something that Oniguruma fixes.
I can reproduce this problem in 1.8.1. I guess this is a bug in the GNU
engine.
This is show off.. my own regexp engine can deal with /^-{128}/
bash-2.05b$ irb
irb(main):001:0> re = NewRegexp.new("^-{128}")
=> #<NewRegexp:0x403a50f0 @source="^-{128}", @scanner=#<Scanner:0x403a50b4
@root=#<Root:0x403a4e5c @number_of_captures=2,
@node=#<ScannerHierarchy::Capture:0x403a4de4
@succ=#<ScannerHierarchy::Anchor:0x403a4d80 @anchor_type=:line_begin,
@succ=#<ScannerHierarchy::BeginMatch:0x403a4d44
@succ=#<ScannerHierarchy::RepeatGreedy:0x403a4d6c @max=128,
@succ=#<ScannerHierarchy::Capture:0x403a4df8
@succ=#<ScannerHierarchy::Last:0x403a4e34>, @register=1>, @min=128,
@index=nil, @pattern=#<ScannerHierarchy::Inside:0x403a4d1c @succ=EndPattern,
@set=#<RangeSet:0x403a4f24 @codepoints=[45]>>>>>, @register=0>,
@parser=+-Sequence
+-Anchor line_begin
+-Repeat greedy{128,128}
+-Inside set="-">>>
irb(main):002:0> re.match(("-"*128)+"x")
=> #<NewMatchData:0x403fb068 @captures=[],
@matched_string="--------------------------------------------------------------------------------------------------------------------------------",
@positions=[[0, 128]], @post_match="x",
@string="--------------------------------------------------------------------------------------------------------------------------------x",
@match_array=["--------------------------------------------------------------------------------------------------------------------------------"],
@pre_match="", @length=128, @offset=0>
irb(main):003:0> re.match(("-"*127)+"x")
=> nil
irb(main):004:0> puts re.tree
+-Sequence
+-Anchor line_begin
+-Repeat greedy{128,128}
+-Inside set="-"
=> nil
irb(main):005:0>
(sorry for show off)
--
Simon Strandgaard