zeusdeux / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

RE2::Set with trailing assertions returns incorrect matches #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

  RE2::Set s(RE2::DefaultOptions, RE2::ANCHOR_START);
  s.Add("foo$", NULL);
  s.Compile();

  vector<int> v;
  s.Match("foo", &v);
  CHECK_EQ(v.size(), 1);

What version of the product are you using? On what operating system?

Rev b49abcd41429, 64-bit Linux.

Please provide any additional information below.

DFA::InlinedSearchLoop checks for upcoming matches before the last byte is 
processed, so it misses any matches lurking behind trailing zero-width 
assertions.

I've attached a crude but small fix. It moves the match collection down past 
the last byte processing, and modifies DFA::RunWorkqOnByte to keep re-adding 
match instructions to the queue when kind == kManyMatch so they'll get picked 
up at the end.

Original issue reported on code.google.com by dhaf...@gmail.com on 20 Oct 2011 at 9:16

Attachments:

GoogleCodeExporter commented 9 years ago
This test case is working now. I think it was fixed independently.

Original comment by rsc@golang.org on 10 Jan 2014 at 3:55