Re: [PATCH v3 4/7] grep.c: display column number of first match
On Tue, Apr 24, 2018 at 1:07 AM, Taylor Blau <me@ttaylorr.com> wrote:
Show 13 quoted lines
> To prepare for 'git grep' learning '--column-number', teach grep.c's
> show_line() how to show the column of the first match on non-context
> line.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
> diff --git a/grep.c b/grep.c
> @@ -1399,6 +1399,17 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
> + /**
> + * Treat 'cno' as the 1-indexed offset from the start of a non-context
> + * line to its first match. Otherwise, 'cno' is 0 indicating that we are
> + * being called with a context line.
> + */
Nit: Ævar's review[1] mentioned that this project tends to use
/*...*/, not /**...*/.
[1]: https://public-inbox.org/git/874lk2e4he.fsf@evledraar.gmail.com/
Show 6 quoted lines
> + if (opt->columnnum && cno) {
> + char buf[32];
> + xsnprintf(buf, sizeof(buf), "%d", cno);
> + output_color(opt, buf, strlen(buf), opt->color_columnno);
> + output_sep(opt, sign);
> + }