| 1149 | } |
| 1150 | |
| 1151 | static int match_next_pattern(struct grep_pat *p, |
| 1152 | const char *bol, const char *eol, |
| 1153 | enum grep_context ctx, |
| 1154 | regmatch_t *pmatch, int eflags) |
| 1155 | { |
| 1156 | regmatch_t match; |
| 1157 | |
| 1158 | if (!headerless_match_one_pattern(p, bol, eol, ctx, &match, eflags)) |
| 1159 | return 0; |
| 1160 | if (match.rm_so < 0 || match.rm_eo < 0) |
| 1161 | return 0; |
| 1162 | if (pmatch->rm_so >= 0 && pmatch->rm_eo >= 0) { |
| 1163 | if (match.rm_so > pmatch->rm_so) |
| 1164 | return 1; |
| 1165 | if (match.rm_so == pmatch->rm_so && match.rm_eo < pmatch->rm_eo) |
| 1166 | return 1; |
| 1167 | } |
| 1168 | pmatch->rm_so = match.rm_so; |
| 1169 | pmatch->rm_eo = match.rm_eo; |
| 1170 | return 1; |
| 1171 | } |
| 1172 | |
| 1173 | int grep_next_match(struct grep_opt *opt, |
| 1174 | const char *bol, const char *eol, |
no test coverage detected