| 1116 | } |
| 1117 | |
| 1118 | static 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 | |
| 1151 | static int match_next_pattern(struct grep_pat *p, |
| 1152 | const char *bol, const char *eol, |
no test coverage detected