Subject: bug#18762: closed (Re: bug#18762: [PATCH] dfa: don't consider RE_DOT_NEWLINE and RE_DOT_NOT_NULL in matching with a bracket expression)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 20 Oct 2014 01:26:02 +0000

Your bug report

#18762: [PATCH] dfa: don't consider RE_DOT_NEWLINE and RE_DOT_NOT_NULL in matching with a bracket expression

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
18762: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18762
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#18762: [PATCH] dfa: don't consider RE_DOT_NEWLINE and RE_DOT_NOT_NULL in matching with a bracket expression
From: Jim Meyering <[email-masked]>
To: Norihiro Tanaka <[email-masked]>
Cc: [email-masked]
Date: Sun, 19 Oct 2014 18:24:56 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On Sat, Oct 18, 2014 at 7:07 PM, Norihiro Tanaka <[email-masked]> wrote:
> Jim Meyering <[email-masked]> wrote:
>> dfa.c's match_mb_charset function *is* used, e.g., in a
>> command like this one:
>>
>>   printf '\0' |src/grep -aE '^\s?$'
>
> Wow, just it isn't good.  I think that behavior of `fails' should be
> same as of `trans' except `fails' checks accepted conditions, including
> following part.  match_mb_charset() should be avoided as far as possible,
> as it doesn't support collating symbols and equivalence classes.
>
>>               /* Falling back to the glibc matcher in this case gives
>>                  better performance (up to 25% better on [a-z], for
>>                  example) and enables support for collating symbols and
>>                  equivalence classes.  */
>>               if (d->states[s].has_mbcset && backref)
>>                 {
>>                   *backref = 1;
>>                   goto done;
>>                 }

Nice change.  I've adjusted the commit log and added the test
above, since no other code even excercised the
now-inaccessible function. I will push it tomorrow.

Subject: [PATCH] dfa: don't consider RE_DOT_NEWLINE and RE_DOT_NOT_NULL in matching with a bracket expression
From: Norihiro Tanaka <[email-masked]>
To: [email-masked]
Date: Sat, 18 Oct 2014 21:39:37 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

RE_DOT_NEW_LINE and NOT_NULL work for '.' only in regex.  OTOH, they
work for MBCSET in addition to '.' in DFA.  This patch adapts the behavior
of DFA to of regex.

BTW, at the moment, grep and gawk never use match_mb_charset function to
be fixed by it.
From 10876f05010e2df3a0705e95a1be62cbb990fbfa Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <[email-masked]>
Date: Wed, 15 Oct 2014 08:24:23 +0900
Subject: [PATCH] dfa: don't consider RE_DOT_NEWLINE and RE_DOT_NOT_NULL in
 matching with a bracket expression

RE_DOT_NEWLINE and RE_DOT_NOT_NULL should be apply to a dot only
which matches any character.  So don't consider RE_DOT_NEWLINE and
RE_DOT_NOT_NULL in matching with a bracket expression.

* src/dfa.c (match_mb_charset): Remove RE_DOT_NEWLINE and RE_DOT_NOT_NULL.
---
 src/dfa.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 58a4b83..a4c48b5 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2998,17 +2998,7 @@ match_mb_charset (struct dfa *d, state_num s, position pos,
   int context;
 
   /* Check syntax bits.  */
-  if (wc == (wchar_t) eolbyte)
-    {
-      if (!(syntax_bits & RE_DOT_NEWLINE))
-        return 0;
-    }
-  else if (wc == (wchar_t) '\0')
-    {
-      if (syntax_bits & RE_DOT_NOT_NULL)
-        return 0;
-    }
-  else if (wc == WEOF)
+  if (wc == WEOF)
     return 0;
 
   context = wchar_context (wc);
-- 
2.1.1