659 |
char edit[IDENTLEN+1]; |
char edit[IDENTLEN+1]; |
660 |
const char *path, *lno, *lid; |
const char *path, *lno, *lid; |
661 |
int linenum, count; |
int linenum, count; |
662 |
char *p, *line; |
char *p, *grep; |
663 |
|
|
664 |
lid = usable("lid"); |
lid = usable("lid"); |
665 |
if (!lid) |
if (!lid) |
670 |
ffformat(edit, sizeof(edit), pattern); |
ffformat(edit, sizeof(edit), pattern); |
671 |
/* |
/* |
672 |
* make lid command line. |
* make lid command line. |
673 |
|
* Invoke lid with the --result=grep option to generate grep format. |
674 |
*/ |
*/ |
675 |
strbuf_puts(ib, lid); |
strbuf_puts(ib, lid); |
676 |
strbuf_puts(ib, " --separator=newline"); |
strbuf_puts(ib, " --separator=newline"); |
693 |
if (!(op = openfilter())) |
if (!(op = openfilter())) |
694 |
die("cannot open output filter."); |
die("cannot open output filter."); |
695 |
count = 0; |
count = 0; |
696 |
while ((line = strbuf_fgets(ib, ip, STRBUF_NOCRLF)) != NULL) { |
while ((grep = strbuf_fgets(ib, ip, STRBUF_NOCRLF)) != NULL) { |
697 |
p = line; |
p = grep; |
698 |
/* extract filename */ |
/* extract filename */ |
699 |
path = p; |
path = p; |
700 |
while (*p && *p != ':') |
while (*p && *p != ':') |
701 |
p++; |
p++; |
702 |
if ((xflag || tflag) && !*p) |
if ((xflag || tflag) && !*p) |
703 |
die("invalid lid(id-utils) output format. '%s'", line); |
die("invalid lid(id-utils) output format. '%s'", grep); |
704 |
*p++ = 0; |
*p++ = 0; |
705 |
if (lflag) { |
if (lflag) { |
706 |
if (!locatestring(path, localprefix + 2, MATCH_AT_FIRST)) |
if (!locatestring(path, localprefix + 2, MATCH_AT_FIRST)) |
718 |
while (*p && isdigit(*p)) |
while (*p && isdigit(*p)) |
719 |
p++; |
p++; |
720 |
if (*p != ':') |
if (*p != ':') |
721 |
die("invalid lid(id-utils) output format. '%s'", line); |
die("invalid lid(id-utils) output format. '%s'", grep); |
722 |
*p++ = 0; |
*p++ = 0; |
723 |
linenum = atoi(lno); |
linenum = atoi(lno); |
724 |
if (linenum <= 0) |
if (linenum <= 0) |
725 |
die("invalid lid(id-utils) output format. '%s'", line); |
die("invalid lid(id-utils) output format. '%s'", grep); |
726 |
/* |
/* |
727 |
* print out. |
* print out. |
728 |
*/ |
*/ |