2021-02-05 Paul Eggert <eggert@cs.ucla.edu>
+ regex: avoid duplicate in espilon closure
+ * lib/regcomp.c (calc_eclosure_iter): Insert NODE into epsilon
+ closure first rather than last. Otherwise, the epsilon closure
+ might contain a duplicate of NODE.
+
regex-tests: fix typo
* tests/test-regex.c (main): Fix typo that would have caused an
old test case to report incorrect values on failure.
reg_errcode_t err;
Idx i;
re_node_set eclosure;
- bool ok;
bool incomplete = false;
err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
if (__glibc_unlikely (err != REG_NOERROR))
return err;
+ /* An epsilon closure includes itself. */
+ eclosure.elems[eclosure.nelem++] = node;
+
/* This indicates that we are calculating this node now.
We reference this value to avoid infinite loop. */
dfa->eclosures[node].nelem = -1;
}
}
- /* An epsilon closure includes itself. */
- ok = re_node_set_insert (&eclosure, node);
- if (__glibc_unlikely (! ok))
- return REG_ESPACE;
if (incomplete && !root)
dfa->eclosures[node].nelem = 0;
else