Lines 339-345
main(int argc, char *argv[])
Link Here
|
339 |
const char *pn; |
339 |
const char *pn; |
340 |
unsigned long long l; |
340 |
unsigned long long l; |
341 |
unsigned int aargc, eargc, i; |
341 |
unsigned int aargc, eargc, i; |
342 |
int c, lastc, needpattern, newarg, prevoptind; |
342 |
int c, lastc, needpattern, newarg, prevoptind, pofs; |
343 |
|
343 |
|
344 |
setlocale(LC_ALL, ""); |
344 |
setlocale(LC_ALL, ""); |
345 |
|
345 |
|
Lines 704-721
main(int argc, char *argv[])
Link Here
|
704 |
|
704 |
|
705 |
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); |
705 |
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); |
706 |
r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); |
706 |
r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); |
|
|
707 |
pofs = 0; |
707 |
|
708 |
|
708 |
/* Check if cheating is allowed (always is for fgrep). */ |
709 |
/* Check if cheating is allowed (always is for fgrep). */ |
709 |
for (i = 0; i < patterns; ++i) { |
710 |
for (i = 0; i < patterns; ++i) { |
710 |
if (fastncomp(&fg_pattern[i], pattern[i].pat, |
711 |
if (fastncomp(&fg_pattern[i - pofs], pattern[i].pat, |
711 |
pattern[i].len, cflags) != 0) { |
712 |
pattern[i].len, cflags) != 0) { |
712 |
/* Fall back to full regex library */ |
713 |
/* Fall back to full regex library */ |
713 |
c = regcomp(&r_pattern[i], pattern[i].pat, cflags); |
714 |
c = regcomp(&r_pattern[i - pofs], pattern[i].pat, cflags); |
714 |
if (c != 0) { |
715 |
if (c != 0) { |
715 |
regerror(c, &r_pattern[i], re_error, |
716 |
regerror(c, &r_pattern[i - pofs], re_error, |
716 |
RE_ERROR_BUF); |
717 |
RE_ERROR_BUF); |
717 |
errx(2, "%s", re_error); |
718 |
errx(2, "%s", re_error); |
718 |
} |
719 |
} |
|
|
720 |
} else { |
721 |
/* Deduct one for invalid pattern */ |
722 |
patterns --; |
723 |
pofs ++; |
719 |
} |
724 |
} |
720 |
} |
725 |
} |
721 |
|
726 |
|