|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Perl-Compatible Regular Expressions *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/* PCRE is a library of functions to support regular expressions whose syntax
|
|
Packit |
504f36 |
and semantics are as close as possible to those of the Perl 5 language.
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
Written by Philip Hazel
|
|
Packit |
504f36 |
Original API code Copyright (c) 1997-2012 University of Cambridge
|
|
Packit |
504f36 |
New API code Copyright (c) 2016-2017 University of Cambridge
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
-----------------------------------------------------------------------------
|
|
Packit |
504f36 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
504f36 |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
* Redistributions of source code must retain the above copyright notice,
|
|
Packit |
504f36 |
this list of conditions and the following disclaimer.
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
* Redistributions in binary form must reproduce the above copyright
|
|
Packit |
504f36 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
504f36 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
* Neither the name of the University of Cambridge nor the names of its
|
|
Packit |
504f36 |
contributors may be used to endorse or promote products derived from
|
|
Packit |
504f36 |
this software without specific prior written permission.
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
504f36 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
504f36 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
504f36 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
504f36 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
504f36 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
504f36 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
504f36 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
504f36 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
504f36 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
504f36 |
POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
504f36 |
-----------------------------------------------------------------------------
|
|
Packit |
504f36 |
*/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
504f36 |
#include "config.h"
|
|
Packit |
504f36 |
#endif
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
#include "pcre2_internal.h"
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Create a match data block given ovector size *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/* A minimum of 1 is imposed on the number of ovector pairs. */
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
pcre2_match_data *yield;
|
|
Packit |
504f36 |
if (oveccount < 1) oveccount = 1;
|
|
Packit |
504f36 |
yield = PRIV(memctl_malloc)(
|
|
Packit |
504f36 |
offsetof(pcre2_match_data, ovector) + 2*oveccount*sizeof(PCRE2_SIZE),
|
|
Packit |
504f36 |
(pcre2_memctl *)gcontext);
|
|
Packit |
504f36 |
if (yield == NULL) return NULL;
|
|
Packit |
504f36 |
yield->oveccount = oveccount;
|
|
Packit |
504f36 |
return yield;
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Create a match data block using pattern data *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/* If no context is supplied, use the memory allocator from the code. */
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_match_data_create_from_pattern(const pcre2_code *code,
|
|
Packit |
504f36 |
pcre2_general_context *gcontext)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
if (gcontext == NULL) gcontext = (pcre2_general_context *)code;
|
|
Packit |
504f36 |
return pcre2_match_data_create(((pcre2_real_code *)code)->top_bracket + 1,
|
|
Packit |
504f36 |
gcontext);
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Free a match data block *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_match_data_free(pcre2_match_data *match_data)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
if (match_data != NULL)
|
|
Packit |
504f36 |
match_data->memctl.free(match_data, match_data->memctl.memory_data);
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Get last mark in match *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN PCRE2_SPTR PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_get_mark(pcre2_match_data *match_data)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
return match_data->mark;
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Get pointer to ovector *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN PCRE2_SIZE * PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_get_ovector_pointer(pcre2_match_data *match_data)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
return match_data->ovector;
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Get number of ovector slots *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_get_ovector_count(pcre2_match_data *match_data)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
return match_data->oveccount;
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/*************************************************
|
|
Packit |
504f36 |
* Get starting code unit in match *
|
|
Packit |
504f36 |
*************************************************/
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
PCRE2_EXP_DEFN PCRE2_SIZE PCRE2_CALL_CONVENTION
|
|
Packit |
504f36 |
pcre2_get_startchar(pcre2_match_data *match_data)
|
|
Packit |
504f36 |
{
|
|
Packit |
504f36 |
return match_data->startchar;
|
|
Packit |
504f36 |
}
|
|
Packit |
504f36 |
|
|
Packit |
504f36 |
/* End of pcre2_match_data.c */
|