diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2016-02-06 16:54:14 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2016-02-06 16:54:14 +0000 |
commit | 3da5528b47b88c32224cf9d14d8a4e80cd7a0815 (patch) | |
tree | 667010d32d2e7d8436fc1e6ec9eaa31784c7f23b /pcretest.c | |
parent | 662911d355f62321074629645ceb6f5ccf5e1a03 (diff) | |
download | pcre-3da5528b47b88c32224cf9d14d8a4e80cd7a0815.tar.gz |
Fix pcretest bad behaviour for callout in lookbehind.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1625 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r-- | pcretest.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -2250,7 +2250,7 @@ data is not zero. */ static int callout(pcre_callout_block *cb) { FILE *f = (first_callout | callout_extra)? outfile : NULL; -int i, pre_start, post_start, subject_length; +int i, current_position, pre_start, post_start, subject_length; if (callout_extra) { @@ -2280,14 +2280,19 @@ printed lengths of the substrings. */ if (f != NULL) fprintf(f, "--->"); +/* If a lookbehind is involved, the current position may be earlier than the +match start. If so, use the match start instead. */ + +current_position = (cb->current_position >= cb->start_match)? + cb->current_position : cb->start_match; + PCHARS(pre_start, cb->subject, 0, cb->start_match, f); PCHARS(post_start, cb->subject, cb->start_match, - cb->current_position - cb->start_match, f); + current_position - cb->start_match, f); PCHARS(subject_length, cb->subject, 0, cb->subject_length, NULL); -PCHARSV(cb->subject, cb->current_position, - cb->subject_length - cb->current_position, f); +PCHARSV(cb->subject, current_position, cb->subject_length - current_position, f); if (f != NULL) fprintf(f, "\n"); @@ -5740,3 +5745,4 @@ return yield; } /* End of pcretest.c */ + |