| 9 |
|
|
| 10 |
Written by: Philip Hazel <ph10@cam.ac.uk> |
Written by: Philip Hazel <ph10@cam.ac.uk> |
| 11 |
|
|
| 12 |
Copyright (c) 1997-2003 University of Cambridge |
Copyright (c) 1997-2004 University of Cambridge |
| 13 |
|
|
| 14 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 15 |
Permission is granted to anyone to use this software for any purpose on any |
Redistribution and use in source and binary forms, with or without |
| 16 |
computer system, and to redistribute it freely, subject to the following |
modification, are permitted provided that the following conditions are met: |
| 17 |
restrictions: |
|
| 18 |
|
* Redistributions of source code must retain the above copyright notice, |
| 19 |
1. This software is distributed in the hope that it will be useful, |
this list of conditions and the following disclaimer. |
| 20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
* Redistributions in binary form must reproduce the above copyright |
| 22 |
|
notice, this list of conditions and the following disclaimer in the |
| 23 |
2. The origin of this software must not be misrepresented, either by |
documentation and/or other materials provided with the distribution. |
| 24 |
explicit claim or by omission. |
|
| 25 |
|
* Neither the name of the University of Cambridge nor the names of its |
| 26 |
3. Altered versions must be plainly marked as such, and must not be |
contributors may be used to endorse or promote products derived from |
| 27 |
misrepresented as being the original software. |
this software without specific prior written permission. |
| 28 |
|
|
| 29 |
4. If PCRE is embedded in any software that is released under the GNU |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 30 |
General Purpose Licence (GPL), then the terms of that licence shall |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 31 |
supersede any condition above with which it is incompatible. |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 32 |
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 33 |
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 34 |
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 35 |
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 36 |
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 37 |
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 38 |
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 39 |
|
POSSIBILITY OF SUCH DAMAGE. |
| 40 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 41 |
*/ |
*/ |
| 42 |
|
|
| 65 |
*/ |
*/ |
| 66 |
|
|
| 67 |
static void |
static void |
| 68 |
set_bit(uschar *start_bits, int c, BOOL caseless, compile_data *cd) |
set_bit(uschar *start_bits, unsigned int c, BOOL caseless, compile_data *cd) |
| 69 |
{ |
{ |
| 70 |
start_bits[c/8] |= (1 << (c&7)); |
start_bits[c/8] |= (1 << (c&7)); |
| 71 |
if (caseless && (cd->ctypes[c] & ctype_letter) != 0) |
if (caseless && (cd->ctypes[c] & ctype_letter) != 0) |
| 131 |
/* Skip over callout */ |
/* Skip over callout */ |
| 132 |
|
|
| 133 |
case OP_CALLOUT: |
case OP_CALLOUT: |
| 134 |
tcode += 2; |
tcode += 2 + 2*LINK_SIZE; |
| 135 |
break; |
break; |
| 136 |
|
|
| 137 |
/* Skip over extended extraction bracket number */ |
/* Skip over extended extraction bracket number */ |
| 194 |
/* At least one single char sets the bit and stops */ |
/* At least one single char sets the bit and stops */ |
| 195 |
|
|
| 196 |
case OP_EXACT: /* Fall through */ |
case OP_EXACT: /* Fall through */ |
| 197 |
tcode++; |
tcode += 2; |
|
|
|
|
case OP_CHARS: /* Fall through */ |
|
|
tcode++; |
|
| 198 |
|
|
| 199 |
|
case OP_CHAR: |
| 200 |
|
case OP_CHARNC: |
| 201 |
case OP_PLUS: |
case OP_PLUS: |
| 202 |
case OP_MINPLUS: |
case OP_MINPLUS: |
| 203 |
set_bit(start_bits, tcode[1], caseless, cd); |
set_bit(start_bits, tcode[1], caseless, cd); |
| 410 |
uschar start_bits[32]; |
uschar start_bits[32]; |
| 411 |
pcre_extra *extra; |
pcre_extra *extra; |
| 412 |
pcre_study_data *study; |
pcre_study_data *study; |
| 413 |
|
const uschar *tables; |
| 414 |
const real_pcre *re = (const real_pcre *)external_re; |
const real_pcre *re = (const real_pcre *)external_re; |
| 415 |
uschar *code = (uschar *)re + sizeof(real_pcre) + |
uschar *code = (uschar *)re + re->name_table_offset + |
| 416 |
(re->name_count * re->name_entry_size); |
(re->name_count * re->name_entry_size); |
| 417 |
compile_data compile_block; |
compile_data compile_block; |
| 418 |
|
|
| 437 |
if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0) |
if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0) |
| 438 |
return NULL; |
return NULL; |
| 439 |
|
|
| 440 |
/* Set the character tables in the block which is passed around */ |
/* Set the character tables in the block that is passed around */ |
| 441 |
|
|
| 442 |
compile_block.lcc = re->tables + lcc_offset; |
tables = re->tables; |
| 443 |
compile_block.fcc = re->tables + fcc_offset; |
if (tables == NULL) |
| 444 |
compile_block.cbits = re->tables + cbits_offset; |
(void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES, &tables); |
| 445 |
compile_block.ctypes = re->tables + ctypes_offset; |
|
| 446 |
|
compile_block.lcc = tables + lcc_offset; |
| 447 |
|
compile_block.fcc = tables + fcc_offset; |
| 448 |
|
compile_block.cbits = tables + cbits_offset; |
| 449 |
|
compile_block.ctypes = tables + ctypes_offset; |
| 450 |
|
|
| 451 |
/* See if we can find a fixed set of initial characters for the pattern. */ |
/* See if we can find a fixed set of initial characters for the pattern. */ |
| 452 |
|
|