| 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 an internal function that is used to match an extended | - | 
| 42 | class. It is used by both pcre_exec() and pcre_def_exec(). */ | - | 
| 43 |  | - | 
| 44 |  | - | 
| 45 | #ifdef PCRE_HAVE_CONFIG_H | - | 
| 46 | #include "config.h" | - | 
| 47 | #endif | - | 
| 48 |  | - | 
| 49 | #include "pcre_internal.h" | - | 
| 50 |  | - | 
| 51 |  | - | 
| 52 | /************************************************* | - | 
| 53 | *       Match character against an XCLASS        * | - | 
| 54 | *************************************************/ | - | 
| 55 |  | - | 
| 56 | /* This function is called to match a character against an extended class that | - | 
| 57 | might contain values > 255 and/or Unicode properties. | - | 
| 58 |  | - | 
| 59 | Arguments: | - | 
| 60 | c           the character | - | 
| 61 | data        points to the flag byte of the XCLASS data | - | 
| 62 |  | - | 
| 63 | Returns:      TRUE if character matches, else FALSE | - | 
| 64 | */ | - | 
| 65 |  | - | 
| 66 | BOOL | - | 
| 67 | PRIV(xclass)(int c, const pcre_uchar *data, BOOL utf) | - | 
| 68 | { | - | 
| 69 | int t; executed (the execution status of this line is deduced): int t; | - | 
| 70 | BOOL negated = (*data & XCL_NOT) != 0; executed (the execution status of this line is deduced): BOOL negated = (*data & 0x01) != 0; | - | 
| 71 |  | - | 
| 72 | (void)utf; executed (the execution status of this line is deduced): (void)utf; | - | 
| 73 | #ifdef COMPILE_PCRE8 | - | 
| 74 | /* In 8 bit mode, this must always be TRUE. Help the compiler to know that. */ | - | 
| 75 | utf = TRUE; | - | 
| 76 | #endif | - | 
| 77 |  | - | 
| 78 | /* Character values < 256 are matched against a bitmap, if one is present. If | - | 
| 79 | not, we still carry on, because there may be ranges that start below 256 in the | - | 
| 80 | additional data. */ | - | 
| 81 |  | - | 
| 82 | if (c < 256) evaluated:  c < 256| yes Evaluation Count:26 | yes Evaluation Count:15 | 
 | 15-26 | 
| 83 | { | - | 
| 84 | if ((*data & XCL_MAP) != 0 && partially evaluated:  (*data & 0x02) != 0| no Evaluation Count:0 | yes Evaluation Count:26 | 
 | 0-26 | 
| 85 | (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0) never evaluated: (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0 | 0 | 
| 86 | return !negated; /* char found */ never executed: return !negated; | 0 | 
| 87 | } executed:  }Execution Count:26 | 26 | 
| 88 |  | - | 
| 89 | /* First skip the bit map if present. Then match against the list of Unicode | - | 
| 90 | properties or large chars or ranges that end with a large char. We won't ever | - | 
| 91 | encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */ | - | 
| 92 |  | - | 
| 93 | if ((*data++ & XCL_MAP) != 0) data += 32 / sizeof(pcre_uchar); never executed: data += 32 / sizeof(pcre_uchar); partially evaluated:  (*data++ & 0x02) != 0| no Evaluation Count:0 | yes Evaluation Count:41 | 
 | 0-41 | 
| 94 |  | - | 
| 95 | while ((t = *data++) != XCL_END) evaluated:  (t = *data++) != 0| yes Evaluation Count:41 | yes Evaluation Count:15 | 
 | 15-41 | 
| 96 | { | - | 
| 97 | int x, y; executed (the execution status of this line is deduced):  int x, y; | - | 
| 98 | if (t == XCL_SINGLE) partially evaluated:  t == 1| no Evaluation Count:0 | yes Evaluation Count:41 | 
 | 0-41 | 
| 99 | { | - | 
| 100 | #ifdef SUPPORT_UTF | - | 
| 101 | if (utf) | 0 | 
| 102 | { | - | 
| 103 | GETCHARINC(x, data); /* macro generates multiple statements */ never executed: } never evaluated: (x & 0xfc00) == 0xd800 | 0 | 
| 104 | } | 0 | 
| 105 | else | - | 
| 106 | #endif | - | 
| 107 | x = *data++; never executed: x = *data++; | 0 | 
| 108 | if (c == x) return !negated; never executed: return !negated; never evaluated: c == x | 0 | 
| 109 | } | 0 | 
| 110 | else if (t == XCL_RANGE) partially evaluated:  t == 2| yes Evaluation Count:41 | no Evaluation Count:0 | 
 | 0-41 | 
| 111 | { | - | 
| 112 | #ifdef SUPPORT_UTF | - | 
| 113 | if (utf) partially evaluated:  utf| yes Evaluation Count:41 | no Evaluation Count:0 | 
 | 0-41 | 
| 114 | { | - | 
| 115 | GETCHARINC(x, data); /* macro generates multiple statements */ never executed: } partially evaluated:  (x & 0xfc00) == 0xd800| no Evaluation Count:0 | yes Evaluation Count:41 | 
 | 0-41 | 
| 116 | GETCHARINC(y, data); /* macro generates multiple statements */ never executed: } partially evaluated:  (y & 0xfc00) == 0xd800| no Evaluation Count:0 | yes Evaluation Count:41 | 
 | 0-41 | 
| 117 | } executed:  }Execution Count:41 | 41 | 
| 118 | else | - | 
| 119 | #endif | - | 
| 120 | { | - | 
| 121 | x = *data++; never executed (the execution status of this line is deduced):  x = *data++; | - | 
| 122 | y = *data++; never executed (the execution status of this line is deduced):  y = *data++; | - | 
| 123 | } | 0 | 
| 124 | if (c >= x && c <= y) return !negated; executed:  return !negated;Execution Count:26 partially evaluated:  c >= x| yes Evaluation Count:41 | no Evaluation Count:0 | 
 evaluated:  c <= y| yes Evaluation Count:26 | yes Evaluation Count:15 | 
 | 0-41 | 
