763 |
grep(const char *dbpath, const char *pattern) |
grep(const char *dbpath, const char *pattern) |
764 |
{ |
{ |
765 |
FILE *op, *fp; |
FILE *op, *fp; |
766 |
|
GFIND *gp; |
767 |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
768 |
const char *path; |
const char *path; |
769 |
char edit[IDENTLEN+1]; |
char edit[IDENTLEN+1]; |
790 |
* The older version (4.8.7 or former) of GPATH doesn't have files |
* The older version (4.8.7 or former) of GPATH doesn't have files |
791 |
* other than source file. The oflag requires new version of GPATH. |
* other than source file. The oflag requires new version of GPATH. |
792 |
*/ |
*/ |
793 |
if (gfind_open(dbpath, localprefix, oflag) < 2 && oflag) |
gp = gfind_open(dbpath, localprefix, oflag); |
794 |
|
if (gp->version < 2 && oflag) |
795 |
die("GPATH is old format. Please remake it by invoking gtags(1)."); |
die("GPATH is old format. Please remake it by invoking gtags(1)."); |
796 |
while ((path = gfind_read()) != NULL) { |
while ((path = gfind_read(gp)) != NULL) { |
797 |
if (!(fp = fopen(path, "r"))) |
if (!(fp = fopen(path, "r"))) |
798 |
die("cannot open file '%s'.", path); |
die("cannot open file '%s'.", path); |
799 |
linenum = 0; |
linenum = 0; |
816 |
} |
} |
817 |
fclose(fp); |
fclose(fp); |
818 |
} |
} |
819 |
gfind_close(); |
gfind_close(gp); |
820 |
closefilter(op); |
closefilter(op); |
821 |
strbuf_close(ib); |
strbuf_close(ib); |
822 |
regfree(&preg); |
regfree(&preg); |
838 |
void |
void |
839 |
pathlist(const char *dbpath, const char *av) |
pathlist(const char *dbpath, const char *av) |
840 |
{ |
{ |
841 |
|
GFIND *gp; |
842 |
FILE *op; |
FILE *op; |
843 |
const char *path, *p; |
const char *path, *p; |
844 |
regex_t preg; |
regex_t preg; |
866 |
* The older version (4.8.7 or former) of GPATH doesn't have files |
* The older version (4.8.7 or former) of GPATH doesn't have files |
867 |
* other than source file. The oflag requires new version of GPATH. |
* other than source file. The oflag requires new version of GPATH. |
868 |
*/ |
*/ |
869 |
if (gfind_open(dbpath, localprefix, oflag) < 2 && oflag) |
gp = gfind_open(dbpath, localprefix, oflag); |
870 |
|
if (gp->version < 2 && oflag) |
871 |
die("GPATH is old format. Please remake it by invoking gtags(1)."); |
die("GPATH is old format. Please remake it by invoking gtags(1)."); |
872 |
while ((path = gfind_read()) != NULL) { |
while ((path = gfind_read(gp)) != NULL) { |
873 |
/* |
/* |
874 |
* skip localprefix because end-user doesn't see it. |
* skip localprefix because end-user doesn't see it. |
875 |
*/ |
*/ |
886 |
} |
} |
887 |
count++; |
count++; |
888 |
} |
} |
889 |
gfind_close(); |
gfind_close(gp); |
890 |
closefilter(op); |
closefilter(op); |
891 |
if (av) |
if (av) |
892 |
regfree(&preg); |
regfree(&preg); |