grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Grep-devel] [PATCH] grep: simplify recent kwset change


From: Jim Meyering
Subject: Re: [Grep-devel] [PATCH] grep: simplify recent kwset change
Date: Mon, 23 Jan 2017 19:37:08 -0800

On Mon, Jan 23, 2017 at 4:03 PM, Paul Eggert <address@hidden> wrote:
> * src/kwset.c (acexec_trans): Simplify.
> ---
>  src/kwset.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/src/kwset.c b/src/kwset.c
> index 258cff5..3be5c42 100644
> --- a/src/kwset.c
> +++ b/src/kwset.c
> @@ -848,20 +848,15 @@ acexec_trans (kwset_t kwset, char const *text, 
> ptrdiff_t len,
>            struct trie const *accept1;
>            char const *left1;
>            unsigned char c = tr (trans, *tp++);
> -          while (true)
> +
> +          do
>              {
>                tree = trie->links;
>                while (tree && c != tree->label)
>                  tree = c < tree->label ? tree->llink : tree->rlink;
> -              if (tree)
> -                break;
> -              trie = trie->fail;
> -              if (!trie)
> -                break;
> -              left1 = tp - trie->depth;
> -              if (left1 > left)
> -                break;
>              }
> +          while (!tree && (trie = trie->fail) && accept->depth <= 
> trie->depth);
> +
>            if (!tree)
>              break;
>            trie = tree->trie;

Nice.
However, both before and after your change, the following still prints
the shorter match:

  $ echo abcdef|LC_ALL=C grep -Fof <(printf '%s\n' ab bcde)
  ab

It should print "bcde".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]