| 125 | } executed:  }Execution Count:15 | 15 | 
| 126 |  | - | 
| 127 | #ifdef SUPPORT_UCP | - | 
| 128 | else  /* XCL_PROP & XCL_NOTPROP */ | - | 
| 129 | { | - | 
| 130 | const ucd_record *prop = GET_UCD(c); never executed (the execution status of this line is deduced):  const ucd_record *prop = (_pcre16_ucd_records + _pcre16_ucd_stage2[_pcre16_ucd_stage1[(c) / 128] * 128 + (c) % 128]); | - | 
| 131 |  | - | 
| 132 | switch(*data) | - | 
| 133 | { | - | 
| 134 | case PT_ANY: | - | 
| 135 | if (t == XCL_PROP) return !negated; never executed: return !negated; never evaluated: t == 3 | 0 | 
| 136 | break; | 0 | 
| 137 |  | - | 
| 138 | case PT_LAMP: | - | 
| 139 | if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || never evaluated: (prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt) == (t == 3) never evaluated: prop->chartype == ucp_Lu never evaluated: prop->chartype == ucp_Ll | 0 | 
| 140 | prop->chartype == ucp_Lt) == (t == XCL_PROP)) return !negated; never executed: return !negated; never evaluated: (prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt) == (t == 3) never evaluated: prop->chartype == ucp_Lt | 0 | 
| 141 | break; | 0 | 
| 142 |  | - | 
| 143 | case PT_GC: | - | 
| 144 | if ((data[1] == PRIV(ucp_gentype)[prop->chartype]) == (t == XCL_PROP)) never evaluated: (data[1] == _pcre16_ucp_gentype[prop->chartype]) == (t == 3) | 0 | 
| 145 | return !negated; never executed: return !negated; | 0 | 
| 146 | break; | 0 | 
| 147 |  | - | 
| 148 | case PT_PC: | - | 
| 149 | if ((data[1] == prop->chartype) == (t == XCL_PROP)) return !negated; never executed: return !negated; never evaluated: (data[1] == prop->chartype) == (t == 3) | 0 | 
| 150 | break; | 0 | 
| 151 |  | - | 
| 152 | case PT_SC: | - | 
| 153 | if ((data[1] == prop->script) == (t == XCL_PROP)) return !negated; never executed: return !negated; never evaluated: (data[1] == prop->script) == (t == 3) | 0 | 
| 154 | break; | 0 | 
| 155 |  | - | 
| 156 | case PT_ALNUM: | - | 
| 157 | if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L || never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_L || _pcre16_ucp_gentype[prop->chartype] == ucp_N) == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_L | 0 | 
| 158 | PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (t == XCL_PROP)) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_L || _pcre16_ucp_gentype[prop->chartype] == ucp_N) == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_N | 0 | 
| 159 | return !negated; never executed: return !negated; | 0 | 
| 160 | break; | 0 | 
| 161 |  | - | 
| 162 | case PT_SPACE:    /* Perl space */ | - | 
| 163 | if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z || never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\014' || c == '\015') == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_Z | 0 | 
| 164 | c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\014' || c == '\015') == (t == 3) never evaluated: c == '\011' never evaluated: c == '\012' never evaluated: c == '\014' never evaluated: c == '\015' | 0 | 
| 165 | == (t == XCL_PROP)) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\014' || c == '\015') == (t == 3) | 0 | 
| 166 | return !negated; never executed: return !negated; | 0 | 
| 167 | break; | 0 | 
| 168 |  | - | 
| 169 | case PT_PXSPACE:  /* POSIX space */ | - | 
| 170 | if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z || never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\013' || c == '\014' || c == '\015') == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_Z | 0 | 
| 171 | c == CHAR_HT || c == CHAR_NL || c == CHAR_VT || never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\013' || c == '\014' || c == '\015') == (t == 3) never evaluated: c == '\011' never evaluated: c == '\012' never evaluated: c == '\013' | 0 | 
| 172 | c == CHAR_FF || c == CHAR_CR) == (t == XCL_PROP)) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_Z || c == '\011' || c == '\012' || c == '\013' || c == '\014' || c == '\015') == (t == 3) never evaluated: c == '\014' never evaluated: c == '\015' | 0 | 
| 173 | return !negated; never executed: return !negated; | 0 | 
| 174 | break; | 0 | 
| 175 |  | - | 
| 176 | case PT_WORD: | - | 
| 177 | if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L || never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_L || _pcre16_ucp_gentype[prop->chartype] == ucp_N || c == '\137') == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_L | 0 | 
| 178 | PRIV(ucp_gentype)[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_L || _pcre16_ucp_gentype[prop->chartype] == ucp_N || c == '\137') == (t == 3) never evaluated: _pcre16_ucp_gentype[prop->chartype] == ucp_N never evaluated: c == '\137' | 0 | 
| 179 | == (t == XCL_PROP)) never evaluated: (_pcre16_ucp_gentype[prop->chartype] == ucp_L || _pcre16_ucp_gentype[prop->chartype] == ucp_N || c == '\137') == (t == 3) | 0 | 
| 180 | return !negated; never executed: return !negated; | 0 | 
| 181 | break; | 0 | 
| 182 |  | - | 
| 183 | /* This should never occur, but compilers may mutter if there is no | - | 
| 184 | default. */ | - | 
| 185 |  | - | 
| 186 | default: | - | 
| 187 | return FALSE; never executed: return 0; | 0 | 
| 188 | } | - | 
| 189 |  | - | 
| 190 | data += 2; never executed (the execution status of this line is deduced):  data += 2; | - | 
| 191 | } | 0 | 
| 192 | #endif  /* SUPPORT_UCP */ | - | 
| 193 | } | - | 
| 194 |  | - | 
| 195 | return negated;   /* char did not match */ executed:  return negated;Execution Count:15 | 15 | 
| 196 | } | - | 
| 197 |  | - | 
| 198 | /* End of pcre_xclass.c */ | - | 
| 199 |  | - | 
|  |  |  |