version 1.1, 2012/02/21 23:05:51
|
version 1.1.1.5, 2014/06/15 19:46:04
|
Line 6
|
Line 6
|
and semantics are as close as possible to those of the Perl 5 language. |
and semantics are as close as possible to those of the Perl 5 language. |
|
|
Written by Philip Hazel |
Written by Philip Hazel |
Copyright (c) 1997-2011 University of Cambridge | Copyright (c) 1997-2013 University of Cambridge |
|
|
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 65 Arguments:
|
Line 65 Arguments:
|
Returns: 0 if data returned, negative on error |
Returns: 0 if data returned, negative on error |
*/ |
*/ |
|
|
|
#if defined COMPILE_PCRE8 |
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what, | pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, |
void *where) | int what, void *where) |
| #elif defined COMPILE_PCRE16 |
| PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
| pcre16_fullinfo(const pcre16 *argument_re, const pcre16_extra *extra_data, |
| int what, void *where) |
| #elif defined COMPILE_PCRE32 |
| PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
| pcre32_fullinfo(const pcre32 *argument_re, const pcre32_extra *extra_data, |
| int what, void *where) |
| #endif |
{ |
{ |
real_pcre internal_re; | const REAL_PCRE *re = (const REAL_PCRE *)argument_re; |
pcre_study_data internal_study; | |
const real_pcre *re = (const real_pcre *)argument_re; | |
const pcre_study_data *study = NULL; |
const pcre_study_data *study = NULL; |
|
|
if (re == NULL || where == NULL) return PCRE_ERROR_NULL; |
if (re == NULL || where == NULL) return PCRE_ERROR_NULL; |
Line 79 if (re == NULL || where == NULL) return PCRE_ERROR_NUL
|
Line 87 if (re == NULL || where == NULL) return PCRE_ERROR_NUL
|
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0) |
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0) |
study = (const pcre_study_data *)extra_data->study_data; |
study = (const pcre_study_data *)extra_data->study_data; |
|
|
|
/* Check that the first field in the block is the magic number. If it is not, |
|
return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to |
|
REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which |
|
means that the pattern is likely compiled with different endianness. */ |
|
|
if (re->magic_number != MAGIC_NUMBER) |
if (re->magic_number != MAGIC_NUMBER) |
{ | return re->magic_number == REVERSED_MAGIC_NUMBER? |
re = _pcre_try_flipped(re, &internal_re, study, &internal_study); | PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC; |
if (re == NULL) return PCRE_ERROR_BADMAGIC; | |
if (study != NULL) study = &internal_study; | |
} | |
|
|
|
/* Check that this pattern was compiled in the correct bit mode */ |
|
|
|
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE; |
|
|
switch (what) |
switch (what) |
{ |
{ |
case PCRE_INFO_OPTIONS: |
case PCRE_INFO_OPTIONS: |
Line 106 switch (what)
|
Line 120 switch (what)
|
(extra_data != NULL && |
(extra_data != NULL && |
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && |
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && |
extra_data->executable_jit != NULL)? |
extra_data->executable_jit != NULL)? |
_pcre_jit_get_size(extra_data->executable_jit) : 0; | PRIV(jit_get_size)(extra_data->executable_jit) : 0; |
#else |
#else |
*((size_t *)where) = 0; |
*((size_t *)where) = 0; |
#endif |
#endif |
|
|
break; |
break; |
|
|
case PCRE_INFO_CAPTURECOUNT: |
case PCRE_INFO_CAPTURECOUNT: |
Line 123 switch (what)
|
Line 136 switch (what)
|
|
|
case PCRE_INFO_FIRSTBYTE: |
case PCRE_INFO_FIRSTBYTE: |
*((int *)where) = |
*((int *)where) = |
((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte : | ((re->flags & PCRE_FIRSTSET) != 0)? (int)re->first_char : |
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; |
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; |
break; |
break; |
|
|
|
case PCRE_INFO_FIRSTCHARACTER: |
|
*((pcre_uint32 *)where) = |
|
(re->flags & PCRE_FIRSTSET) != 0 ? re->first_char : 0; |
|
break; |
|
|
|
case PCRE_INFO_FIRSTCHARACTERFLAGS: |
|
*((int *)where) = |
|
((re->flags & PCRE_FIRSTSET) != 0) ? 1 : |
|
((re->flags & PCRE_STARTLINE) != 0) ? 2 : 0; |
|
break; |
|
|
/* Make sure we pass back the pointer to the bit vector in the external |
/* Make sure we pass back the pointer to the bit vector in the external |
block, not the internal copy (with flipped integer fields). */ |
block, not the internal copy (with flipped integer fields). */ |
|
|
case PCRE_INFO_FIRSTTABLE: |
case PCRE_INFO_FIRSTTABLE: |
*((const uschar **)where) = | *((const pcre_uint8 **)where) = |
(study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)? |
(study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)? |
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL; |
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL; |
break; |
break; |
Line 139 switch (what)
|
Line 163 switch (what)
|
case PCRE_INFO_MINLENGTH: |
case PCRE_INFO_MINLENGTH: |
*((int *)where) = |
*((int *)where) = |
(study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)? |
(study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)? |
study->minlength : -1; | (int)(study->minlength) : -1; |
break; |
break; |
|
|
case PCRE_INFO_JIT: |
case PCRE_INFO_JIT: |
Line 150 switch (what)
|
Line 174 switch (what)
|
|
|
case PCRE_INFO_LASTLITERAL: |
case PCRE_INFO_LASTLITERAL: |
*((int *)where) = |
*((int *)where) = |
((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1; | ((re->flags & PCRE_REQCHSET) != 0)? (int)re->req_char : -1; |
break; |
break; |
|
|
|
case PCRE_INFO_REQUIREDCHAR: |
|
*((pcre_uint32 *)where) = |
|
((re->flags & PCRE_REQCHSET) != 0) ? re->req_char : 0; |
|
break; |
|
|
|
case PCRE_INFO_REQUIREDCHARFLAGS: |
|
*((int *)where) = |
|
((re->flags & PCRE_REQCHSET) != 0); |
|
break; |
|
|
case PCRE_INFO_NAMEENTRYSIZE: |
case PCRE_INFO_NAMEENTRYSIZE: |
*((int *)where) = re->name_entry_size; |
*((int *)where) = re->name_entry_size; |
break; |
break; |
Line 162 switch (what)
|
Line 196 switch (what)
|
break; |
break; |
|
|
case PCRE_INFO_NAMETABLE: |
case PCRE_INFO_NAMETABLE: |
*((const uschar **)where) = (const uschar *)re + re->name_table_offset; | *((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset; |
break; |
break; |
|
|
case PCRE_INFO_DEFAULT_TABLES: |
case PCRE_INFO_DEFAULT_TABLES: |
*((const uschar **)where) = (const uschar *)(_pcre_default_tables); | *((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables)); |
break; |
break; |
|
|
/* From release 8.00 this will always return TRUE because NOPARTIAL is |
/* From release 8.00 this will always return TRUE because NOPARTIAL is |
Line 182 switch (what)
|
Line 216 switch (what)
|
|
|
case PCRE_INFO_HASCRORLF: |
case PCRE_INFO_HASCRORLF: |
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0; |
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0; |
|
break; |
|
|
|
case PCRE_INFO_MAXLOOKBEHIND: |
|
*((int *)where) = re->max_lookbehind; |
|
break; |
|
|
|
case PCRE_INFO_MATCHLIMIT: |
|
if ((re->flags & PCRE_MLSET) == 0) return PCRE_ERROR_UNSET; |
|
*((pcre_uint32 *)where) = re->limit_match; |
|
break; |
|
|
|
case PCRE_INFO_RECURSIONLIMIT: |
|
if ((re->flags & PCRE_RLSET) == 0) return PCRE_ERROR_UNSET; |
|
*((pcre_uint32 *)where) = re->limit_recursion; |
|
break; |
|
|
|
case PCRE_INFO_MATCH_EMPTY: |
|
*((int *)where) = (re->flags & PCRE_MATCH_EMPTY) != 0; |
break; |
break; |
|
|
default: return PCRE_ERROR_BADOPTION; |
default: return PCRE_ERROR_BADOPTION; |