MCPcopy Index your code
hub / github.com/git/git / show_line_header

Function show_line_header

grep.c:1205–1235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1203}
1204
1205static void show_line_header(struct grep_opt *opt, const char *name,
1206 unsigned lno, ssize_t cno, char sign)
1207{
1208 if (opt->heading && opt->last_shown == 0) {
1209 output_color(opt, name, strlen(name), opt->colors[GREP_COLOR_FILENAME]);
1210 opt->output(opt, "\n", 1);
1211 }
1212 opt->last_shown = lno;
1213
1214 if (!opt->heading && opt->pathname) {
1215 output_color(opt, name, strlen(name), opt->colors[GREP_COLOR_FILENAME]);
1216 output_sep(opt, sign);
1217 }
1218 if (opt->linenum) {
1219 char buf[32];
1220 xsnprintf(buf, sizeof(buf), "%d", lno);
1221 output_color(opt, buf, strlen(buf), opt->colors[GREP_COLOR_LINENO]);
1222 output_sep(opt, sign);
1223 }
1224 /*
1225 * Treat 'cno' as the 1-indexed offset from the start of a non-context
1226 * line to its first match. Otherwise, 'cno' is 0 indicating that we are
1227 * being called with a context line.
1228 */
1229 if (opt->columnnum && cno) {
1230 char buf[32];
1231 xsnprintf(buf, sizeof(buf), "%"PRIuMAX, (uintmax_t)cno);
1232 output_color(opt, buf, strlen(buf), opt->colors[GREP_COLOR_COLUMNNO]);
1233 output_sep(opt, sign);
1234 }
1235}
1236
1237static void show_line(struct grep_opt *opt,
1238 const char *bol, const char *eol,

Callers 1

show_lineFunction · 0.85

Calls 3

output_colorFunction · 0.85
output_sepFunction · 0.85
xsnprintfFunction · 0.85

Tested by

no test coverage detected