Description: |
This regexp test fails, though it should succeed:
% regexp {(\w).*?\1} {Programmer}
0
If you remove the '?', it does succeed, showing that the problem is restricted to non-greedy mode.
This problem was initially reported to the Postgres project:
http://www.postgresql.org/message-id/CAM2+6=U8CdfM-qL55XHt+7hVzDRBnZwrHiVZRX2shGZ4OMuMSQ@mail.gmail.com
As per the discussion there, it seems that this is a bug in cfindloop(), and that the fix is that the /* no point in trying again */ code block is wrong and should be replaced by a simple "break;", allowing the intermediate loop to continue iterating with the next possible "begin" value. I further suggested refactoring to merge that test into the subsequent statements that adjust estart/estop, but that's cosmetic, not essential to the fix.
|