2016-11-25 Paul Eggert <eggert@cs.ucla.edu>
+ dfa: simplify with new function fillset
+ * lib/dfa.c (fillset): New function.
+ Use it for clarity when applicable.
+
dfa: fix glitches with on-demand states
Also, adjust commentary to better match new code.
Some of these glitches predate the recent change.
}
static void
-notset (charclass s)
+fillset (charclass s)
{
int i;
+ for (i = 0; i < CHARCLASS_WORDS; i++)
+ s[i] = CHARCLASS_WORD_MASK;
+}
+static void
+notset (charclass s)
+{
+ int i;
for (i = 0; i < CHARCLASS_WORDS; ++i)
s[i] = CHARCLASS_WORD_MASK & ~s[i];
}
goto normal_char;
if (dfa->canychar == (size_t) -1)
{
- zeroset (ccl);
- notset (ccl);
+ fillset (ccl);
if (!(dfa->syntax.syntax_bits & RE_DOT_NEWLINE))
clrbit ('\n', ccl);
if (dfa->syntax.syntax_bits & RE_DOT_NOT_NULL)
group.elems = xnmalloc (d->nleaves, sizeof *group.elems);
group.nelem = 0;
- zeroset (label);
- notset (label);
+ fillset (label);
for (i = 0; i < d->states[s].elems.nelem; ++i)
{
dfassbuild (struct dfa *d)
{
size_t i, j;
- charclass ccl;
bool have_achar = false;
bool have_nchar = false;
struct dfa *sup = dfaalloc ();
case ANYCHAR:
case MBCSET:
case BACKREF:
- zeroset (ccl);
- notset (ccl);
- sup->tokens[j++] = CSET + charclass_index (sup, ccl);
- sup->tokens[j++] = STAR;
- if (d->tokens[i + 1] == QMARK || d->tokens[i + 1] == STAR
- || d->tokens[i + 1] == PLUS)
- i++;
- have_achar = true;
+ {
+ charclass ccl;
+ fillset (ccl);
+ sup->tokens[j++] = CSET + charclass_index (sup, ccl);
+ sup->tokens[j++] = STAR;
+ if (d->tokens[i + 1] == QMARK || d->tokens[i + 1] == STAR
+ || d->tokens[i + 1] == PLUS)
+ i++;
+ have_achar = true;
+ }
break;
case BEGWORD:
case ENDWORD: