version 1.28, 2020/06/10 21:03:36 |
version 1.29, 2020/06/10 21:03:56 |
|
|
overflo(__func__); |
overflo(__func__); |
} |
} |
|
|
fa *makedfa(const char *s, int anchor) /* returns dfa for reg expr s */ |
fa *makedfa(const char *s, bool anchor) /* returns dfa for reg expr s */ |
{ |
{ |
int i, use, nuse; |
int i, use, nuse; |
fa *pfa; |
fa *pfa; |
|
|
allocsetvec(__func__); |
allocsetvec(__func__); |
} |
} |
|
|
if (compile_time) /* a constant for sure */ |
if (compile_time != RUNNING) /* a constant for sure */ |
return mkdfa(s, anchor); |
return mkdfa(s, anchor); |
for (i = 0; i < nfatab; i++) /* is it there already? */ |
for (i = 0; i < nfatab; i++) /* is it there already? */ |
if (fatab[i]->anchor == anchor |
if (fatab[i]->anchor == anchor |
|
|
return pfa; |
return pfa; |
} |
} |
|
|
fa *mkdfa(const char *s, int anchor) /* does the real work of making a dfa */ |
fa *mkdfa(const char *s, bool anchor) /* does the real work of making a dfa */ |
/* anchor = 1 for anchored matches, else 0 */ |
/* anchor = 1 for anchored matches, else 0 */ |
{ |
{ |
Node *p, *p1; |
Node *p, *p1; |
|
|
return f; |
return f; |
} |
} |
|
|
int makeinit(fa *f, int anchor) |
int makeinit(fa *f, bool anchor) |
{ |
{ |
int i, k; |
int i, k; |
|
|
|
|
* a match is found, patbeg and patlen are set appropriately. |
* a match is found, patbeg and patlen are set appropriately. |
* |
* |
* RETURN VALUES |
* RETURN VALUES |
* 0 No match found. |
* false No match found. |
* 1 Match found. |
* true Match found. |
*/ |
*/ |
|
|
int fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum) |
bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum) |
{ |
{ |
char *buf = *pbuf; |
char *buf = *pbuf; |
int bufsize = *pbufsize; |
int bufsize = *pbufsize; |
|
|
FATAL("unable to ungetc '%c'", buf[k]); |
FATAL("unable to ungetc '%c'", buf[k]); |
while (k > i + patlen); |
while (k > i + patlen); |
buf[k] = 0; |
buf[k] = 0; |
return 1; |
return true; |
} |
} |
else |
else |
return 0; |
return false; |
} |
} |
|
|
Node *reparse(const char *p) /* parses regular expression pointed to by p */ |
Node *reparse(const char *p) /* parses regular expression pointed to by p */ |
|
|
int i, j; |
int i, j; |
uschar *buf = NULL; |
uschar *buf = NULL; |
int ret = 1; |
int ret = 1; |
int init_q = (firstnum==0); /* first added char will be ? */ |
int init_q = (firstnum == 0); /* first added char will be ? */ |
int n_q_reps = secondnum-firstnum; /* m>n, so reduce until {1,m-n} left */ |
int n_q_reps = secondnum-firstnum; /* m>n, so reduce until {1,m-n} left */ |
int prefix_length = reptok - basestr; /* prefix includes first rep */ |
int prefix_length = reptok - basestr; /* prefix includes first rep */ |
int suffix_length = strlen((const char *) reptok) - reptoklen; /* string after rep specifier */ |
int suffix_length = strlen((const char *) reptok) - reptoklen; /* string after rep specifier */ |
|
|
if (special_case == REPEAT_PLUS_APPENDED) { |
if (special_case == REPEAT_PLUS_APPENDED) { |
buf[j++] = '+'; |
buf[j++] = '+'; |
} else if (special_case == REPEAT_WITH_Q) { |
} else if (special_case == REPEAT_WITH_Q) { |
if (init_q) buf[j++] = '?'; |
if (init_q) |
for (i=0; i < n_q_reps; i++) { /* copy x? reps */ |
buf[j++] = '?'; |
|
for (i = 0; i < n_q_reps; i++) { /* copy x? reps */ |
memcpy(&buf[j], atom, atomlen); |
memcpy(&buf[j], atom, atomlen); |
j += atomlen; |
j += atomlen; |
buf[j++] = '?'; |
buf[j++] = '?'; |
|
|
uschar *bp; |
uschar *bp; |
struct charclass *cc; |
struct charclass *cc; |
int i; |
int i; |
int num, m, commafound, digitfound; |
int num, m; |
|
bool commafound, digitfound; |
const uschar *startreptok; |
const uschar *startreptok; |
static int parens = 0; |
static int parens = 0; |
|
|
|
|
if (isdigit(*(prestr))) { |
if (isdigit(*(prestr))) { |
num = 0; /* Process as a repetition */ |
num = 0; /* Process as a repetition */ |
n = -1; m = -1; |
n = -1; m = -1; |
commafound = 0; |
commafound = false; |
digitfound = 0; |
digitfound = false; |
startreptok = prestr-1; |
startreptok = prestr-1; |
/* Remember start of previous atom here ? */ |
/* Remember start of previous atom here ? */ |
} else { /* just a { char, not a repetition */ |
} else { /* just a { char, not a repetition */ |
|
|
lastre); |
lastre); |
} else if (isdigit(c)) { |
} else if (isdigit(c)) { |
num = 10 * num + c - '0'; |
num = 10 * num + c - '0'; |
digitfound = 1; |
digitfound = true; |
} else if (c == ',') { |
} else if (c == ',') { |
if (commafound) |
if (commafound) |
FATAL("illegal repetition expression: class %.20s", |
FATAL("illegal repetition expression: class %.20s", |
lastre); |
lastre); |
/* looking for {n,} or {n,m} */ |
/* looking for {n,} or {n,m} */ |
commafound = 1; |
commafound = true; |
n = num; |
n = num; |
digitfound = 0; /* reset */ |
digitfound = false; /* reset */ |
num = 0; |
num = 0; |
} else { |
} else { |
FATAL("illegal repetition expression: class %.20s", |
FATAL("illegal repetition expression: class %.20s", |