Subject: Re: bug#33249: [PATCH] grep: grouping of patterns including back reference

From: Norihiro Tanaka <[email-masked]>
Date: Sun, 04 Nov 2018 08:21:18 +0900

On Sat, 3 Nov 2018 08:29:39 -0700
Paul Eggert <[email-masked]> wrote:

> Norihiro Tanaka wrote:
> > By this change, each fragment is divided into
> > groups by whether the fragment includes back reference in a pattern or
> > not. a frgment which includes back reference constitutes group, and all
> > frgments which include back reference also constitute a group.
> 
> Surely this is not sufficient. An invocation of grep like this:
> 
> grep -E '(a
> b)'
> 
> should be an error, but with the proposed patch won't it be equivalent to "grep -E '(a|b)'" since the pattern has no back-references?

Even the pattern has no back-references, compilation by regex run for
each line.  So Syntax errors will be detected as even your present.

  212:      if (!regex_compile (dc, p, len, dc->pcount, lineno, !backref))
  213:        compilation_failed = true;

  $ env LC_ALL=C src/grep -E '(a
  b)' ~/in
  src/grep: Unmatched ( or \(