On Mon, Oct 10, 2016 at 09:53:55PM +0200, Martijn van Duren wrote:

> Hello tech@,
> 
> As reported and fixed by pfg@freebsd.
> Fixes the following case:
> % echo z | gsed -n -e 's/^a*/b/2p'
> # empty -- correct
> % echo z |  sed -n -e 's/^a*/b/2p'
> z # incorrect
> 
> Fix in FreeBSD r302973
> 
> OK?

It looks ok, although I prefer it to go with a regress test.
I verified the current regress tests still pass with this diff.

        -Otto

> 
> martijn@
> 
> Index: process.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/sed/process.c,v
> retrieving revision 1.28
> diff -u -p -r1.28 process.c
> --- process.c 30 May 2016 18:10:29 -0000      1.28
> +++ process.c 10 Oct 2016 19:48:58 -0000
> @@ -404,7 +404,7 @@ substitute(struct s_command *cp)
>           regexec_e(re, ps, REG_NOTBOL, 0, le, psl));
>  
>       /* Did not find the requested number of matches. */
> -     if (n > 1)
> +     if (n > 0)
>               return (0);
>  
>       /* Copy the trailing retained string. */

Reply via email to