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

Function look_ahead

grep.c:1456–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1454}
1455
1456static int look_ahead(struct grep_opt *opt,
1457 unsigned long *left_p,
1458 unsigned *lno_p,
1459 const char **bol_p)
1460{
1461 unsigned lno = *lno_p;
1462 const char *bol = *bol_p;
1463 struct grep_pat *p;
1464 const char *sp, *last_bol;
1465 regoff_t earliest = -1;
1466
1467 for (p = opt->pattern_list; p; p = p->next) {
1468 int hit;
1469 regmatch_t m;
1470
1471 hit = patmatch(p, bol, bol + *left_p, &m, 0);
1472 if (hit < 0)
1473 return -1;
1474 if (!hit || m.rm_so < 0 || m.rm_eo < 0)
1475 continue;
1476 if (earliest < 0 || m.rm_so < earliest)
1477 earliest = m.rm_so;
1478 }
1479
1480 if (earliest < 0) {
1481 *bol_p = bol + *left_p;
1482 *left_p = 0;
1483 return 1;
1484 }
1485 for (sp = bol + earliest; bol < sp && sp[-1] != '\n'; sp--)
1486 ; /* find the beginning of the line */
1487 last_bol = sp;
1488
1489 for (sp = bol; sp < last_bol; sp++) {
1490 if (*sp == '\n')
1491 lno++;
1492 }
1493 *left_p -= last_bol - bol;
1494 *bol_p = last_bol;
1495 *lno_p = lno;
1496 return 0;
1497}
1498
1499static int fill_textconv_grep(struct repository *r,
1500 struct userdiff_driver *driver,

Callers 1

grep_source_1Function · 0.85

Calls 1

patmatchFunction · 0.85

Tested by

no test coverage detected