deps: pcre2 updates with c90 compatible syntax

Yes, the world has moved on from us.
This commit is contained in:
Edward Thomson
2026-05-26 16:00:47 +01:00
parent 993397a603
commit 64469259a5
9 changed files with 56 additions and 41 deletions

View File

@@ -6086,6 +6086,8 @@ uint32_t meta, meta_arg;
uint32_t firstcuflags, reqcuflags;
uint32_t zeroreqcuflags, zerofirstcuflags;
uint32_t req_caseopt, reqvary, tempreqvary;
uint32_t j;
int i;
/* Some opcodes, such as META_CAPTURE_NUMBER or META_CAPTURE_NAME,
depends on the previous value of offset. */
PCRE2_SIZE offset = 0;
@@ -6542,7 +6544,7 @@ for (;; pptr++)
verbarglen = *(++pptr);
verbculen = 0;
tempcode = code++;
for (int i = 0; i < (int)verbarglen; i++)
for (i = 0; i < (int)verbarglen; i++)
{
meta = *(++pptr);
#ifdef SUPPORT_UNICODE
@@ -7482,7 +7484,7 @@ for (;; pptr++)
}
*lengthptr += delta;
}
else for (int i = 0; i < replicate; i++)
else for (i = 0; i < replicate; i++)
{
memcpy(code, previous, CU2BYTES(length_prevgroup));
previous = code;
@@ -7665,7 +7667,7 @@ for (;; pptr++)
reqcu = firstcu;
reqcuflags = firstcuflags;
}
for (uint32_t i = 1; i < repeat_min; i++)
for (j = 1; j < repeat_min; j++)
{
memcpy(code, previous, CU2BYTES(len));
code += len;
@@ -7707,7 +7709,7 @@ for (;; pptr++)
/* This is compiling for real */
else for (uint32_t i = repeat_max; i >= 1; i--)
else for (i = repeat_max; i >= 1; i--)
{
*code++ = OP_BRAZERO + repeat_type;

View File

@@ -1076,6 +1076,7 @@ const uint8_t *cbits = cb->cbits;
/* Some functions such as add_to_class() or eclass processing
expects that the bitset is stored in cb->classbits.classbits. */
uint8_t *const classbits = cb->classbits.classbits;
int i;
#ifdef SUPPORT_UNICODE
BOOL utf = (options & PCRE2_UTF) != 0;
@@ -1173,6 +1174,7 @@ while (TRUE)
int taboffset, tabopt;
class_bits_storage pbits;
uint32_t escape, c;
int i;
/* Handle POSIX classes such as [:alpha:] etc. */
switch (META_CODE(meta))
@@ -1272,10 +1274,10 @@ while (TRUE)
if (taboffset >= 0)
{
if (tabopt >= 0)
for (int i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
pbits.classbits[i] |= cbits[i + taboffset];
else
for (int i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
pbits.classbits[i] &= (uint8_t)(~cbits[i + taboffset]);
}
@@ -1308,10 +1310,10 @@ while (TRUE)
uint32_t *classwords = cb->classbits.classwords;
if (local_negate)
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
classwords[i] |= (uint32_t)(~pbits.classwords[i]);
else
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
classwords[i] |= pbits.classwords[i];
}
@@ -1333,22 +1335,22 @@ while (TRUE)
switch(escape)
{
case ESC_d:
for (int i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_digit];
for (i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_digit];
break;
case ESC_D:
should_flip_negation = TRUE;
for (int i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
classbits[i] |= (uint8_t)(~cbits[i+cbit_digit]);
break;
case ESC_w:
for (int i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_word];
for (i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_word];
break;
case ESC_W:
should_flip_negation = TRUE;
for (int i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
classbits[i] |= (uint8_t)(~cbits[i+cbit_word]);
break;
@@ -1360,12 +1362,12 @@ while (TRUE)
longer treat \s and \S specially. */
case ESC_s:
for (int i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_space];
for (i = 0; i < 32; i++) classbits[i] |= cbits[i+cbit_space];
break;
case ESC_S:
should_flip_negation = TRUE;
for (int i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
classbits[i] |= (uint8_t)(~cbits[i+cbit_space]);
break;
@@ -1717,7 +1719,7 @@ if ((xclass_props & XCLASS_REQUIRED) != 0)
if (negate_class)
{
uint32_t *classwords = cb->classbits.classwords;
for (int i = 0; i < 8; i++) classwords[i] = ~classwords[i];
for (i = 0; i < 8; i++) classwords[i] = ~classwords[i];
}
if (has_bitmap == NULL)
@@ -1838,7 +1840,7 @@ if (negate_class)
{
uint32_t *classwords = cb->classbits.classwords;
for (int i = 0; i < 8; i++) classwords[i] = ~classwords[i];
for (i = 0; i < 8; i++) classwords[i] = ~classwords[i];
}
if ((SELECT_VALUE8(!utf, 0) || negate_class != should_flip_negation) &&
@@ -1880,6 +1882,8 @@ static void
fold_negation(eclass_op_info *pop_info, PCRE2_SIZE *lengthptr,
BOOL preserve_classbits)
{
int i;
/* If the chunk of stack code is already composed of multiple ops, we won't
descend in and try and propagate the negation down the tree. (That would lead
to O(n^2) compile-time, which could be exploitable with a malicious regex -
@@ -1916,7 +1920,7 @@ else
if (!preserve_classbits)
{
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
pop_info->bits.classwords[i] = ~pop_info->bits.classwords[i];
}
}
@@ -1930,6 +1934,8 @@ static void
fold_binary(int op, eclass_op_info *lhs_op_info, eclass_op_info *rhs_op_info,
PCRE2_SIZE *lengthptr)
{
int i;
switch (op)
{
/* ECL_AND truth table:
@@ -1984,7 +1990,7 @@ switch (op)
lhs_op_info->op_single_type = 0;
}
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
lhs_op_info->bits.classwords[i] &= rhs_op_info->bits.classwords[i];
break;
@@ -2040,7 +2046,7 @@ switch (op)
lhs_op_info->op_single_type = 0;
}
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
lhs_op_info->bits.classwords[i] |= rhs_op_info->bits.classwords[i];
break;
@@ -2103,7 +2109,7 @@ switch (op)
lhs_op_info->op_single_type = 0;
}
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
lhs_op_info->bits.classwords[i] ^= rhs_op_info->bits.classwords[i];
break;
@@ -2138,6 +2144,7 @@ PCRE2_UCHAR *code_start = code;
PCRE2_SIZE prev_length = (lengthptr != NULL)? *lengthptr : 0;
PCRE2_SIZE extra_length;
uint32_t meta = META_CODE(*ptr);
int i;
switch (meta)
{
@@ -2240,7 +2247,7 @@ switch (meta)
{
uint32_t *classwords = pop_info->bits.classwords;
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
if (classwords[i] != 0)
{
context->needs_bitmap = TRUE;
@@ -2578,6 +2585,7 @@ PCRE2_SIZE previous_length = (lengthptr != NULL)? *lengthptr : 0;
PCRE2_UCHAR *code = *pcode;
PCRE2_UCHAR *previous;
BOOL allbitsone = TRUE;
int i;
context.needs_bitmap = FALSE;
context.options = options;
@@ -2603,7 +2611,7 @@ if (lengthptr != NULL)
}
/* Do some useful counting of what's in the bitmap. */
for (int i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
if (op_info.bits.classwords[i] != 0xffffffff)
{
allbitsone = FALSE;

View File

@@ -72,7 +72,8 @@ enum { POSIX_START_REGEX, POSIX_ANCHORED, POSIX_NOT_BRACKET,
#define PUTCHARS(string) \
{ \
for (const char *s = string; *s != 0; s++) \
const char *s; \
for (s = string; *s != 0; s++) \
{ \
if (p >= endp) return PCRE2_ERROR_NOMEMORY; \
*p++ = *s; \
@@ -1125,6 +1126,7 @@ PCRE2_UCHAR *use_buffer = dummy_buffer;
PCRE2_SIZE use_length = DUMMY_BUFFER_SIZE;
BOOL utf = (options & PCRE2_CONVERT_UTF) != 0;
uint32_t pattype = options & TYPE_OPTIONS;
int i;
if (pattern == NULL && plength == 0)
pattern = null_str;
@@ -1180,7 +1182,7 @@ if (buffptr != NULL && *buffptr != NULL)
/* Call an individual converter, either just once (if a buffer was provided or
just the length is needed), or twice (if a memory allocation is required). */
for (int i = 0; i < 2; i++)
for (i = 0; i < 2; i++)
{
PCRE2_UCHAR *allocated;
BOOL dummyrun = buffptr == NULL || *buffptr == NULL;

View File

@@ -2933,6 +2933,7 @@ for (;;)
{
int rc;
int *local_workspace;
dfa_recursion_info *ri;
PCRE2_SIZE *local_offsets;
RWS_anchor *rws = (RWS_anchor *)RWS;
PCRE2_SPTR callpat = start_code + GET(code, 1);
@@ -2957,7 +2958,7 @@ for (;;)
pointer or last used character. This should catch convoluted mutual
recursions. (Some simple cases are caught at compile time.) */
for (dfa_recursion_info *ri = mb->recursive;
for (ri = mb->recursive;
ri != NULL;
ri = ri->prevrec)
{

View File

@@ -80,12 +80,12 @@ PRIV(ord2utf)(uint32_t cvalue, PCRE2_UCHAR *buffer)
/* Convert to UTF-8 */
#if PCRE2_CODE_UNIT_WIDTH == 8
unsigned int i;
unsigned int i, j;
for (i = 0; i < PRIV(utf8_table1_size); i++)
if ((int)cvalue <= PRIV(utf8_table1)[i]) break;
buffer += i;
for (unsigned int j = i; j != 0; j--)
for (j = i; j != 0; j--)
{
*buffer-- = 0x80 | (cvalue & 0x3f);
cvalue >>= 6;

View File

@@ -89,6 +89,7 @@ uint32_t require_map[FULL_MAPSIZE];
uint32_t map[FULL_MAPSIZE];
uint32_t require_digitset = 0;
uint32_t c;
int i;
#if PCRE2_CODE_UNIT_WIDTH == 32
(void)utf; /* Avoid compiler warning */
@@ -105,7 +106,7 @@ every script, as opposed to the maps in ucd_script_sets, which only have bits
for scripts less than ucp_Unknown - those that appear in script extension
lists. */
for (int i = 0; i < FULL_MAPSIZE; i++) require_map[i] = 0;
for (i = 0; i < FULL_MAPSIZE; i++) require_map[i] = 0;
/* Scan strings of two or more characters, checking the Unicode characteristics
of each code point. There is special code for scripts that can be combined with
@@ -244,7 +245,7 @@ for (;;)
case SCRIPT_MAP:
OK = FALSE;
for (int i = 0; i < FULL_MAPSIZE; i++)
for (i = 0; i < FULL_MAPSIZE; i++)
{
if ((require_map[i] & map[i]) != 0)
{
@@ -281,7 +282,7 @@ for (;;)
allowed scripts for this character. */
default:
for (int i = 0; i < FULL_MAPSIZE; i++) require_map[i] &= map[i];
for (i = 0; i < FULL_MAPSIZE; i++) require_map[i] &= map[i];
break;
}

View File

@@ -1095,6 +1095,7 @@ set_start_bits(pcre2_real_code *re, PCRE2_SPTR code, BOOL utf, BOOL ucp,
{
uint32_t c;
int yield = SSB_DONE;
BOOL done;
#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8
int table_limit = utf? 16:32;
@@ -1261,7 +1262,7 @@ do
/* Skip irrelevant items */
for (BOOL done = FALSE; !done;)
for (done = FALSE; !done;)
{
switch (*ncode)
{

View File

@@ -261,7 +261,7 @@ return FALSE;
*************************************************/
#define PCRE2_SUBSTITUTE_CASE_NONE 0
// 1, 2, 3 are PCRE2_SUBSTITUTE_CASE_LOWER, UPPER, TITLE_FIRST.
/* 1, 2, 3 are PCRE2_SUBSTITUTE_CASE_LOWER, UPPER, TITLE_FIRST. */
#define PCRE2_SUBSTITUTE_CASE_REVERSE_TITLE_FIRST 4
typedef struct {
@@ -330,18 +330,18 @@ switch (state->to_case)
return 0;
/* LCOV_EXCL_STOP */
case PCRE2_SUBSTITUTE_CASE_LOWER: // Can be single_char TRUE or FALSE
case PCRE2_SUBSTITUTE_CASE_UPPER: // Can only be single_char FALSE
case PCRE2_SUBSTITUTE_CASE_LOWER: /* Can be single_char TRUE or FALSE */
case PCRE2_SUBSTITUTE_CASE_UPPER: /* Can only be single_char FALSE */
next_to_upper = rest_to_upper = (state->to_case == PCRE2_SUBSTITUTE_CASE_UPPER);
break;
case PCRE2_SUBSTITUTE_CASE_TITLE_FIRST: // Can be single_char TRUE or FALSE
case PCRE2_SUBSTITUTE_CASE_TITLE_FIRST: /* Can be single_char TRUE or FALSE */
next_to_upper = TRUE;
rest_to_upper = FALSE;
state->to_case = PCRE2_SUBSTITUTE_CASE_LOWER;
break;
case PCRE2_SUBSTITUTE_CASE_REVERSE_TITLE_FIRST: // Can only be single_char FALSE
case PCRE2_SUBSTITUTE_CASE_REVERSE_TITLE_FIRST: /* Can only be single_char FALSE */
next_to_upper = FALSE;
rest_to_upper = TRUE;
state->to_case = PCRE2_SUBSTITUTE_CASE_UPPER;
@@ -470,9 +470,9 @@ switch (state->to_case)
return 0;
/* LCOV_EXCL_STOP */
case PCRE2_SUBSTITUTE_CASE_LOWER: // Can be single_char TRUE or FALSE
case PCRE2_SUBSTITUTE_CASE_UPPER: // Can only be single_char FALSE
case PCRE2_SUBSTITUTE_CASE_TITLE_FIRST: // Can be single_char TRUE or FALSE
case PCRE2_SUBSTITUTE_CASE_LOWER: /* Can be single_char TRUE or FALSE */
case PCRE2_SUBSTITUTE_CASE_UPPER: /* Can only be single_char FALSE */
case PCRE2_SUBSTITUTE_CASE_TITLE_FIRST: /* Can be single_char TRUE or FALSE */
/* The easy case, where our internal casing operations align with those of
the callout. */
@@ -492,7 +492,7 @@ switch (state->to_case)
rest_to_case = PCRE2_SUBSTITUTE_CASE_NONE;
break;
case PCRE2_SUBSTITUTE_CASE_REVERSE_TITLE_FIRST: // Can only be single_char FALSE
case PCRE2_SUBSTITUTE_CASE_REVERSE_TITLE_FIRST: /* Can only be single_char FALSE */
ch1_to_case = PCRE2_SUBSTITUTE_CASE_LOWER;
rest_to_case = PCRE2_SUBSTITUTE_CASE_UPPER;
break;

View File

@@ -141,7 +141,7 @@ and also specially-formatted comments.
This macro should be used with no following semicolon, and ideally with a comment: */
// PCRE2_FALLTHROUGH /* Fall through */
/* PCRE2_FALLTHROUGH */ /* Fall through */
#ifndef PCRE2_FALLTHROUGH