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-2007 University of Cambridge |
Copyright (c) 1997-2008 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 |
45 |
|
|
46 |
|
|
47 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
48 |
#include <config.h> |
#include "config.h" |
49 |
#endif |
#endif |
50 |
|
|
51 |
#define NLBLOCK md /* Block containing newline information */ |
#define NLBLOCK md /* Block containing newline information */ |
84 |
small value. ***NOTE*** If the start of this table is modified, the two tables |
small value. ***NOTE*** If the start of this table is modified, the two tables |
85 |
that follow must also be modified. */ |
that follow must also be modified. */ |
86 |
|
|
87 |
static uschar coptable[] = { |
static const uschar coptable[] = { |
88 |
0, /* End */ |
0, /* End */ |
89 |
0, 0, 0, 0, 0, /* \A, \G, \K, \B, \b */ |
0, 0, 0, 0, 0, /* \A, \G, \K, \B, \b */ |
90 |
0, 0, 0, 0, 0, 0, /* \D, \d, \S, \s, \W, \w */ |
0, 0, 0, 0, 0, 0, /* \D, \d, \S, \s, \W, \w */ |
138 |
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W, |
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W, |
139 |
and \w */ |
and \w */ |
140 |
|
|
141 |
static uschar toptable1[] = { |
static const uschar toptable1[] = { |
142 |
0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, |
143 |
ctype_digit, ctype_digit, |
ctype_digit, ctype_digit, |
144 |
ctype_space, ctype_space, |
ctype_space, ctype_space, |
146 |
0 /* OP_ANY */ |
0 /* OP_ANY */ |
147 |
}; |
}; |
148 |
|
|
149 |
static uschar toptable2[] = { |
static const uschar toptable2[] = { |
150 |
0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, |
151 |
ctype_digit, 0, |
ctype_digit, 0, |
152 |
ctype_space, 0, |
ctype_space, 0, |
1080 |
int ncount = 0; |
int ncount = 0; |
1081 |
switch (c) |
switch (c) |
1082 |
{ |
{ |
|
case 0x000d: |
|
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
|
|
/* Fall through */ |
|
|
case 0x000a: |
|
1083 |
case 0x000b: |
case 0x000b: |
1084 |
case 0x000c: |
case 0x000c: |
1085 |
case 0x0085: |
case 0x0085: |
1086 |
case 0x2028: |
case 0x2028: |
1087 |
case 0x2029: |
case 0x2029: |
1088 |
|
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; |
1089 |
|
goto ANYNL01; |
1090 |
|
|
1091 |
|
case 0x000d: |
1092 |
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
1093 |
|
/* Fall through */ |
1094 |
|
|
1095 |
|
ANYNL01: |
1096 |
|
case 0x000a: |
1097 |
if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS) |
if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS) |
1098 |
{ |
{ |
1099 |
active_count--; /* Remove non-match possibility */ |
active_count--; /* Remove non-match possibility */ |
1102 |
count++; |
count++; |
1103 |
ADD_NEW_DATA(-state_offset, count, ncount); |
ADD_NEW_DATA(-state_offset, count, ncount); |
1104 |
break; |
break; |
1105 |
|
|
1106 |
default: |
default: |
1107 |
break; |
break; |
1108 |
} |
} |
1319 |
int ncount = 0; |
int ncount = 0; |
1320 |
switch (c) |
switch (c) |
1321 |
{ |
{ |
|
case 0x000d: |
|
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
|
|
/* Fall through */ |
|
|
case 0x000a: |
|
1322 |
case 0x000b: |
case 0x000b: |
1323 |
case 0x000c: |
case 0x000c: |
1324 |
case 0x0085: |
case 0x0085: |
1325 |
case 0x2028: |
case 0x2028: |
1326 |
case 0x2029: |
case 0x2029: |
1327 |
|
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; |
1328 |
|
goto ANYNL02; |
1329 |
|
|
1330 |
|
case 0x000d: |
1331 |
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
1332 |
|
/* Fall through */ |
1333 |
|
|
1334 |
|
ANYNL02: |
1335 |
|
case 0x000a: |
1336 |
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR || |
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR || |
1337 |
codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY) |
codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY) |
1338 |
{ |
{ |
1341 |
} |
} |
1342 |
ADD_NEW_DATA(-(state_offset + count), 0, ncount); |
ADD_NEW_DATA(-(state_offset + count), 0, ncount); |
1343 |
break; |
break; |
1344 |
|
|
1345 |
default: |
default: |
1346 |
break; |
break; |
1347 |
} |
} |
1557 |
int ncount = 0; |
int ncount = 0; |
1558 |
switch (c) |
switch (c) |
1559 |
{ |
{ |
|
case 0x000d: |
|
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
|
|
/* Fall through */ |
|
|
case 0x000a: |
|
1560 |
case 0x000b: |
case 0x000b: |
1561 |
case 0x000c: |
case 0x000c: |
1562 |
case 0x0085: |
case 0x0085: |
1563 |
case 0x2028: |
case 0x2028: |
1564 |
case 0x2029: |
case 0x2029: |
1565 |
|
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; |
1566 |
|
goto ANYNL03; |
1567 |
|
|
1568 |
|
case 0x000d: |
1569 |
|
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; |
1570 |
|
/* Fall through */ |
1571 |
|
|
1572 |
|
ANYNL03: |
1573 |
|
case 0x000a: |
1574 |
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO) |
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO) |
1575 |
{ |
{ |
1576 |
active_count--; /* Remove non-match possibility */ |
active_count--; /* Remove non-match possibility */ |
1581 |
else |
else |
1582 |
{ ADD_NEW_DATA(-state_offset, count, ncount); } |
{ ADD_NEW_DATA(-state_offset, count, ncount); } |
1583 |
break; |
break; |
1584 |
|
|
1585 |
default: |
default: |
1586 |
break; |
break; |
1587 |
} |
} |
1762 |
case OP_ANYNL: |
case OP_ANYNL: |
1763 |
if (clen > 0) switch(c) |
if (clen > 0) switch(c) |
1764 |
{ |
{ |
|
case 0x000a: |
|
1765 |
case 0x000b: |
case 0x000b: |
1766 |
case 0x000c: |
case 0x000c: |
1767 |
case 0x0085: |
case 0x0085: |
1768 |
case 0x2028: |
case 0x2028: |
1769 |
case 0x2029: |
case 0x2029: |
1770 |
|
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; |
1771 |
|
|
1772 |
|
case 0x000a: |
1773 |
ADD_NEW(state_offset + 1, 0); |
ADD_NEW(state_offset + 1, 0); |
1774 |
break; |
break; |
1775 |
|
|
1776 |
case 0x000d: |
case 0x000d: |
1777 |
if (ptr + 1 < end_subject && ptr[1] == 0x0a) |
if (ptr + 1 < end_subject && ptr[1] == 0x0a) |
1778 |
{ |
{ |
2595 |
md->moptions = options; |
md->moptions = options; |
2596 |
md->poptions = re->options; |
md->poptions = re->options; |
2597 |
|
|
2598 |
|
/* If the BSR option is not set at match time, copy what was set |
2599 |
|
at compile time. */ |
2600 |
|
|
2601 |
|
if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0) |
2602 |
|
{ |
2603 |
|
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0) |
2604 |
|
md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE); |
2605 |
|
#ifdef BSR_ANYCRLF |
2606 |
|
else md->moptions |= PCRE_BSR_ANYCRLF; |
2607 |
|
#endif |
2608 |
|
} |
2609 |
|
|
2610 |
/* Handle different types of newline. The three bits give eight cases. If |
/* Handle different types of newline. The three bits give eight cases. If |
2611 |
nothing is set at run time, whatever was used at compile time applies. */ |
nothing is set at run time, whatever was used at compile time applies. */ |
2612 |
|
|