Subject: Re: grep-2.21 (and git master): --null-data and ranges work in an odd way (-P works fine)

From: Ulrich Mueller <[email-masked]>
Date: Sun, 14 Feb 2016 01:08:43 +0100

>>>>> On Sat, 13 Feb 2016, Sergei Trofimovich wrote:

> The issue is found by Ulrich Mueller:
> It seems DFA engine does not understand --null-data:

> ~/dev/git/grep $ cat a-test.sh 
> #!/bin/bash

> printf '12\n34\0' | LC_ALL=en_US.utf-8 src/grep -z    '^[1234yz]*$'  | wc -c
> printf '12\n34\0' | LC_ALL=en_US.utf-8 src/grep -P -z '^[1234yz]*$'  | wc -c
> printf '12\n34\0' | LC_ALL=en_US.utf-8 src/grep -z    '^[1234y-z]*$' | wc -c
> printf '12\n34\0' | LC_ALL=en_US.utf-8 src/grep -P -z '^[1234y-z]*$' | wc -c

> ~/dev/git/grep $ ./a-test.sh 
> 0
> 6
> 6
> 6

> All 4 should return 6 but first is not correct.
> It seems that 'y-z' range disables dfa.c code and works fine.

Hm, I think it is the other way around. \n is a normal char, so the
regex shouldn't match (and all four should return 0). In any case,
behaviour should be the same for all of them.

Downstream bug: https://bugs.gentoo.org/show_bug.cgi?id=574662

Ulrich