GNU bug report logs - #22655
grep-2.21 (and git master): --null-data and ranges work in an odd way (-P works fine)

Previous Next

Package: grep;

Reported by: Sergei Trofimovich <slyfox <at> gentoo.org>

Date: Sat, 13 Feb 2016 23:24:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Zev Weiss <zev <at> bewilderbeest.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 22655 <at> debbugs.gnu.org, Stephane Chazelas <stephane.chazelas <at> gmail.com>
Subject: bug#22655: grep -Pz '^' now fails!
Date: Sat, 19 Nov 2016 03:22:07 -0600
On Sat, Nov 19, 2016 at 12:36:12AM -0800, Paul Eggert wrote:
>Stephane Chazelas wrote:
>>one can
>>use (?m) if he wants ^ to match the beginning of each line in
>>the NUL-delimited record instead of just the beginning of the
>>record.
>
>I think the intent is that ^ and $ should match only the 
>line-terminator specified by -z (or by -z's absence). So the sort of 
>usage you describe is unspecified and not supported. That being said, 
>it does make sense to match tricky regular expressions like that line 
>by line, even if this hurts performance. Otherwise, I suspect there 
>are even trickier regular expressions that could reject a buffer full 
>of lines even though it contains matching lines. When in doubt we 
>should avoid optimization so I installed the attached patch into the 
>master branch. Please give it a try.

>From 0e00fe0fc34184b1cdcea92a671eb9ffebb4899b Mon Sep 17 00:00:00 2001
>From: Paul Eggert <eggert <at> cs.ucla.edu>
>Date: Sat, 19 Nov 2016 00:25:46 -0800
>Subject: [PATCH] grep: -Pz no longer rejects ^, $
>
>Problem reported by Stephane Chazelas (Bug#22655).
>* NEWS: Document this.
>* doc/grep.texi (grep Programs): Warn about -Pz.
>* src/pcresearch.c (reflags): New static var.
>(multibyte_locale): Remove static var; now local to Pcompile.
>(Pcompile): Check for (? and (* too.  Set reflags instead of
>dying when problematic operators are found.
>(Pexecute): Use reflags to decide whether searches should
>be multiline.
>* tests/pcre: Test new behavior.

I'm a bit confused by this patch -- I see 'reflags' being tested in 
Pexecute(), but I don't see it getting set anywhere, just Pcompile()'s 
local 'flags'...I'm guessing 'flags' was supposed to be replaced by 
'reflags'?  (Not entirely certain though.)


Zev





This bug report was last modified 8 years and 190 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.