diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2013-12-27 12:23:25 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2013-12-27 12:23:25 +0000 |
commit | 5b52324dc797364680c782b151f7d0f8aa8618ad (patch) | |
tree | 56011d0a72aea26b87224dccb9b1cbbe456483de /pcretest.c | |
parent | 52788c0f63139de170cfe1b3769fa1d5a97d9147 (diff) | |
download | pcre-5b52324dc797364680c782b151f7d0f8aa8618ad.tar.gz |
Fix pcretest's handling of patterns when \K in an assertion sets the start of a
match past the end of the match.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1418 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r-- | pcretest.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -5192,7 +5192,8 @@ while (!done) if (count * 2 > use_size_offsets) count = use_size_offsets/2; } - /* Output the captured substrings */ + /* Output the captured substrings. Note that, for the matched string, + the use of \K in an assertion can make the start later than the end. */ for (i = 0; i < count * 2; i += 2) { @@ -5208,11 +5209,25 @@ while (!done) } else { + int start = use_offsets[i]; + int end = use_offsets[i+1]; + + if (start > end) + { + start = use_offsets[i+1]; + end = use_offsets[i]; + fprintf(outfile, "Start of matched string is beyond its end - " + "displaying from end to start.\n"); + } + fprintf(outfile, "%2d: ", i/2); - PCHARSV(bptr, use_offsets[i], - use_offsets[i+1] - use_offsets[i], outfile); + PCHARSV(bptr, start, end - start, outfile); if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)"); fprintf(outfile, "\n"); + + /* Note: don't use the start/end variables here because we want to + show the text from what is reported as the end. */ + if (do_showcaprest || (i == 0 && do_showrest)) { fprintf(outfile, "%2d+ ", i/2); |