Git-Raw
view release on metacpan or search on metacpan
deps/libgit2/deps/pcre/pcre_compile.c view on Meta::CPAN
case 0x2029:
#endif /* Not EBCDIC */
return FALSE;
}
break;
case OP_EOD: /* Can always possessify before \z */
break;
#ifdef SUPPORT_UCP
case OP_PROP:
case OP_NOTPROP:
if (!check_char_prop(chr, list_ptr[2], list_ptr[3],
list_ptr[0] == OP_NOTPROP))
return FALSE;
break;
#endif
case OP_NCLASS:
if (chr > 255) return FALSE;
/* Fall through */
case OP_CLASS:
if (chr > 255) break;
class_bitset = (pcre_uint8 *)
((list_ptr == list ? code : base_end) - list_ptr[2]);
if ((class_bitset[chr >> 3] & (1U << (chr & 7))) != 0) return FALSE;
break;
#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
case OP_XCLASS:
if (PRIV(xclass)(chr, (list_ptr == list ? code : base_end) -
list_ptr[2] + LINK_SIZE, utf)) return FALSE;
break;
#endif
default:
return FALSE;
}
chr_ptr++;
}
while(*chr_ptr != NOTACHAR);
/* At least one character must be matched from this opcode. */
if (list[1] == 0) return TRUE;
}
/* Control never reaches here. There used to be a fail-save return FALSE; here,
but some compilers complain about an unreachable statement. */
}
/*************************************************
* Scan compiled regex for auto-possession *
*************************************************/
/* Replaces single character iterations with their possessive alternatives
if appropriate. This function modifies the compiled opcode!
Arguments:
code points to start of the byte code
utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
cd static compile data
Returns: nothing
*/
static void
auto_possessify(pcre_uchar *code, BOOL utf, const compile_data *cd)
{
register pcre_uchar c;
const pcre_uchar *end;
pcre_uchar *repeat_opcode;
pcre_uint32 list[8];
int rec_limit;
for (;;)
{
c = *code;
/* When a pattern with bad UTF-8 encoding is compiled with NO_UTF_CHECK,
it may compile without complaining, but may get into a loop here if the code
pointer points to a bad value. This is, of course a documentated possibility,
when NO_UTF_CHECK is set, so it isn't a bug, but we can detect this case and
just give up on this optimization. */
if (c >= OP_TABLE_LENGTH) return;
if (c >= OP_STAR && c <= OP_TYPEPOSUPTO)
{
c -= get_repeat_base(c) - OP_STAR;
end = (c <= OP_MINUPTO) ?
get_chr_property_list(code, utf, cd->fcc, list) : NULL;
list[1] = c == OP_STAR || c == OP_PLUS || c == OP_QUERY || c == OP_UPTO;
rec_limit = 1000;
if (end != NULL && compare_opcodes(end, utf, cd, list, end, &rec_limit))
{
switch(c)
{
case OP_STAR:
*code += OP_POSSTAR - OP_STAR;
break;
case OP_MINSTAR:
*code += OP_POSSTAR - OP_MINSTAR;
break;
case OP_PLUS:
*code += OP_POSPLUS - OP_PLUS;
break;
case OP_MINPLUS:
*code += OP_POSPLUS - OP_MINPLUS;
break;
case OP_QUERY:
( run in 0.698 second using v1.01-cache-2.11-cpan-e1769b4cff6 )