Skip to content

Commit 08fd6ff

Browse files
committed
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 df1e965). 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.
1 parent 06d9afa commit 08fd6ff

File tree

3 files changed

+20
-35
lines changed

3 files changed

+20
-35
lines changed

src/backend/regex/regc_locale.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,15 @@ cclass(struct vars * v, /* context */
499499
{
500500
size_t len;
501501
struct cvec *cv = NULL;
502-
const char **namePtr;
502+
const char * const *namePtr;
503503
int i,
504504
index;
505505

506506
/*
507507
* The following arrays define the valid character class names.
508508
*/
509509

510-
static const char *classNames[] = {
510+
static const char * const classNames[] = {
511511
"alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph",
512512
"lower", "print", "punct", "space", "upper", "xdigit", NULL
513513
};

src/backend/regex/rege_dfa.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -272,36 +272,35 @@ static struct dfa *
272272
newdfa(struct vars * v,
273273
struct cnfa * cnfa,
274274
struct colormap * cm,
275-
struct smalldfa * small) /* preallocated space, may be NULL */
275+
struct smalldfa * sml) /* preallocated space, may be NULL */
276276
{
277277
struct dfa *d;
278278
size_t nss = cnfa->nstates * 2;
279279
int wordsper = (cnfa->nstates + UBITS - 1) / UBITS;
280-
struct smalldfa *smallwas = small;
280+
struct smalldfa *smallwas = sml;
281281

282282
assert(cnfa != NULL && cnfa->nstates != 0);
283283

284284
if (nss <= FEWSTATES && cnfa->ncolors <= FEWCOLORS)
285285
{
286286
assert(wordsper == 1);
287-
if (small == NULL)
287+
if (sml == NULL)
288288
{
289-
small = (struct smalldfa *) MALLOC(
290-
sizeof(struct smalldfa));
291-
if (small == NULL)
289+
sml = (struct smalldfa *) MALLOC(sizeof(struct smalldfa));
290+
if (sml == NULL)
292291
{
293292
ERR(REG_ESPACE);
294293
return NULL;
295294
}
296295
}
297-
d = &small->dfa;
298-
d->ssets = small->ssets;
299-
d->statesarea = small->statesarea;
296+
d = &sml->dfa;
297+
d->ssets = sml->ssets;
298+
d->statesarea = sml->statesarea;
300299
d->work = &d->statesarea[nss];
301-
d->outsarea = small->outsarea;
302-
d->incarea = small->incarea;
300+
d->outsarea = sml->outsarea;
301+
d->incarea = sml->incarea;
303302
d->cptsmalloced = 0;
304-
d->mallocarea = (smallwas == NULL) ? (char *) small : NULL;
303+
d->mallocarea = (smallwas == NULL) ? (char *) sml : NULL;
305304
}
306305
else
307306
{

src/backend/regex/regexec.c

+7-21
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static int dissect(struct vars *, struct subre *, chr *, chr *);
141141
static int condissect(struct vars *, struct subre *, chr *, chr *);
142142
static int altdissect(struct vars *, struct subre *, chr *, chr *);
143143
static int cdissect(struct vars *, struct subre *, chr *, chr *);
144-
static int ccaptdissect(struct vars *, struct subre *, chr *, chr *);
145144
static int ccondissect(struct vars *, struct subre *, chr *, chr *);
146145
static int crevdissect(struct vars *, struct subre *, chr *, chr *);
147146
static int cbrdissect(struct vars *, struct subre *, chr *, chr *);
@@ -708,6 +707,8 @@ cdissect(struct vars * v,
708707
chr *begin, /* beginning of relevant substring */
709708
chr *end) /* end of same */
710709
{
710+
int er;
711+
711712
assert(t != NULL);
712713
MDEBUG(("cdissect %ld-%ld %c\n", LOFF(begin), LOFF(end), t->op));
713714

@@ -727,31 +728,16 @@ cdissect(struct vars * v,
727728
return ccondissect(v, t, begin, end);
728729
case '(': /* capturing */
729730
assert(t->left != NULL && t->right == NULL);
730-
return ccaptdissect(v, t, begin, end);
731+
assert(t->subno > 0);
732+
er = cdissect(v, t->left, begin, end);
733+
if (er == REG_OKAY)
734+
subset(v, t, begin, end);
735+
return er;
731736
default:
732737
return REG_ASSERT;
733738
}
734739
}
735740

736-
/*
737-
* ccaptdissect - capture subexpression matches (with complications)
738-
*/
739-
static int /* regexec return code */
740-
ccaptdissect(struct vars * v,
741-
struct subre * t,
742-
chr *begin, /* beginning of relevant substring */
743-
chr *end) /* end of same */
744-
{
745-
int er;
746-
747-
assert(t->subno > 0);
748-
749-
er = cdissect(v, t->left, begin, end);
750-
if (er == REG_OKAY)
751-
subset(v, t, begin, end);
752-
return er;
753-
}
754-
755741
/*
756742
* ccondissect - concatenation subexpression matches (with complications)
757743
* The retry memory stores the offset of the trial midpoint from begin,

0 commit comments

Comments
 (0)