diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-07-30 11:58:56 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-07-30 11:58:56 +0300 |
commit | f8736063deab07744e5e3c8834d60a1db5a8574d (patch) | |
tree | 9402328bfe08c7812fc95be355c28b2e742c3221 /pcre/pcregrep.c | |
parent | 051f8bc8e35d9d10d64fb9d3d1e521793ec99d12 (diff) | |
parent | dba454ef54bfc83cc1ade93c668f39ec0a5895d3 (diff) | |
download | mariadb-git-f8736063deab07744e5e3c8834d60a1db5a8574d.tar.gz |
Merge branch 'merge-pcre' into 10.0
Diffstat (limited to 'pcre/pcregrep.c')
-rw-r--r-- | pcre/pcregrep.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/pcre/pcregrep.c b/pcre/pcregrep.c index fd2a67622ba..317f7454e13 100644 --- a/pcre/pcregrep.c +++ b/pcre/pcregrep.c @@ -1804,11 +1804,6 @@ while (ptr < endptr) if (line_buffered) fflush(stdout); rc = 0; /* Had some success */ - /* If the current match ended past the end of the line (only possible - in multiline mode), we are done with this line. */ - - if ((unsigned int)offsets[1] > linelength) goto END_ONE_MATCH; - startoffset = offsets[1]; /* Restart after the match */ if (startoffset <= oldstartoffset) { @@ -1818,6 +1813,22 @@ while (ptr < endptr) if (utf8) while ((matchptr[startoffset] & 0xc0) == 0x80) startoffset++; } + + /* If the current match ended past the end of the line (only possible + in multiline mode), we must move on to the line in which it did end + before searching for more matches. */ + + while (startoffset > (int)linelength) + { + matchptr = ptr += linelength + endlinelength; + filepos += (int)(linelength + endlinelength); + linenumber++; + startoffset -= (int)(linelength + endlinelength); + t = end_of_line(ptr, endptr, &endlinelength); + linelength = t - ptr - endlinelength; + length = (size_t)(endptr - ptr); + } + goto ONLY_MATCHING_RESTART; } } @@ -3179,9 +3190,11 @@ for (j = 1, cp = patterns; cp != NULL; j++, cp = cp->next) cp->hint = pcre_study(cp->compiled, study_options, &error); if (error != NULL) { - char s[16]; - if (patterns->next == NULL) s[0] = 0; else sprintf(s, " number %d", j); - fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error); + if (patterns->next == NULL) + fprintf(stderr, "pcregrep: Error while studying regex: %s\n", error); + else + fprintf(stderr, "pcregrep: Error while studying regex number %d: %s\n", + j, error); goto EXIT2; } #ifdef SUPPORT_PCREGREP_JIT |