| 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. |
| 7 |
|
|
| 8 |
Written by Philip Hazel |
Written by Philip Hazel |
| 9 |
Copyright (c) 1997-2009 University of Cambridge |
Copyright (c) 1997-2012 University of Cambridge |
| 10 |
|
|
| 11 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 12 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
| 65 |
Returns: 0 if data returned, negative on error |
Returns: 0 if data returned, negative on error |
| 66 |
*/ |
*/ |
| 67 |
|
|
| 68 |
|
#ifdef COMPILE_PCRE8 |
| 69 |
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
| 70 |
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what, |
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, |
| 71 |
void *where) |
int what, void *where) |
| 72 |
|
#else |
| 73 |
|
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
| 74 |
|
pcre16_fullinfo(const pcre16 *argument_re, const pcre16_extra *extra_data, |
| 75 |
|
int what, void *where) |
| 76 |
|
#endif |
| 77 |
{ |
{ |
| 78 |
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; |
|
| 79 |
const pcre_study_data *study = NULL; |
const pcre_study_data *study = NULL; |
| 80 |
|
|
| 81 |
if (re == NULL || where == NULL) return PCRE_ERROR_NULL; |
if (re == NULL || where == NULL) return PCRE_ERROR_NULL; |
| 83 |
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0) |
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0) |
| 84 |
study = (const pcre_study_data *)extra_data->study_data; |
study = (const pcre_study_data *)extra_data->study_data; |
| 85 |
|
|
| 86 |
|
/* Check that the first field in the block is the magic number. If it is not, |
| 87 |
|
return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to |
| 88 |
|
REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which |
| 89 |
|
means that the pattern is likely compiled with different endianness. */ |
| 90 |
|
|
| 91 |
if (re->magic_number != MAGIC_NUMBER) |
if (re->magic_number != MAGIC_NUMBER) |
| 92 |
{ |
return re->magic_number == REVERSED_MAGIC_NUMBER? |
| 93 |
re = _pcre_try_flipped(re, &internal_re, study, &internal_study); |
PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC; |
| 94 |
if (re == NULL) return PCRE_ERROR_BADMAGIC; |
|
| 95 |
if (study != NULL) study = &internal_study; |
/* Check that this pattern was compiled in the correct bit mode */ |
| 96 |
} |
|
| 97 |
|
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE; |
| 98 |
|
|
| 99 |
switch (what) |
switch (what) |
| 100 |
{ |
{ |
| 110 |
*((size_t *)where) = (study == NULL)? 0 : study->size; |
*((size_t *)where) = (study == NULL)? 0 : study->size; |
| 111 |
break; |
break; |
| 112 |
|
|
| 113 |
|
case PCRE_INFO_JITSIZE: |
| 114 |
|
#ifdef SUPPORT_JIT |
| 115 |
|
*((size_t *)where) = |
| 116 |
|
(extra_data != NULL && |
| 117 |
|
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && |
| 118 |
|
extra_data->executable_jit != NULL)? |
| 119 |
|
PRIV(jit_get_size)(extra_data->executable_jit) : 0; |
| 120 |
|
#else |
| 121 |
|
*((size_t *)where) = 0; |
| 122 |
|
#endif |
| 123 |
|
break; |
| 124 |
|
|
| 125 |
case PCRE_INFO_CAPTURECOUNT: |
case PCRE_INFO_CAPTURECOUNT: |
| 126 |
*((int *)where) = re->top_bracket; |
*((int *)where) = re->top_bracket; |
| 127 |
break; |
break; |
| 132 |
|
|
| 133 |
case PCRE_INFO_FIRSTBYTE: |
case PCRE_INFO_FIRSTBYTE: |
| 134 |
*((int *)where) = |
*((int *)where) = |
| 135 |
((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte : |
((re->flags & PCRE_FIRSTSET) != 0)? re->first_char : |
| 136 |
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; |
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; |
| 137 |
break; |
break; |
| 138 |
|
|
| 140 |
block, not the internal copy (with flipped integer fields). */ |
block, not the internal copy (with flipped integer fields). */ |
| 141 |
|
|
| 142 |
case PCRE_INFO_FIRSTTABLE: |
case PCRE_INFO_FIRSTTABLE: |
| 143 |
*((const uschar **)where) = |
*((const pcre_uint8 **)where) = |
| 144 |
(study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)? |
(study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)? |
| 145 |
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL; |
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL; |
| 146 |
break; |
break; |
| 147 |
|
|
| 148 |
case PCRE_INFO_MINLENGTH: |
case PCRE_INFO_MINLENGTH: |
| 149 |
*((int *)where) = |
*((int *)where) = |
| 150 |
(study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)? |
(study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)? |
| 151 |
study->minlength : -1; |
(int)(study->minlength) : -1; |
| 152 |
break; |
break; |
| 153 |
|
|
| 154 |
|
case PCRE_INFO_JIT: |
| 155 |
|
*((int *)where) = extra_data != NULL && |
| 156 |
|
(extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && |
| 157 |
|
extra_data->executable_jit != NULL; |
| 158 |
|
break; |
| 159 |
|
|
| 160 |
case PCRE_INFO_LASTLITERAL: |
case PCRE_INFO_LASTLITERAL: |
| 161 |
*((int *)where) = |
*((int *)where) = |
| 162 |
((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1; |
((re->flags & PCRE_REQCHSET) != 0)? re->req_char : -1; |
| 163 |
break; |
break; |
| 164 |
|
|
| 165 |
case PCRE_INFO_NAMEENTRYSIZE: |
case PCRE_INFO_NAMEENTRYSIZE: |
| 171 |
break; |
break; |
| 172 |
|
|
| 173 |
case PCRE_INFO_NAMETABLE: |
case PCRE_INFO_NAMETABLE: |
| 174 |
*((const uschar **)where) = (const uschar *)re + re->name_table_offset; |
*((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset; |
| 175 |
break; |
break; |
| 176 |
|
|
| 177 |
case PCRE_INFO_DEFAULT_TABLES: |
case PCRE_INFO_DEFAULT_TABLES: |
| 178 |
*((const uschar **)where) = (const uschar *)(_pcre_default_tables); |
*((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables)); |
| 179 |
break; |
break; |
| 180 |
|
|
| 181 |
/* From release 8.00 this will always return TRUE because NOPARTIAL is |
/* From release 8.00 this will always return TRUE because NOPARTIAL is |
| 182 |
no longer ever set (the restrictions have been removed). */ |
no longer ever set (the restrictions have been removed). */ |
| 183 |
|
|
| 184 |
case PCRE_INFO_OKPARTIAL: |
case PCRE_INFO_OKPARTIAL: |
| 185 |
*((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0; |
*((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0; |
| 186 |
break; |
break; |
| 193 |
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0; |
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0; |
| 194 |
break; |
break; |
| 195 |
|
|
| 196 |
|
case PCRE_INFO_MAXLOOKBEHIND: |
| 197 |
|
*((int *)where) = re->max_lookbehind; |
| 198 |
|
break; |
| 199 |
|
|
| 200 |
default: return PCRE_ERROR_BADOPTION; |
default: return PCRE_ERROR_BADOPTION; |
| 201 |
} |
} |
| 202 |
|
|