| Line | Source Code | Coverage |
|---|
| 1 | /************************************************* | - |
| 2 | * Perl-Compatible Regular Expressions * | - |
| 3 | *************************************************/ | - |
| 4 | | - |
| 5 | /* PCRE is a library of functions to support regular expressions whose syntax | - |
| 6 | and semantics are as close as possible to those of the Perl 5 language. | - |
| 7 | | - |
| 8 | Written by Philip Hazel | - |
| 9 | Copyright (c) 1997-2012 University of Cambridge | - |
| 10 | | - |
| 11 | ----------------------------------------------------------------------------- | - |
| 12 | Redistribution and use in source and binary forms, with or without | - |
| 13 | modification, are permitted provided that the following conditions are met: | - |
| 14 | | - |
| 15 | * Redistributions of source code must retain the above copyright notice, | - |
| 16 | this list of conditions and the following disclaimer. | - |
| 17 | | - |
| 18 | * Redistributions in binary form must reproduce the above copyright | - |
| 19 | notice, this list of conditions and the following disclaimer in the | - |
| 20 | documentation and/or other materials provided with the distribution. | - |
| 21 | | - |
| 22 | * Neither the name of the University of Cambridge nor the names of its | - |
| 23 | contributors may be used to endorse or promote products derived from | - |
| 24 | this software without specific prior written permission. | - |
| 25 | | - |
| 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | - |
| 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | - |
| 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | - |
| 29 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | - |
| 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | - |
| 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | - |
| 32 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | - |
| 33 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | - |
| 34 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | - |
| 35 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | - |
| 36 | POSSIBILITY OF SUCH DAMAGE. | - |
| 37 | ----------------------------------------------------------------------------- | - |
| 38 | */ | - |
| 39 | | - |
| 40 | | - |
| 41 | /* This module contains the external function pcre_fullinfo(), which returns | - |
| 42 | information about a compiled pattern. */ | - |
| 43 | | - |
| 44 | | - |
| 45 | #ifdef PCRE_HAVE_CONFIG_H | - |
| 46 | #include "config.h" | - |
| 47 | #endif | - |
| 48 | | - |
| 49 | #include "pcre_internal.h" | - |
| 50 | | - |
| 51 | | - |
| 52 | /************************************************* | - |
| 53 | * Return info about compiled pattern * | - |
| 54 | *************************************************/ | - |
| 55 | | - |
| 56 | /* This is a newer "info" function which has an extensible interface so | - |
| 57 | that additional items can be added compatibly. | - |
| 58 | | - |
| 59 | Arguments: | - |
| 60 | argument_re points to compiled code | - |
| 61 | extra_data points extra data, or NULL | - |
| 62 | what what information is required | - |
| 63 | where where to put the information | - |
| 64 | | - |
| 65 | Returns: 0 if data returned, negative on error | - |
| 66 | */ | - |
| 67 | | - |
| 68 | #ifdef COMPILE_PCRE8 | - |
| 69 | PCRE_EXP_DEFN int PCRE_CALL_CONVENTION | - |
| 70 | pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, | - |
| 71 | 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 | const REAL_PCRE *re = (const REAL_PCRE *)argument_re; executed (the execution status of this line is deduced): const real_pcre16 *re = (const real_pcre16 *)argument_re; | - |
| 79 | const pcre_study_data *study = NULL; executed (the execution status of this line is deduced): const pcre_study_data *study = ((void *)0); | - |
| 80 | | - |
| 81 | if (re == NULL || where == NULL) return PCRE_ERROR_NULL; never executed: return (-2); partially evaluated: re == ((void *)0)| no Evaluation Count:0 | yes Evaluation Count:754 |
partially evaluated: where == ((void *)0)| no Evaluation Count:0 | yes Evaluation Count:754 |
| 0-754 |
| 82 | | - |
| 83 | if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0) partially evaluated: extra_data != ((void *)0)| no Evaluation Count:0 | yes Evaluation Count:754 |
never evaluated: (extra_data->flags & 0x0001) != 0 | 0-754 |
| 84 | study = (const pcre_study_data *)extra_data->study_data; never executed: study = (const pcre_study_data *)extra_data->study_data; | 0 |
| 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) partially evaluated: re->magic_number != 0x50435245UL| no Evaluation Count:0 | yes Evaluation Count:754 |
| 0-754 |
| 92 | return re->magic_number == REVERSED_MAGIC_NUMBER? never executed: return re->magic_number == 0x45524350UL? (-29):(-4); | 0 |
| 93 | PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC; never executed: return re->magic_number == 0x45524350UL? (-29):(-4); | 0 |
| 94 | | - |
| 95 | /* Check that this pattern was compiled in the correct bit mode */ | - |
| 96 | | - |
| 97 | if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE; never executed: return (-28); partially evaluated: (re->flags & 0x0002) == 0| no Evaluation Count:0 | yes Evaluation Count:754 |
| 0-754 |
| 98 | | - |
| 99 | switch (what) | - |
| 100 | { | - |
| 101 | case PCRE_INFO_OPTIONS: | - |
| 102 | *((unsigned long int *)where) = re->options & PUBLIC_COMPILE_OPTIONS; executed (the execution status of this line is deduced): *((unsigned long int *)where) = re->options & (0x00000001|0x00000008|0x00000010|0x00000002| 0x00000004|0x00000020|0x00000040|0x00000200|0x00000800| 0x00001000|0x00002000|0x00004000|0x00040000| 0x00080000|(0x00100000|0x00200000|0x00400000| 0x00500000)|0x00800000|0x01000000| 0x02000000|0x20000000|0x04000000); | - |
| 103 | break; executed: break;Execution Count:357 | 357 |
| 104 | | - |
| 105 | case PCRE_INFO_SIZE: | - |
| 106 | *((size_t *)where) = re->size; never executed (the execution status of this line is deduced): *((size_t *)where) = re->size; | - |
| 107 | break; | 0 |
| 108 | | - |
| 109 | case PCRE_INFO_STUDYSIZE: | - |
| 110 | *((size_t *)where) = (study == NULL)? 0 : study->size; never evaluated: (study == ((void *)0)) | 0 |
| 111 | break; | 0 |
| 112 | | - |
| 113 | case PCRE_INFO_JITSIZE: | - |
| 114 | #ifdef SUPPORT_JIT | - |
| 115 | *((size_t *)where) = never executed (the execution status of this line is deduced): *((size_t *)where) = | - |
| 116 | (extra_data != NULL && never evaluated: extra_data != ((void *)0) | 0 |
| 117 | (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && never evaluated: (extra_data->flags & 0x0040) != 0 | 0 |
| 118 | extra_data->executable_jit != NULL)? never evaluated: extra_data->executable_jit != ((void *)0) | 0 |
| 119 | PRIV(jit_get_size)(extra_data->executable_jit) : 0; never executed (the execution status of this line is deduced): _pcre16_jit_get_size(extra_data->executable_jit) : 0; | - |
| 120 | #else | - |
| 121 | *((size_t *)where) = 0; | - |
| 122 | #endif | - |
| 123 | break; | 0 |
| 124 | | - |
| 125 | case PCRE_INFO_CAPTURECOUNT: | - |
| 126 | *((int *)where) = re->top_bracket; executed (the execution status of this line is deduced): *((int *)where) = re->top_bracket; | - |
| 127 | break; executed: break;Execution Count:357 | 357 |
| 128 | | - |
| 129 | case PCRE_INFO_BACKREFMAX: | - |
| 130 | *((int *)where) = re->top_backref; never executed (the execution status of this line is deduced): *((int *)where) = re->top_backref; | - |
| 131 | break; | 0 |
| 132 | | - |
| 133 | case PCRE_INFO_FIRSTBYTE: | - |
| 134 | *((int *)where) = never executed (the execution status of this line is deduced): *((int *)where) = | - |
| 135 | ((re->flags & PCRE_FIRSTSET) != 0)? re->first_char : never evaluated: ((re->flags & 0x0010) != 0) | 0 |
| 136 | ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; never executed (the execution status of this line is deduced): ((re->flags & 0x0100) != 0)? -1 : -2; | - |
| 137 | break; | 0 |
| 138 | | - |
| 139 | /* Make sure we pass back the pointer to the bit vector in the external | - |
| 140 | block, not the internal copy (with flipped integer fields). */ | - |
| 141 | | - |
| 142 | case PCRE_INFO_FIRSTTABLE: | - |
| 143 | *((const pcre_uint8 **)where) = never executed (the execution status of this line is deduced): *((const pcre_uint8 **)where) = | - |
| 144 | (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)? never evaluated: study != ((void *)0) never evaluated: (study->flags & 0x0001) != 0 | 0 |
| 145 | ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL; never executed (the execution status of this line is deduced): ((const pcre_study_data *)extra_data->study_data)->start_bits : ((void *)0); | - |
| 146 | break; | 0 |
| 147 | | - |
| 148 | case PCRE_INFO_MINLENGTH: | - |
| 149 | *((int *)where) = never executed (the execution status of this line is deduced): *((int *)where) = | - |
| 150 | (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)? never evaluated: study != ((void *)0) never evaluated: (study->flags & 0x0002) != 0 | 0 |
| 151 | (int)(study->minlength) : -1; never executed (the execution status of this line is deduced): (int)(study->minlength) : -1; | - |
| 152 | break; | 0 |
| 153 | | - |
| 154 | case PCRE_INFO_JIT: | - |
| 155 | *((int *)where) = extra_data != NULL && never evaluated: extra_data != ((void *)0) | 0 |
| 156 | (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && never evaluated: (extra_data->flags & 0x0040) != 0 | 0 |
| 157 | extra_data->executable_jit != NULL; never evaluated: extra_data->executable_jit != ((void *)0) | 0 |
| 158 | break; | 0 |
| 159 | | - |
| 160 | case PCRE_INFO_LASTLITERAL: | - |
| 161 | *((int *)where) = never executed (the execution status of this line is deduced): *((int *)where) = | - |
| 162 | ((re->flags & PCRE_REQCHSET) != 0)? re->req_char : -1; never evaluated: ((re->flags & 0x0040) != 0) | 0 |
| 163 | break; | 0 |
| 164 | | - |
| 165 | case PCRE_INFO_NAMEENTRYSIZE: | - |
| 166 | *((int *)where) = re->name_entry_size; executed (the execution status of this line is deduced): *((int *)where) = re->name_entry_size; | - |
| 167 | break; executed: break;Execution Count:12 | 12 |
| 168 | | - |
| 169 | case PCRE_INFO_NAMECOUNT: | - |
| 170 | *((int *)where) = re->name_count; executed (the execution status of this line is deduced): *((int *)where) = re->name_count; | - |
| 171 | break; executed: break;Execution Count:12 | 12 |
| 172 | | - |
| 173 | case PCRE_INFO_NAMETABLE: | - |
| 174 | *((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset; executed (the execution status of this line is deduced): *((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset; | - |
| 175 | break; executed: break;Execution Count:12 | 12 |
| 176 | | - |
| 177 | case PCRE_INFO_DEFAULT_TABLES: | - |
| 178 | *((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables)); executed (the execution status of this line is deduced): *((const pcre_uint8 **)where) = (const pcre_uint8 *)(_pcre16_default_tables); | - |
| 179 | break; executed: break;Execution Count:4 | 4 |
| 180 | | - |
| 181 | /* From release 8.00 this will always return TRUE because NOPARTIAL is | - |
| 182 | no longer ever set (the restrictions have been removed). */ | - |
| 183 | | - |
| 184 | case PCRE_INFO_OKPARTIAL: | - |
| 185 | *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0; never executed (the execution status of this line is deduced): *((int *)where) = (re->flags & 0x0200) == 0; | - |
| 186 | break; | 0 |
| 187 | | - |
| 188 | case PCRE_INFO_JCHANGED: | - |
| 189 | *((int *)where) = (re->flags & PCRE_JCHANGED) != 0; never executed (the execution status of this line is deduced): *((int *)where) = (re->flags & 0x0400) != 0; | - |
| 190 | break; | 0 |
| 191 | | - |
| 192 | case PCRE_INFO_HASCRORLF: | - |
| 193 | *((int *)where) = (re->flags & PCRE_HASCRORLF) != 0; never executed (the execution status of this line is deduced): *((int *)where) = (re->flags & 0x0800) != 0; | - |
| 194 | break; | 0 |
| 195 | | - |
| 196 | default: return PCRE_ERROR_BADOPTION; never executed: return (-3); | 0 |
| 197 | } | - |
| 198 | | - |
| 199 | return 0; executed: return 0;Execution Count:754 | 754 |
| 200 | } | - |
| 201 | | - |
| 202 | /* End of pcre_fullinfo.c */ | - |
| 203 | | - |
| | |