Skip to content

Commit

Permalink
pcre2lib: Pull PCRE2 10.37
Browse files Browse the repository at this point in the history
Excerpt from the release news:

Version 10.37 26-May-2021
-------------------------

A few more bug fixes and tidies. The only change of real note is the removal of
the actual POSIX names regcomp etc. from the POSIX wrapper library because
these have caused issues for some applications (see 10.33 #2 below).

Version 10.36 04-December-2020
------------------------------

Again, mainly bug fixes and tidies. The only enhancements are the addition of
GNU grep's -m (aka --max-count) option to pcre2grep, and also unifying the
handling of substitution strings for both -O and callouts in pcre2grep, with
the addition of $x{...} and $o{...} to allow for characters whose code points
are greater than 255 in Unicode mode.

NOTE: there is an outstanding issue with JIT support for MacOS on arm64
hardware. For details, please see Bugzilla issue php#2618.

Signed-off-by: Anatol Belski <[email protected]>
  • Loading branch information
weltling committed May 29, 2021
1 parent 56c1633 commit 5d42900
Show file tree
Hide file tree
Showing 32 changed files with 4,630 additions and 13,576 deletions.
4 changes: 2 additions & 2 deletions ext/pcre/pcre2lib/pcre2.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */

#define PCRE2_MAJOR 10
#define PCRE2_MINOR 35
#define PCRE2_MINOR 37
#define PCRE2_PRERELEASE
#define PCRE2_DATE 2020-05-09
#define PCRE2_DATE 2021-05-26

/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
Expand Down
13 changes: 9 additions & 4 deletions ext/pcre/pcre2lib/pcre2_auto_possess.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2020 University of Cambridge
New API code Copyright (c) 2016-2021 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -490,6 +490,7 @@ switch(c)
list[2] = (uint32_t)(end - code);
return end;
}

return NULL; /* Opcode not accepted */
}

Expand Down Expand Up @@ -1186,12 +1187,16 @@ for (;;)
c = *repeat_opcode;
if (c >= OP_CRSTAR && c <= OP_CRMINRANGE)
{
/* end must not be NULL. */
end = get_chr_property_list(code, utf, ucp, cb->fcc, list);
/* The return from get_chr_property_list() will never be NULL when
*code (aka c) is one of the three class opcodes. However, gcc with
-fanalyzer notes that a NULL return is possible, and grumbles. Hence we
put in a check. */

end = get_chr_property_list(code, utf, ucp, cb->fcc, list);
list[1] = (c & 1) == 0;

if (compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
if (end != NULL &&
compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
{
switch (c)
{
Expand Down
202 changes: 0 additions & 202 deletions ext/pcre/pcre2lib/pcre2_chartables.c

This file was deleted.

1 change: 1 addition & 0 deletions ext/pcre/pcre2lib/pcre2_chartables.c
55 changes: 37 additions & 18 deletions ext/pcre/pcre2lib/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,32 +1398,47 @@ static BOOL
read_repeat_counts(PCRE2_SPTR *ptrptr, PCRE2_SPTR ptrend, uint32_t *minp,
uint32_t *maxp, int *errorcodeptr)
{
PCRE2_SPTR p = *ptrptr;
PCRE2_SPTR p;
BOOL yield = FALSE;
BOOL had_comma = FALSE;
int32_t min = 0;
int32_t max = REPEAT_UNLIMITED; /* This value is larger than MAX_REPEAT_COUNT */

/* NB read_number() initializes the error code to zero. The only error is for a
number that is too big. */
/* Check the syntax */

*errorcodeptr = 0;
for (p = *ptrptr;; p++)
{
uint32_t c;
if (p >= ptrend) return FALSE;
c = *p;
if (IS_DIGIT(c)) continue;
if (c == CHAR_RIGHT_CURLY_BRACKET) break;
if (c == CHAR_COMMA)
{
if (had_comma) return FALSE;
had_comma = TRUE;
}
else return FALSE;
}

/* The only error from read_number() is for a number that is too big. */

p = *ptrptr;
if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &min, errorcodeptr))
goto EXIT;

if (p >= ptrend) goto EXIT;

if (*p == CHAR_RIGHT_CURLY_BRACKET)
{
p++;
max = min;
}

else
{
if (*p++ != CHAR_COMMA || p >= ptrend) goto EXIT;
if (*p != CHAR_RIGHT_CURLY_BRACKET)
if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
{
if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &max,
errorcodeptr) || p >= ptrend || *p != CHAR_RIGHT_CURLY_BRACKET)
errorcodeptr))
goto EXIT;
if (max < min)
{
Expand All @@ -1438,11 +1453,10 @@ yield = TRUE;
if (minp != NULL) *minp = (uint32_t)min;
if (maxp != NULL) *maxp = (uint32_t)max;

/* Update the pattern pointer on success, or after an error, but not when
the result is "not a repeat quantifier". */
/* Update the pattern pointer */

EXIT:
if (yield || *errorcodeptr != 0) *ptrptr = p;
*ptrptr = p;
return yield;
}

Expand Down Expand Up @@ -1776,19 +1790,23 @@ else
{
oldptr = ptr;
ptr--; /* Back to the digit */
if (!read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, ERR61, &s,
errorcodeptr))
break;

/* \1 to \9 are always back references. \8x and \9x are too; \1x to \7x
/* As we know we are at a digit, the only possible error from
read_number() is a number that is too large to be a group number. In this
case we fall through handle this as not a group reference. If we have
read a small enough number, check for a back reference.
\1 to \9 are always back references. \8x and \9x are too; \1x to \7x
are octal escapes if there are not that many previous captures. */

if (s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount)
if (read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, 0, &s, errorcodeptr) &&
(s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount))
{
if (s > (int)MAX_GROUP_NUMBER) *errorcodeptr = ERR61;
else escape = -s; /* Indicates a back reference */
break;
}

ptr = oldptr; /* Put the pointer back and fall through */
}

Expand Down Expand Up @@ -2344,7 +2362,7 @@ if (ptr > *nameptr + MAX_NAME_SIZE)
*errorcodeptr = ERR48;
goto FAILED;
}
*namelenptr = ptr - *nameptr;
*namelenptr = (uint32_t)(ptr - *nameptr);

/* Subpattern names must not be empty, and their terminator is checked here.
(What follows a verb or alpha assertion name is checked separately.) */
Expand Down Expand Up @@ -4331,6 +4349,7 @@ while (ptr < ptrend)
{
if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
minor = (*ptr++ - CHAR_0) * 10;
if (ptr >= ptrend) goto BAD_VERSION_CONDITION;
if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0;
if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
goto BAD_VERSION_CONDITION;
Expand Down
Loading

0 comments on commit 5d42900

Please sign in to comment.