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

Function match_line

grep.c:1118–1149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1116}
1117
1118static int match_line(struct grep_opt *opt,
1119 const char *bol, const char *eol,
1120 ssize_t *col, ssize_t *icol,
1121 enum grep_context ctx, int collect_hits)
1122{
1123 struct grep_pat *p;
1124 int hit = 0;
1125
1126 if (opt->pattern_expression)
1127 return match_expr(opt, bol, eol, ctx, col, icol,
1128 collect_hits);
1129
1130 /* we do not call with collect_hits without being extended */
1131 for (p = opt->pattern_list; p; p = p->next) {
1132 regmatch_t tmp;
1133 if (match_one_pattern(p, bol, eol, ctx, &tmp, 0)) {
1134 hit |= 1;
1135 if (!opt->columnnum) {
1136 /*
1137 * Without --column, any single match on a line
1138 * is enough to know that it needs to be
1139 * printed. With --column, scan _all_ patterns
1140 * to find the earliest.
1141 */
1142 break;
1143 }
1144 if (*col < 0 || tmp.rm_so < *col)
1145 *col = tmp.rm_so;
1146 }
1147 }
1148 return hit;
1149}
1150
1151static int match_next_pattern(struct grep_pat *p,
1152 const char *bol, const char *eol,

Callers 1

grep_source_1Function · 0.85

Calls 2

match_exprFunction · 0.85
match_one_patternFunction · 0.85

Tested by

no test coverage detected