Re: grep(1) bug - duplicate output lines

From: Jamie Landeg-Jones <jamie_at_catflap.org>
Date: Fri, 29 Sep 2023 16:29:30 UTC
Kyle Evans <kevans@FreeBSD.org> wrote:

> I think this is what we want:
>
> https://people.freebsd.org/~kevans/grep-color.diff

Brilliant! Thanks for the quick response and fix. It works fine for me -
I've not managed to break it again :-)

> Basically, for --color with . we actually get each individual character 
> reported, and we can't really coalesce that. (Well, we could, but I'll 
> leave that for future improvement). Once you hit 32 matches in the same 
> line, we dump out the first set of matches then check again for any more
> that just didn't fit the first time. Unfortunately, that logic wasn't 
> prepared to avoid terminating the first time in case we have more 
> matches to output, so we'd terminate, then refill our matches with the 
> remainder of the line and output the leading context again + terminate 
> again.

Ahh, hence the 'chunks' of coloured sections, and the fact that the longer
the line, the more times it was repeated.

Will this be MFC'd to 13 and 14?

Thanks again, Jamie.