diff options
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 42 |
1 files changed, 20 insertions, 22 deletions
@@ -1112,33 +1112,31 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, output_sep(opt, sign); } if (opt->color) { - if (sign == ':') { - /* paint the hits on matched lines */ - regmatch_t match; - enum grep_context ctx = GREP_CONTEXT_BODY; - int ch = *eol; - int eflags = 0; + regmatch_t match; + enum grep_context ctx = GREP_CONTEXT_BODY; + int ch = *eol; + int eflags = 0; + if (sign == ':') line_color = opt->color_selected; - *eol = '\0'; - while (next_match(opt, bol, eol, ctx, &match, eflags)) { - if (match.rm_so == match.rm_eo) - break; - - output_color(opt, bol, match.rm_so, line_color); - output_color(opt, bol + match.rm_so, - match.rm_eo - match.rm_so, - opt->color_match); - bol += match.rm_eo; - rest -= match.rm_eo; - eflags = REG_NOTBOL; - } - *eol = ch; - } else if (sign == '-') { + else if (sign == '-') line_color = opt->color_context; - } else if (sign == '=') { + else if (sign == '=') line_color = opt->color_function; + *eol = '\0'; + while (next_match(opt, bol, eol, ctx, &match, eflags)) { + if (match.rm_so == match.rm_eo) + break; + + output_color(opt, bol, match.rm_so, line_color); + output_color(opt, bol + match.rm_so, + match.rm_eo - match.rm_so, + opt->color_match); + bol += match.rm_eo; + rest -= match.rm_eo; + eflags = REG_NOTBOL; } + *eol = ch; } output_color(opt, bol, rest, line_color); opt->output(opt, "\n", 1); |