Sync regex code with Tcl 8.5.11.

Sync our regex code with upstream changes since last time we did this,
which was Tcl 8.5.0 (see commit df1e965e12).

There are no functional changes here; the main point is just to lay down
a commit-log marker that somebody has looked at this recently, and to do
what we can to keep the two codebases comparable.
This commit is contained in:
Tom Lane 2012-02-17 19:44:26 -05:00
parent 06d9afa6f9
commit 08fd6ff37f
3 changed files with 20 additions and 35 deletions

View File

@ -499,7 +499,7 @@ cclass(struct vars * v, /* context */
{ {
size_t len; size_t len;
struct cvec *cv = NULL; struct cvec *cv = NULL;
const char **namePtr; const char * const *namePtr;
int i, int i,
index; index;
@ -507,7 +507,7 @@ cclass(struct vars * v, /* context */
* The following arrays define the valid character class names. * The following arrays define the valid character class names.
*/ */
static const char *classNames[] = { static const char * const classNames[] = {
"alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph",
"lower", "print", "punct", "space", "upper", "xdigit", NULL "lower", "print", "punct", "space", "upper", "xdigit", NULL
}; };

View File

@ -272,36 +272,35 @@ static struct dfa *
newdfa(struct vars * v, newdfa(struct vars * v,
struct cnfa * cnfa, struct cnfa * cnfa,
struct colormap * cm, struct colormap * cm,
struct smalldfa * small) /* preallocated space, may be NULL */ struct smalldfa * sml) /* preallocated space, may be NULL */
{ {
struct dfa *d; struct dfa *d;
size_t nss = cnfa->nstates * 2; size_t nss = cnfa->nstates * 2;
int wordsper = (cnfa->nstates + UBITS - 1) / UBITS; int wordsper = (cnfa->nstates + UBITS - 1) / UBITS;
struct smalldfa *smallwas = small; struct smalldfa *smallwas = sml;
assert(cnfa != NULL && cnfa->nstates != 0); assert(cnfa != NULL && cnfa->nstates != 0);
if (nss <= FEWSTATES && cnfa->ncolors <= FEWCOLORS) if (nss <= FEWSTATES && cnfa->ncolors <= FEWCOLORS)
{ {
assert(wordsper == 1); assert(wordsper == 1);
if (small == NULL) if (sml == NULL)
{ {
small = (struct smalldfa *) MALLOC( sml = (struct smalldfa *) MALLOC(sizeof(struct smalldfa));
sizeof(struct smalldfa)); if (sml == NULL)
if (small == NULL)
{ {
ERR(REG_ESPACE); ERR(REG_ESPACE);
return NULL; return NULL;
} }
} }
d = &small->dfa; d = &sml->dfa;
d->ssets = small->ssets; d->ssets = sml->ssets;
d->statesarea = small->statesarea; d->statesarea = sml->statesarea;
d->work = &d->statesarea[nss]; d->work = &d->statesarea[nss];
d->outsarea = small->outsarea; d->outsarea = sml->outsarea;
d->incarea = small->incarea; d->incarea = sml->incarea;
d->cptsmalloced = 0; d->cptsmalloced = 0;
d->mallocarea = (smallwas == NULL) ? (char *) small : NULL; d->mallocarea = (smallwas == NULL) ? (char *) sml : NULL;
} }
else else
{ {

View File

@ -141,7 +141,6 @@ static int dissect(struct vars *, struct subre *, chr *, chr *);
static int condissect(struct vars *, struct subre *, chr *, chr *); static int condissect(struct vars *, struct subre *, chr *, chr *);
static int altdissect(struct vars *, struct subre *, chr *, chr *); static int altdissect(struct vars *, struct subre *, chr *, chr *);
static int cdissect(struct vars *, struct subre *, chr *, chr *); static int cdissect(struct vars *, struct subre *, chr *, chr *);
static int ccaptdissect(struct vars *, struct subre *, chr *, chr *);
static int ccondissect(struct vars *, struct subre *, chr *, chr *); static int ccondissect(struct vars *, struct subre *, chr *, chr *);
static int crevdissect(struct vars *, struct subre *, chr *, chr *); static int crevdissect(struct vars *, struct subre *, chr *, chr *);
static int cbrdissect(struct vars *, struct subre *, chr *, chr *); static int cbrdissect(struct vars *, struct subre *, chr *, chr *);
@ -708,6 +707,8 @@ cdissect(struct vars * v,
chr *begin, /* beginning of relevant substring */ chr *begin, /* beginning of relevant substring */
chr *end) /* end of same */ chr *end) /* end of same */
{ {
int er;
assert(t != NULL); assert(t != NULL);
MDEBUG(("cdissect %ld-%ld %c\n", LOFF(begin), LOFF(end), t->op)); MDEBUG(("cdissect %ld-%ld %c\n", LOFF(begin), LOFF(end), t->op));
@ -727,29 +728,14 @@ cdissect(struct vars * v,
return ccondissect(v, t, begin, end); return ccondissect(v, t, begin, end);
case '(': /* capturing */ case '(': /* capturing */
assert(t->left != NULL && t->right == NULL); assert(t->left != NULL && t->right == NULL);
return ccaptdissect(v, t, begin, end);
default:
return REG_ASSERT;
}
}
/*
* ccaptdissect - capture subexpression matches (with complications)
*/
static int /* regexec return code */
ccaptdissect(struct vars * v,
struct subre * t,
chr *begin, /* beginning of relevant substring */
chr *end) /* end of same */
{
int er;
assert(t->subno > 0); assert(t->subno > 0);
er = cdissect(v, t->left, begin, end); er = cdissect(v, t->left, begin, end);
if (er == REG_OKAY) if (er == REG_OKAY)
subset(v, t, begin, end); subset(v, t, begin, end);
return er; return er;
default:
return REG_ASSERT;
}
} }
/* /*