[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] dfa: do not use MATCHES_*_CONTEXT directly
From: |
Jim Meyering |
Subject: |
Re: [PATCH 2/4] dfa: do not use MATCHES_*_CONTEXT directly |
Date: |
Sat, 25 Feb 2012 19:28:28 +0100 |
Paolo Bonzini wrote:
> * src/dfa.c (dfastate): Use SUCCEEDS_IN_CONTEXT.
> ---
ACK, in spite of the fact that the latter half of this
patch is merely adding spaces before parentheses.
> diff --git a/src/dfa.c b/src/dfa.c
> index dc487ff..6f57536 100644
> --- a/src/dfa.c
> +++ b/src/dfa.c
> @@ -2503,23 +2503,20 @@ dfastate (int s, struct dfa *d, int trans[])
>
> /* Some characters may need to be eliminated from matches because
> they fail in the current context. */
> - if (pos.constraint != 0xFF)
> + if (pos.constraint != NO_CONSTRAINT)
> {
> - if (! MATCHES_NEWLINE_CONTEXT(pos.constraint,
> - d->states[s].context, CTX_NEWLINE))
> - clrbit(eolbyte, matches);
> - if (! MATCHES_NEWLINE_CONTEXT(pos.constraint,
> - d->states[s].context, ~CTX_NEWLINE))
> + if (! SUCCEEDS_IN_CONTEXT(pos.constraint,
> + d->states[s].context, CTX_NEWLINE))
> for (j = 0; j < CHARCLASS_INTS; ++j)
> - matches[j] &= newline[j];
> - if (! MATCHES_LETTER_CONTEXT(pos.constraint,
> - d->states[s].context, CTX_LETTER))
> + matches[j] &= ~newline[j];
> + if (! SUCCEEDS_IN_CONTEXT(pos.constraint,
> + d->states[s].context, CTX_LETTER))
> for (j = 0; j < CHARCLASS_INTS; ++j)
> matches[j] &= ~letters[j];
> - if (! MATCHES_LETTER_CONTEXT(pos.constraint,
> - d->states[s].context, ~CTX_LETTER))
> + if (! SUCCEEDS_IN_CONTEXT(pos.constraint,
> + d->states[s].context, CTX_NONE))
> for (j = 0; j < CHARCLASS_INTS; ++j)
> - matches[j] &= letters[j];
> + matches[j] &= letters[j] | newline[j];
>
> /* If there are no characters left, there's no point in going on.
> */
> for (j = 0; j < CHARCLASS_INTS && !matches[j]; ++j)
> @@ -2743,11 +2740,11 @@ build_state (int s, struct dfa *d)
>
> /* Set up the success bits for this state. */
> d->success[s] = 0;
> - if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_NEWLINE, s, *d))
> + if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s, *d))
> d->success[s] |= CTX_NEWLINE;
> - if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_LETTER, s, *d))
> + if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_LETTER, s, *d))
> d->success[s] |= CTX_LETTER;
> - if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_NONE, s, *d))
> + if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NONE, s, *d))
> d->success[s] |= CTX_NONE;
>
> MALLOC(trans, NOTCHAR);
> @@ -2928,7 +2925,7 @@ match_anychar (struct dfa *d, int s, position pos, int
> idx)
> }
>
> context = wchar_context(wc);
> - if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].context, context))
> + if (!SUCCEEDS_IN_CONTEXT (pos.constraint, d->states[s].context, context))
> return 0;
>
> return mbclen;
> @@ -2970,7 +2967,7 @@ match_mb_charset (struct dfa *d, int s, position pos,
> int idx)
> }
>
> context = wchar_context(wc);
> - if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].context, context))
> + if (!SUCCEEDS_IN_CONTEXT (pos.constraint, d->states[s].context, context))
> return 0;
>
> /* Assign the current refering operator to work_mbc. */