grep-devel
[Top][All Lists]
Advanced

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

Re: [Grep-devel] Proposed patch: remove DFA_CASE_FOLD


From: Jim Meyering
Subject: Re: [Grep-devel] Proposed patch: remove DFA_CASE_FOLD
Date: Tue, 6 Dec 2016 22:42:26 -0800

On Tue, Nov 29, 2016 at 2:49 AM,  <address@hidden> wrote:
> Hi.
>
> Regex already gives us RE_ICASE.  dfa.c can just use that instead
> of DFA_CASE_FOLD.
...
> diff --git a/lib/dfa.h b/lib/dfa.h
> index 9787d76..500ee76 100644
> --- a/lib/dfa.h
> +++ b/lib/dfa.h
> @@ -58,11 +58,8 @@ enum
>         possibly true for other apps.  */
>      DFA_ANCHOR = 1 << 0,
>
> -    /* Ignore case while matching.  */
> -    DFA_CASE_FOLD = 1 << 1,
> -
>      /* '\0' in data is end-of-line, instead of the traditional '\n'.  */
> -    DFA_EOL_NUL = 1 << 2
> +    DFA_EOL_NUL = 1 << 1
>    };
>
>  /* Initialize or reinitialize a DFA.  This must be called before
> diff --git a/src/dfasearch.c b/src/dfasearch.c
> index ded9917..7eec4d8 100644
> --- a/src/dfasearch.c
> +++ b/src/dfasearch.c
> @@ -121,8 +121,7 @@ GEAcompile (char const *pattern, size_t size, 
> reg_syntax_t syntax_bits)
>    if (match_icase)
>      syntax_bits |= RE_ICASE;
>    re_set_syntax (syntax_bits);
> -  int dfaopts = ((match_icase ? DFA_CASE_FOLD : 0)
> -                 | (eolbyte ? 0 : DFA_EOL_NUL));
> +  int dfaopts = (eolbyte ? 0 : DFA_EOL_NUL);

Hi Arnold,

This change would enable a small simplification in each definition of
"dfaopts." However, it does that at the cost of changing the public
API of the dfa module and making it dependent on the regex one. I.e.,
it would change the value of DFA_EOL_NUL (I would object even if this
value were left unchanged) and makes dfa's API depend on the RE_ICASE
value provided by regex headers. I doubt there is any guarantee that
its value does not collide with DFA_EOL_NUL. Sure, for your use of dfa
in gawk, I presume there is no such risk (recalling that gawk always
uses the included regex code), but I would like dfa to continue to
work independently of any package-provided regex code.

Sorry, but it doesn't seem worth the cost.



reply via email to

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