1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Upgrading libpcre from version 7.2 to 7.4. Tested on Linux and Windows

This commit is contained in:
kris
2007-12-20 22:24:53 +00:00
parent aa94d1e9d1
commit a1654beda6
38 changed files with 1728 additions and 712 deletions

View File

@@ -44,6 +44,12 @@ FSM). This is NOT Perl- compatible, but it has advantages in certain
applications. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#define NLBLOCK md /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */
@@ -126,7 +132,9 @@ static uschar coptable[] = {
0, /* CREF */
0, /* RREF */
0, /* DEF */
0, 0 /* BRAZERO, BRAMINZERO */
0, 0, /* BRAZERO, BRAMINZERO */
0, 0, 0, 0, /* PRUNE, SKIP, THEN, COMMIT */
0, 0 /* FAIL, ACCEPT */
};
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
@@ -1074,15 +1082,20 @@ for (;;)
int ncount = 0;
switch (c)
{
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b:
case 0x000c:
case 0x0085:
case 0x2028:
case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL01;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL01:
case 0x000a:
if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)
{
active_count--; /* Remove non-match possibility */
@@ -1091,6 +1104,7 @@ for (;;)
count++;
ADD_NEW_DATA(-state_offset, count, ncount);
break;
default:
break;
}
@@ -1307,15 +1321,20 @@ for (;;)
int ncount = 0;
switch (c)
{
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b:
case 0x000c:
case 0x0085:
case 0x2028:
case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL02;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL02:
case 0x000a:
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||
codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)
{
@@ -1324,6 +1343,7 @@ for (;;)
}
ADD_NEW_DATA(-(state_offset + count), 0, ncount);
break;
default:
break;
}
@@ -1539,15 +1559,20 @@ for (;;)
int ncount = 0;
switch (c)
{
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b:
case 0x000c:
case 0x0085:
case 0x2028:
case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL03;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL03:
case 0x000a:
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)
{
active_count--; /* Remove non-match possibility */
@@ -1558,6 +1583,7 @@ for (;;)
else
{ ADD_NEW_DATA(-state_offset, count, ncount); }
break;
default:
break;
}
@@ -1738,14 +1764,17 @@ for (;;)
case OP_ANYNL:
if (clen > 0) switch(c)
{
case 0x000a:
case 0x000b:
case 0x000c:
case 0x0085:
case 0x2028:
case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
case 0x000a:
ADD_NEW(state_offset + 1, 0);
break;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a)
{
@@ -2568,6 +2597,18 @@ md->end_subject = end_subject;
md->moptions = options;
md->poptions = re->options;
/* If the BSR option is not set at match time, copy what was set
at compile time. */
if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0)
{
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE);
#ifdef BSR_ANYCRLF
else md->moptions |= PCRE_BSR_ANYCRLF;
#endif
}
/* Handle different types of newline. The three bits give eight cases. If
nothing is set at run time, whatever was used at compile time applies. */
@@ -2638,7 +2679,7 @@ if (md->tables == NULL) md->tables = _pcre_default_tables;
used in a loop when finding where to start. */
lcc = md->tables + lcc_offset;
startline = (re->options & PCRE_STARTLINE) != 0;
startline = (re->flags & PCRE_STARTLINE) != 0;
firstline = (re->options & PCRE_FIRSTLINE) != 0;
/* Set up the first character to match, if available. The first_byte value is
@@ -2649,7 +2690,7 @@ studied, there may be a bitmap of possible first characters. */
if (!anchored)
{
if ((re->options & PCRE_FIRSTSET) != 0)
if ((re->flags & PCRE_FIRSTSET) != 0)
{
first_byte = re->first_byte & 255;
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
@@ -2666,7 +2707,7 @@ if (!anchored)
/* For anchored or unanchored matches, there may be a "last known required
character" set. */
if ((re->options & PCRE_REQCHSET) != 0)
if ((re->flags & PCRE_REQCHSET) != 0)
{
req_byte = re->req_byte & 255;
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
@@ -2836,16 +2877,17 @@ for (;;)
}
if (current_subject > end_subject) break;
/* If we have just passed a CR and the newline option is CRLF or ANY or
ANYCRLF, and we are now at a LF, advance the match position by one more
character. */
/* If we have just passed a CR and we are now at a LF, and the pattern does
not contain any explicit matches for \r or \n, and the newline option is CRLF
or ANY or ANYCRLF, advance the match position by one more character. */
if (current_subject[-1] == '\r' &&
(md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2) &&
current_subject < end_subject &&
*current_subject == '\n')
current_subject < end_subject &&
*current_subject == '\n' &&
(re->flags & PCRE_HASCRORLF) == 0 &&
(md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2))
current_subject++;
} /* "Bumpalong" loop */