RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: pcre Date: 24-Jun-2016 10:45:31 Branch: HEAD Handle: 2016062408453100 Modified files: pcre Makefile.am RunTest config.h.generic configure.ac pcregrep.c pcretest.c Log: - merge conflicts on HEAD after import of pcre-8.39. Summary: Revision Changes Path 1.15 +1 -0 pcre/Makefile.am 1.3 +19 -15 pcre/RunTest 1.3 +3 -3 pcre/config.h.generic 1.10 +7 -7 pcre/configure.ac 1.10 +91 -51 pcre/pcregrep.c 1.10 +66 -21 pcre/pcretest.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: pcre/Makefile.am ============================================================================ $ cvs diff -u -r1.14 -r1.15 Makefile.am --- pcre/Makefile.am 10 May 2015 17:55:16 -0000 1.14 +++ pcre/Makefile.am 24 Jun 2016 08:45:31 -0000 1.15 @@ -617,6 +617,7 @@ testdata/testoutput25 \ testdata/testoutput26 \ testdata/testoutputEBC \ + testdata/valgrind-jit.supp \ testdata/wintestinput3 \ testdata/wintestoutput3 \ perltest.pl @@ . patch -p0 <<'@@ .' Index: pcre/RunTest ============================================================================ $ cvs diff -u -r1.2 -r1.3 RunTest --- pcre/RunTest 20 Apr 2016 09:55:09 -0000 1.2 +++ pcre/RunTest 24 Jun 2016 08:45:31 -0000 1.3 @@ -178,6 +178,7 @@ sim= skip= valgrind= +vjs= # This is in case the caller has set aliases (as I do - PH) unset cp ls mv rm @@ -357,6 +358,9 @@ jit=$? if [ $jit -ne 0 -a "$nojit" != "yes" ] ; then jitopt=-s+ + if [ "$valgrind" != "" ] ; then + vjs="--suppressions=$testdata/valgrind-jit.supp" + fi fi # If no specific tests were requested, select all. Those that are not @@ -370,7 +374,7 @@ $do21 = no -a $do22 = no -a $do23 = no -a $do24 = no -a \ $do25 = no -a $do26 = no ] ; then do1=yes - do2=no + do2=yes do3=yes do4=yes do5=yes @@ -423,7 +427,7 @@ if [ $do1 = yes ] ; then echo $title1 for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput1 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput1 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput1 testtry if [ $? != 0 ] ; then exit 1; fi @@ -441,7 +445,7 @@ if [ $do2 = yes ] ; then echo $title2 "(not UTF-$bits)" for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput2 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput2 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput2 testtry if [ $? != 0 ] ; then exit 1; fi @@ -504,7 +508,7 @@ if [ "$locale" != "" ] ; then echo $title3 "(using '$locale' locale)" for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $infile testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $infile testtry if [ $? = 0 ] ; then if $cf $outfile testtry >teststdout || \ $cf $outfile2 testtry >teststdout || \ @@ -540,7 +544,7 @@ echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput4 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput4 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput4 testtry if [ $? != 0 ] ; then exit 1; fi @@ -560,7 +564,7 @@ echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput5 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput5 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput5 testtry if [ $? != 0 ] ; then exit 1; fi @@ -580,7 +584,7 @@ echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput6 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput6 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput6 testtry if [ $? != 0 ] ; then exit 1; fi @@ -602,7 +606,7 @@ echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput7 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput7 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput7 testtry if [ $? != 0 ] ; then exit 1; fi @@ -698,7 +702,7 @@ if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then echo " Skipped because JIT is not available or not usable" else - $sim $valgrind ./pcretest -q $bmode $testdata/testinput12 testtry + $sim $valgrind $vjs ./pcretest -q $bmode $testdata/testinput12 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput12 testtry if [ $? != 0 ] ; then exit 1; fi @@ -735,7 +739,7 @@ cp -f $testdata/saved16 testsaved16 cp -f $testdata/saved32 testsaved32 for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput14 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput14 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput14 testtry if [ $? != 0 ] ; then exit 1; fi @@ -759,7 +763,7 @@ echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput15 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput15 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput15 testtry if [ $? != 0 ] ; then exit 1; fi @@ -783,7 +787,7 @@ echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput16 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput16 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput16 testtry if [ $? != 0 ] ; then exit 1; fi @@ -805,7 +809,7 @@ echo " Skipped when running 8-bit tests" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput17 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput17 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput17 testtry if [ $? != 0 ] ; then exit 1; fi @@ -829,7 +833,7 @@ echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput18 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput18 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput18-$bits testtry if [ $? != 0 ] ; then exit 1; fi @@ -853,7 +857,7 @@ echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput19 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput19 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput19 testtry if [ $? != 0 ] ; then exit 1; fi @@ . patch -p0 <<'@@ .' Index: pcre/config.h.generic ============================================================================ $ cvs diff -u -r1.2 -r1.3 config.h.generic --- pcre/config.h.generic 20 Apr 2016 09:56:13 -0000 1.2 +++ pcre/config.h.generic 24 Jun 2016 08:45:31 -0000 1.3 @@ -235,7 +235,7 @@ #define PACKAGE_NAME "PCRE" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "PCRE 8.35" +#define PACKAGE_STRING "PCRE 8.39" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pcre" @@ -244,7 +244,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "8.35" +#define PACKAGE_VERSION "8.39" /* The value of PARENS_NEST_LIMIT specifies the maximum depth of nested parentheses (of any kind) in a pattern. This limits the amount of system @@ -336,7 +336,7 @@ /* #undef SUPPORT_VALGRIND */ /* Version number of package */ -#define VERSION "8.35" +#define VERSION "8.39" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ @@ . patch -p0 <<'@@ .' Index: pcre/configure.ac ============================================================================ $ cvs diff -u -r1.9 -r1.10 configure.ac --- pcre/configure.ac 19 Apr 2016 12:57:48 -0000 1.9 +++ pcre/configure.ac 24 Jun 2016 08:45:31 -0000 1.10 @@ -9,19 +9,19 @@ dnl be defined as -RC2, for example. For real releases, it should be empty. m4_define(pcre_major, [8]) -m4_define(pcre_minor, [35]) +m4_define(pcre_minor, [39]) m4_define(pcre_prerelease, []) -m4_define(pcre_date, [2014-04-04]) +m4_define(pcre_date, [2016-06-14]) # NOTE: The CMakeLists.txt file searches for the above variables in the first # 50 lines of this file. Please update that if the variables above are moved. # Libtool shared library interface versions (current:revision:age) -m4_define(libpcre_version, [3:3:2]) -m4_define(libpcre16_version, [2:3:2]) -m4_define(libpcre32_version, [0:3:0]) -m4_define(libpcreposix_version, [0:2:0]) -m4_define(libpcrecpp_version, [0:0:0]) +m4_define(libpcre_version, [3:7:2]) +m4_define(libpcre16_version, [2:7:2]) +m4_define(libpcre32_version, [0:7:0]) +m4_define(libpcreposix_version, [0:4:0]) +m4_define(libpcrecpp_version, [0:1:0]) AC_PREREQ(2.57) AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre) @@ . patch -p0 <<'@@ .' Index: pcre/pcregrep.c ============================================================================ $ cvs diff -u -r1.9 -r1.10 pcregrep.c --- pcre/pcregrep.c 18 Jul 2014 18:33:21 -0000 1.9 +++ pcre/pcregrep.c 24 Jun 2016 08:45:31 -0000 1.10 @@ -455,7 +455,7 @@ s pattern string to add after if not NULL points to item to insert after -Returns: new pattern block +Returns: new pattern block or NULL on error */ static patstr * @@ -1582,12 +1582,15 @@ int endlinelength; int mrc = 0; int startoffset = 0; + int prevoffsets[2]; unsigned int options = 0; BOOL match; char *matchptr = ptr; char *t = ptr; size_t length, linelength; + prevoffsets[0] = prevoffsets[1] = -1; + /* At this point, ptr is at the start of a line. We need to find the length of the subject string to pass to pcre_exec(). In multiline mode, it is the length remainder of the data in the buffer. Otherwise, it is the length of @@ -1689,9 +1692,13 @@ if (filenames == FN_NOMATCH_ONLY) return 1; + /* If all we want is a yes/no answer, stop now. */ + + if (quiet) return 0; + /* Just count if just counting is wanted. */ - if (count_only) count++; + else if (count_only) count++; /* When handling a binary file and binary-files==binary, the "binary" variable will be set true (it's false in all other cases). In this @@ -1712,10 +1719,6 @@ return 0; } - /* Likewise, if all we want is a yes/no answer. */ - - else if (quiet) return 0; - /* The --only-matching option prints just the substring that matched, and/or one or more captured portions of it, as long as these strings are not empty. The --file-offsets and --line-offsets options output offsets for @@ -1729,55 +1732,86 @@ { if (!invert) { - if (printname != NULL) fprintf(stdout, "%s:", printname); - if (number) fprintf(stdout, "%d:", linenumber); + int oldstartoffset = startoffset; + + /* It is possible, when a lookbehind assertion contains \K, for the + same string to be found again. The code below advances startoffset, but + until it is past the "bumpalong" offset that gave the match, the same + substring will be returned. The PCRE1 library does not return the + bumpalong offset, so all we can do is ignore repeated strings. (PCRE2 + does this better.) */ - /* Handle --line-offsets */ + if (prevoffsets[0] != offsets[0] || prevoffsets[1] != offsets[1]) + { + prevoffsets[0] = offsets[0]; + prevoffsets[1] = offsets[1]; - if (line_offsets) - fprintf(stdout, "%d,%d\n", (int)(matchptr + offsets[0] - ptr), - offsets[1] - offsets[0]); + if (printname != NULL) fprintf(stdout, "%s:", printname); + if (number) fprintf(stdout, "%d:", linenumber); - /* Handle --file-offsets */ + /* Handle --line-offsets */ - else if (file_offsets) - fprintf(stdout, "%d,%d\n", - (int)(filepos + matchptr + offsets[0] - ptr), - offsets[1] - offsets[0]); + if (line_offsets) + fprintf(stdout, "%d,%d\n", (int)(matchptr + offsets[0] - ptr), + offsets[1] - offsets[0]); - /* Handle --only-matching, which may occur many times */ + /* Handle --file-offsets */ - else - { - BOOL printed = FALSE; - omstr *om; + else if (file_offsets) + fprintf(stdout, "%d,%d\n", + (int)(filepos + matchptr + offsets[0] - ptr), + offsets[1] - offsets[0]); - for (om = only_matching; om != NULL; om = om->next) + /* Handle --only-matching, which may occur many times */ + + else { - int n = om->groupnum; - if (n < mrc) + BOOL printed = FALSE; + omstr *om; + + for (om = only_matching; om != NULL; om = om->next) { - int plen = offsets[2*n + 1] - offsets[2*n]; - if (plen > 0) + int n = om->groupnum; + if (n < mrc) { - if (printed) fprintf(stdout, "%s", om_separator); - if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string); - FWRITE(matchptr + offsets[n*2], 1, plen, stdout); - if (do_colour) fprintf(stdout, "%c[00m", 0x1b); - printed = TRUE; + int plen = offsets[2*n + 1] - offsets[2*n]; + if (plen > 0) + { + if (printed) fprintf(stdout, "%s", om_separator); + if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string); + FWRITE(matchptr + offsets[n*2], 1, plen, stdout); + if (do_colour) fprintf(stdout, "%c[00m", 0x1b); + printed = TRUE; + } } } - } - if (printed || printname != NULL || number) fprintf(stdout, "\n"); + if (printed || printname != NULL || number) fprintf(stdout, "\n"); + } } - /* Prepare to repeat to find the next match */ + /* Prepare to repeat to find the next match. If the patterned contained + a lookbehind tht included \K, it is possible that the end of the match + might be at or before the actual strting offset we have just used. We + need to start one character further on. Unfortunately, for unanchored + patterns, the actual start offset can be greater that the one that was + set as a result of "bumpalong". PCRE1 does not return the actual start + offset, so we have to check against the original start offset. This may + lead to duplicates - we we need the fudge above to avoid printing them. + (PCRE2 does this better.) */ match = FALSE; if (line_buffered) fflush(stdout); rc = 0; /* Had some success */ startoffset = offsets[1]; /* Restart after the match */ + if (startoffset <= oldstartoffset) + { + if ((size_t)startoffset >= length) + goto END_ONE_MATCH; /* We were at the end */ + startoffset = oldstartoffset + 1; + if (utf8) + while ((matchptr[startoffset] & 0xc0) == 0x80) startoffset++; + } goto ONLY_MATCHING_RESTART; } } @@ -1974,6 +2008,7 @@ /* Advance to after the newline and increment the line number. The file offset to the current line is maintained in filepos. */ + END_ONE_MATCH: ptr += linelength + endlinelength; filepos += (int)(linelength + endlinelength); linenumber++; @@ -2054,7 +2089,7 @@ /* Print the match count if wanted */ -if (count_only) +if (count_only && !quiet) { if (count > 0 || !omit_zero_count) { @@ -2402,7 +2437,7 @@ static char * ordin(int n) { -static char buffer[8]; +static char buffer[14]; char *p = buffer; sprintf(p, "%d", n); while (*p != 0) p++; @@ -2519,7 +2554,6 @@ FILE *f; char *filename; char buffer[PATBUFSIZE]; -BOOL ret = FALSE; if (strcmp(name, "-") == 0) { @@ -2551,7 +2585,11 @@ afterwards, as a precaution against any later code trying to use it. */ *patlastptr = add_pattern(buffer, *patlastptr); - if (*patlastptr == NULL) goto exit; + if (*patlastptr == NULL) + { + if (f != stdin) fclose(f); + return FALSE; + } if (*patptr == NULL) *patptr = *patlastptr; /* This loop is needed because compiling a "pattern" when -F is set may add @@ -2563,17 +2601,18 @@ { if (!compile_pattern(*patlastptr, pcre_options, popts, TRUE, filename, linenumber)) - goto exit; + { + if (f != stdin) fclose(f); + return FALSE; + } (*patlastptr)->string = NULL; /* Insurance */ if ((*patlastptr)->next == NULL) break; *patlastptr = (*patlastptr)->next; } } - ret = TRUE; -exit: if (f != stdin) fclose(f); -return ret; +return TRUE; } @@ -2966,8 +3005,8 @@ locale_from = "LC_CTYPE"; } -/* If a locale has been provided, set it, and generate the tables the PCRE -needs. Otherwise, pcretables==NULL, which causes the use of default tables. */ +/* If a locale is set, use it to generate the tables the PCRE needs. Otherwise, +pcretables==NULL, which causes the use of default tables. */ if (locale != NULL) { @@ -2975,7 +3014,7 @@ { fprintf(stderr, "pcregrep: Failed to set locale %s (obtained from %s)\n", locale, locale_from); - return 2; + goto EXIT2; } pcretables = pcre_maketables(); } @@ -2990,7 +3029,7 @@ { fprintf(stderr, "pcregrep: Unknown colour setting \"%s\"\n", colour_option); - return 2; + goto EXIT2; } if (do_colour) { @@ -3030,7 +3069,7 @@ else { fprintf(stderr, "pcregrep: Invalid newline specifier \"%s\"\n", newline); - return 2; + goto EXIT2; } /* Interpret the text values for -d and -D */ @@ -3043,7 +3082,7 @@ else { fprintf(stderr, "pcregrep: Invalid value \"%s\" for -d\n", dee_option); - return 2; + goto EXIT2; } } @@ -3054,7 +3093,7 @@ else { fprintf(stderr, "pcregrep: Invalid value \"%s\" for -D\n", DEE_option); - return 2; + goto EXIT2; } } @@ -3255,7 +3294,8 @@ if (jit_stack != NULL) pcre_jit_stack_free(jit_stack); #endif -if (main_buffer != NULL) free(main_buffer); +free(main_buffer); +free((void *)pcretables); free_pattern_chain(patterns); free_pattern_chain(include_patterns); @@ . patch -p0 <<'@@ .' Index: pcre/pcretest.c ============================================================================ $ cvs diff -u -r1.9 -r1.10 pcretest.c --- pcre/pcretest.c 18 Jul 2014 18:33:21 -0000 1.9 +++ pcre/pcretest.c 24 Jun 2016 08:45:31 -0000 1.10 @@ -2250,23 +2250,26 @@ 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) { fprintf(f, "Callout %d: last capture = %d\n", cb->callout_number, cb->capture_last); - for (i = 0; i < cb->capture_top * 2; i += 2) + if (cb->offset_vector != NULL) { - if (cb->offset_vector[i] < 0) - fprintf(f, "%2d: <unset>\n", i/2); - else + for (i = 0; i < cb->capture_top * 2; i += 2) { - fprintf(f, "%2d: ", i/2); - PCHARSV(cb->subject, cb->offset_vector[i], - cb->offset_vector[i+1] - cb->offset_vector[i], f); - fprintf(f, "\n"); + if (cb->offset_vector[i] < 0) + fprintf(f, "%2d: <unset>\n", i/2); + else + { + fprintf(f, "%2d: ", i/2); + PCHARSV(cb->subject, cb->offset_vector[i], + cb->offset_vector[i+1] - cb->offset_vector[i], f); + fprintf(f, "\n"); + } } } } @@ -2277,14 +2280,19 @@ 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"); @@ -2519,7 +2527,7 @@ re->name_count = swap_uint16(re->name_count); re->ref_count = swap_uint16(re->ref_count); -if (extra != NULL) +if (extra != NULL && (extra->flags & PCRE_EXTRA_STUDY_DATA) != 0) { pcre_study_data *rsd = (pcre_study_data *)(extra->study_data); rsd->size = swap_uint32(rsd->size); @@ -2700,7 +2708,7 @@ re->name_count = swap_uint16(re->name_count); re->ref_count = swap_uint16(re->ref_count); -if (extra != NULL) +if (extra != NULL && (extra->flags & PCRE_EXTRA_STUDY_DATA) != 0) { pcre_study_data *rsd = (pcre_study_data *)(extra->study_data); rsd->size = swap_uint32(rsd->size); @@ -3453,7 +3461,7 @@ pcre_extra *extra = NULL; #if !defined NOPOSIX /* There are still compilers that require no indent */ - regex_t preg; + regex_t preg = { NULL, 0, 0} ; int do_posix = 0; #endif @@ -4618,9 +4626,9 @@ else switch ((c = *p++)) { - case 'a': c = 7; break; + case 'a': c = CHAR_BEL; break; case 'b': c = '\b'; break; - case 'e': c = 27; break; + case 'e': c = CHAR_ESC; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; @@ -5603,6 +5611,18 @@ if (!do_g && !do_G) break; + if (use_offsets == NULL) + { + fprintf(outfile, "Cannot do global matching without an ovector\n"); + break; + } + + if (use_size_offsets < 2) + { + fprintf(outfile, "Cannot do global matching with an ovector size < 2\n"); + break; + } + /* If we have matched an empty string, first check to see if we are at the end of the subject. If so, the /g loop is over. Otherwise, mimic what Perl's /g options does. This turns out to be rather cunning. First we set @@ -5618,9 +5638,33 @@ g_notempty = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED; } - /* For /g, update the start offset, leaving the rest alone */ - - if (do_g) start_offset = use_offsets[1]; + /* For /g, update the start offset, leaving the rest alone. There is a + tricky case when \K is used in a positive lookbehind assertion. This can + cause the end of the match to be less than or equal to the start offset. + In this case we restart at one past the start offset. This may return the + same match if the original start offset was bumped along during the + match, but eventually the new start offset will hit the actual start + offset. (In PCRE2 the true start offset is available, and this can be + done better. It is not worth doing more than making sure we do not loop + at this stage in the life of PCRE1.) */ + + if (do_g) + { + if (g_notempty == 0 && use_offsets[1] <= start_offset) + { + if (start_offset >= len) break; /* End of subject */ + start_offset++; + if (use_utf) + { + while (start_offset < len) + { + if ((bptr[start_offset] & 0xc0) != 0x80) break; + start_offset++; + } + } + } + else start_offset = use_offsets[1]; + } /* For /G, update the pointer and length */ @@ -5637,7 +5681,7 @@ CONTINUE: #if !defined NOPOSIX - if (posix || do_posix) regfree(&preg); + if ((posix || do_posix) && preg.re_pcre != 0) regfree(&preg); #endif if (re != NULL) new_free(re); @@ -5707,3 +5751,4 @@ } /* End of pcretest.c */ + @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org