Fix regexp_matches() handling of zero-length matches.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 8505ebf31eb50c20afeaca0e0dfa2fbb1cec001f
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2013-07-31T15:31:30Z
Releases: 9.2.5
Fix regexp_matches() handling of zero-length matches.

We'd find the same match twice if it was of zero length and not immediately
adjacent to the previous match.  replace_text_regexp() got similar cases
right, so adjust this search logic to match that.  Note that even though
the regexp_split_to_xxx() functions share this code, they did not display
equivalent misbehavior, because the second match would be considered
degenerate and ignored.

Jeevan Chalke, with some cosmetic changes by me.

Files