2014-03-07 18:28:52 +01:00
|
|
|
/*************************************************
|
|
|
|
* Perl-Compatible Regular Expressions *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
/* PCRE is a library of functions to support regular expressions whose syntax
|
|
|
|
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
|
2016-01-12 15:44:34 +01:00
|
|
|
New API code Copyright (c) 2016 University of Cambridge
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the University of Cambridge nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pcre2_internal.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Default malloc/free functions *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
/* Ignore the "user data" argument in each case. */
|
|
|
|
|
|
|
|
static void *default_malloc(size_t size, void *data)
|
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
(void)data;
|
2014-03-07 18:28:52 +01:00
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void default_free(void *block, void *data)
|
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
(void)data;
|
2014-03-07 18:28:52 +01:00
|
|
|
free(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
2014-04-30 18:55:24 +02:00
|
|
|
* Get a block and save memory control *
|
2014-03-07 18:28:52 +01:00
|
|
|
*************************************************/
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
/* This internal function is called to get a block of memory in which the
|
2014-08-15 11:19:04 +02:00
|
|
|
memory control data is to be stored at the start for future use.
|
2014-04-30 18:55:24 +02:00
|
|
|
|
|
|
|
Arguments:
|
|
|
|
size amount of memory required
|
2014-05-13 13:20:03 +02:00
|
|
|
memctl pointer to a memctl block or NULL
|
2014-10-20 19:28:49 +02:00
|
|
|
|
2014-04-30 18:55:24 +02:00
|
|
|
Returns: pointer to memory or NULL on failure
|
2014-10-20 19:28:49 +02:00
|
|
|
*/
|
2014-04-30 18:55:24 +02:00
|
|
|
|
2014-12-01 17:14:53 +01:00
|
|
|
extern void *
|
2014-08-15 11:19:04 +02:00
|
|
|
PRIV(memctl_malloc)(size_t size, pcre2_memctl *memctl)
|
2014-04-30 18:55:24 +02:00
|
|
|
{
|
2014-05-13 13:20:03 +02:00
|
|
|
pcre2_memctl *newmemctl;
|
|
|
|
void *yield = (memctl == NULL)? malloc(size) :
|
|
|
|
memctl->malloc(size, memctl->memory_data);
|
2014-10-20 19:28:49 +02:00
|
|
|
if (yield == NULL) return NULL;
|
2014-08-15 11:19:04 +02:00
|
|
|
newmemctl = (pcre2_memctl *)yield;
|
2014-05-13 13:20:03 +02:00
|
|
|
if (memctl == NULL)
|
2014-04-30 18:55:24 +02:00
|
|
|
{
|
2014-05-13 13:20:03 +02:00
|
|
|
newmemctl->malloc = default_malloc;
|
|
|
|
newmemctl->free = default_free;
|
|
|
|
newmemctl->memory_data = NULL;
|
2014-04-30 18:55:24 +02:00
|
|
|
}
|
2014-10-20 19:28:49 +02:00
|
|
|
else *newmemctl = *memctl;
|
2014-04-30 18:55:24 +02:00
|
|
|
return yield;
|
2014-10-20 19:28:49 +02:00
|
|
|
}
|
2014-04-30 18:55:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Create and initialize contexts *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
/* Initializing for compile and match contexts is done in separate, private
|
|
|
|
functions so that these can be called from functions such as pcre2_compile()
|
2014-10-20 19:28:49 +02:00
|
|
|
when an external context is not supplied. The initializing functions have an
|
2014-04-30 18:55:24 +02:00
|
|
|
option to set up default memory management. */
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN pcre2_general_context * PCRE2_CALL_CONVENTION
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_general_context_create(void *(*private_malloc)(size_t, void *),
|
2014-04-18 17:37:56 +02:00
|
|
|
void (*private_free)(void *, void *), void *memory_data)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
pcre2_general_context *gcontext;
|
|
|
|
if (private_malloc == NULL) private_malloc = default_malloc;
|
|
|
|
if (private_free == NULL) private_free = default_free;
|
|
|
|
gcontext = private_malloc(sizeof(pcre2_real_general_context), memory_data);
|
2014-04-30 18:55:24 +02:00
|
|
|
if (gcontext == NULL) return NULL;
|
|
|
|
gcontext->memctl.malloc = private_malloc;
|
2014-10-20 19:28:49 +02:00
|
|
|
gcontext->memctl.free = private_free;
|
2014-04-30 18:55:24 +02:00
|
|
|
gcontext->memctl.memory_data = memory_data;
|
2014-04-18 17:37:56 +02:00
|
|
|
return gcontext;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-11 19:05:18 +02:00
|
|
|
/* A default compile context is set up to save having to initialize at run time
|
|
|
|
when no context is supplied to the compile function. */
|
2014-04-30 18:55:24 +02:00
|
|
|
|
2014-10-11 19:05:18 +02:00
|
|
|
const pcre2_compile_context PRIV(default_compile_context) = {
|
2015-11-05 18:33:39 +01:00
|
|
|
{ default_malloc, default_free, NULL }, /* Default memory handling */
|
|
|
|
NULL, /* Stack guard */
|
|
|
|
NULL, /* Stack guard data */
|
|
|
|
PRIV(default_tables), /* Character tables */
|
|
|
|
PCRE2_UNSET, /* Max pattern length */
|
|
|
|
BSR_DEFAULT, /* Backslash R default */
|
|
|
|
NEWLINE_DEFAULT, /* Newline convention */
|
|
|
|
PARENS_NEST_LIMIT }; /* As it says */
|
2014-10-11 19:05:18 +02:00
|
|
|
|
|
|
|
/* The create function copies the default into the new memory, but must
|
|
|
|
override the default memory handling functions if a gcontext was provided. */
|
2014-04-30 18:55:24 +02:00
|
|
|
|
|
|
|
PCRE2_EXP_DEFN pcre2_compile_context * PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_compile_context_create(pcre2_general_context *gcontext)
|
|
|
|
{
|
|
|
|
pcre2_compile_context *ccontext = PRIV(memctl_malloc)(
|
2014-10-20 19:28:49 +02:00
|
|
|
sizeof(pcre2_real_compile_context), (pcre2_memctl *)gcontext);
|
|
|
|
if (ccontext == NULL) return NULL;
|
2014-10-11 19:05:18 +02:00
|
|
|
*ccontext = PRIV(default_compile_context);
|
|
|
|
if (gcontext != NULL)
|
|
|
|
*((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
|
2014-04-18 17:37:56 +02:00
|
|
|
return ccontext;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-11 19:05:18 +02:00
|
|
|
/* A default match context is set up to save having to initialize at run time
|
|
|
|
when no context is supplied to a match function. */
|
2014-04-30 18:55:24 +02:00
|
|
|
|
2014-10-11 19:05:18 +02:00
|
|
|
const pcre2_match_context PRIV(default_match_context) = {
|
|
|
|
{ default_malloc, default_free, NULL },
|
2014-10-20 19:28:49 +02:00
|
|
|
#ifdef HEAP_MATCH_RECURSE
|
2014-10-11 19:05:18 +02:00
|
|
|
{ default_malloc, default_free, NULL },
|
2014-11-07 13:12:52 +01:00
|
|
|
#endif
|
|
|
|
#ifdef SUPPORT_JIT
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-10-11 19:05:18 +02:00
|
|
|
#endif
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2015-11-05 18:33:39 +01:00
|
|
|
PCRE2_UNSET, /* Offset limit */
|
2014-10-11 19:05:18 +02:00
|
|
|
MATCH_LIMIT,
|
2014-10-20 19:28:49 +02:00
|
|
|
MATCH_LIMIT_RECURSION };
|
|
|
|
|
2014-10-11 19:05:18 +02:00
|
|
|
/* The create function copies the default into the new memory, but must
|
|
|
|
override the default memory handling functions if a gcontext was provided. */
|
2014-04-30 18:55:24 +02:00
|
|
|
|
|
|
|
PCRE2_EXP_DEFN pcre2_match_context * PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_match_context_create(pcre2_general_context *gcontext)
|
|
|
|
{
|
|
|
|
pcre2_match_context *mcontext = PRIV(memctl_malloc)(
|
2014-10-20 19:28:49 +02:00
|
|
|
sizeof(pcre2_real_match_context), (pcre2_memctl *)gcontext);
|
|
|
|
if (mcontext == NULL) return NULL;
|
2014-10-11 19:05:18 +02:00
|
|
|
*mcontext = PRIV(default_match_context);
|
|
|
|
if (gcontext != NULL)
|
|
|
|
*((pcre2_memctl *)mcontext) = *((pcre2_memctl *)gcontext);
|
2014-04-18 17:37:56 +02:00
|
|
|
return mcontext;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
2014-04-18 17:37:56 +02:00
|
|
|
* Context copy functions *
|
2014-03-07 18:28:52 +01:00
|
|
|
*************************************************/
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN pcre2_general_context * PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_general_context_copy(pcre2_general_context *gcontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_general_context *new =
|
|
|
|
gcontext->memctl.malloc(sizeof(pcre2_real_general_context),
|
2014-04-30 18:55:24 +02:00
|
|
|
gcontext->memctl.memory_data);
|
2014-04-18 17:37:56 +02:00
|
|
|
if (new == NULL) return NULL;
|
|
|
|
memcpy(new, gcontext, sizeof(pcre2_real_general_context));
|
|
|
|
return new;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN pcre2_compile_context * PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_compile_context_copy(pcre2_compile_context *ccontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_compile_context *new =
|
|
|
|
ccontext->memctl.malloc(sizeof(pcre2_real_compile_context),
|
2014-04-30 18:55:24 +02:00
|
|
|
ccontext->memctl.memory_data);
|
2014-04-18 17:37:56 +02:00
|
|
|
if (new == NULL) return NULL;
|
|
|
|
memcpy(new, ccontext, sizeof(pcre2_real_compile_context));
|
|
|
|
return new;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN pcre2_match_context * PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_match_context_copy(pcre2_match_context *mcontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_match_context *new =
|
|
|
|
mcontext->memctl.malloc(sizeof(pcre2_real_match_context),
|
2014-04-30 18:55:24 +02:00
|
|
|
mcontext->memctl.memory_data);
|
2014-04-18 17:37:56 +02:00
|
|
|
if (new == NULL) return NULL;
|
|
|
|
memcpy(new, mcontext, sizeof(pcre2_real_match_context));
|
|
|
|
return new;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
/*************************************************
|
|
|
|
* Context free functions *
|
|
|
|
*************************************************/
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_general_context_free(pcre2_general_context *gcontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-05-13 13:20:03 +02:00
|
|
|
if (gcontext != NULL)
|
|
|
|
gcontext->memctl.free(gcontext, gcontext->memctl.memory_data);
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_compile_context_free(pcre2_compile_context *ccontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-05-13 13:20:03 +02:00
|
|
|
if (ccontext != NULL)
|
|
|
|
ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
|
2014-04-18 17:37:56 +02:00
|
|
|
pcre2_match_context_free(pcre2_match_context *mcontext)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-05-13 13:20:03 +02:00
|
|
|
if (mcontext != NULL)
|
|
|
|
mcontext->memctl.free(mcontext, mcontext->memctl.memory_data);
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Set values in contexts *
|
|
|
|
*************************************************/
|
|
|
|
|
2014-09-19 09:43:39 +02:00
|
|
|
/* All these functions return 0 for success or PCRE2_ERROR_BADDATA if invalid
|
|
|
|
data is given. Only some of the functions are able to test the validity of the
|
|
|
|
data. */
|
2014-03-07 18:28:52 +01:00
|
|
|
|
2014-06-24 11:51:58 +02:00
|
|
|
|
|
|
|
/* ------------ Compile contexts ------------ */
|
|
|
|
|
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_set_character_tables(pcre2_compile_context *ccontext,
|
2014-06-24 11:51:58 +02:00
|
|
|
const unsigned char *tables)
|
|
|
|
{
|
|
|
|
ccontext->tables = tables;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-06-24 11:51:58 +02:00
|
|
|
}
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-10-01 19:02:33 +02:00
|
|
|
pcre2_set_bsr(pcre2_compile_context *ccontext, uint32_t value)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
|
|
|
switch(value)
|
|
|
|
{
|
|
|
|
case PCRE2_BSR_ANYCRLF:
|
|
|
|
case PCRE2_BSR_UNICODE:
|
2014-04-18 17:37:56 +02:00
|
|
|
ccontext->bsr_convention = value;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-10-20 19:28:49 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
default:
|
2014-10-20 19:28:49 +02:00
|
|
|
return PCRE2_ERROR_BADDATA;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-05 18:33:39 +01:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_set_max_pattern_length(pcre2_compile_context *ccontext, PCRE2_SIZE length)
|
|
|
|
{
|
|
|
|
ccontext->max_pattern_length = length;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-10-01 19:02:33 +02:00
|
|
|
pcre2_set_newline(pcre2_compile_context *ccontext, uint32_t newline)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
|
|
|
switch(newline)
|
|
|
|
{
|
|
|
|
case PCRE2_NEWLINE_CR:
|
|
|
|
case PCRE2_NEWLINE_LF:
|
|
|
|
case PCRE2_NEWLINE_CRLF:
|
|
|
|
case PCRE2_NEWLINE_ANY:
|
|
|
|
case PCRE2_NEWLINE_ANYCRLF:
|
2014-04-18 17:37:56 +02:00
|
|
|
ccontext->newline_convention = newline;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-10-20 19:28:49 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
return PCRE2_ERROR_BADDATA;
|
|
|
|
}
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-04-18 17:37:56 +02:00
|
|
|
pcre2_set_parens_nest_limit(pcre2_compile_context *ccontext, uint32_t limit)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
ccontext->parens_nest_limit = limit;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_set_compile_recursion_guard(pcre2_compile_context *ccontext,
|
2014-11-26 17:51:53 +01:00
|
|
|
int (*guard)(uint32_t, void *), void *user_data)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
ccontext->stack_guard = guard;
|
2014-11-26 17:51:53 +01:00
|
|
|
ccontext->stack_guard_data = user_data;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 11:51:58 +02:00
|
|
|
/* ------------ Match contexts ------------ */
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_set_callout(pcre2_match_context *mcontext,
|
2014-11-25 18:35:01 +01:00
|
|
|
int (*callout)(pcre2_callout_block *, void *), void *callout_data)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
mcontext->callout = callout;
|
2014-06-28 16:23:18 +02:00
|
|
|
mcontext->callout_data = callout_data;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-04-18 17:37:56 +02:00
|
|
|
pcre2_set_match_limit(pcre2_match_context *mcontext, uint32_t limit)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
mcontext->match_limit = limit;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-04-18 17:37:56 +02:00
|
|
|
}
|
2014-03-07 18:28:52 +01:00
|
|
|
|
2015-09-22 13:24:28 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_set_offset_limit(pcre2_match_context *mcontext, PCRE2_SIZE limit)
|
|
|
|
{
|
|
|
|
mcontext->offset_limit = limit;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
|
|
|
pcre2_set_recursion_limit(pcre2_match_context *mcontext, uint32_t limit)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2014-04-18 17:37:56 +02:00
|
|
|
mcontext->recursion_limit = limit;
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
2014-04-18 17:37:56 +02:00
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2014-10-20 19:28:49 +02:00
|
|
|
pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
|
|
|
|
void *(*mymalloc)(size_t, void *), void (*myfree)(void *, void *),
|
2014-07-04 18:26:09 +02:00
|
|
|
void *mydata)
|
2014-04-18 17:37:56 +02:00
|
|
|
{
|
2014-08-16 11:46:58 +02:00
|
|
|
#ifdef HEAP_MATCH_RECURSE
|
2014-07-04 18:26:09 +02:00
|
|
|
mcontext->stack_memctl.malloc = mymalloc;
|
|
|
|
mcontext->stack_memctl.free = myfree;
|
|
|
|
mcontext->stack_memctl.memory_data = mydata;
|
2014-04-18 17:37:56 +02:00
|
|
|
#else
|
|
|
|
(void)mcontext;
|
|
|
|
(void)mymalloc;
|
|
|
|
(void)myfree;
|
2014-07-04 18:26:09 +02:00
|
|
|
(void)mydata;
|
2014-04-18 17:37:56 +02:00
|
|
|
#endif
|
2014-09-19 09:43:39 +02:00
|
|
|
return 0;
|
2014-10-20 19:28:49 +02:00
|
|
|
}
|
2014-04-18 17:37:56 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
/* End of pcre2_context.c */
|