900 |
const char *dbpath; |
const char *dbpath; |
901 |
int db; |
int db; |
902 |
{ |
{ |
903 |
|
char rootdir[MAXPATHLEN+1]; |
904 |
char buf[MAXPATHLEN+1], *path; |
char buf[MAXPATHLEN+1], *path; |
905 |
FILE *op; |
FILE *op; |
906 |
int count; |
int count; |
907 |
STRBUF *comline = strbuf_open(0); |
STRBUF *comline = strbuf_open(0); |
908 |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
909 |
int path_list_max; |
int path_list_max; |
|
size_t rootlen = strlen(root); |
|
910 |
|
|
911 |
|
snprintf(rootdir, sizeof(rootdir), "%s/", root); |
912 |
/* |
/* |
913 |
* teach parser where is dbpath. |
* teach parser where is dbpath. |
914 |
*/ |
*/ |
950 |
die("realpath(%s, buf) failed. (errno=%d).", av, errno); |
die("realpath(%s, buf) failed. (errno=%d).", av, errno); |
951 |
if (!isabspath(path)) |
if (!isabspath(path)) |
952 |
die("realpath(3) is not compatible with BSD version."); |
die("realpath(3) is not compatible with BSD version."); |
953 |
if (strncmp(path, root, rootlen) || path[rootlen] != '/') { |
/* |
954 |
|
* Remove the root part of path and insert './'. |
955 |
|
* rootdir /a/b/ |
956 |
|
* path /a/b/c/d.c -> c/d.c -> ./c/d.c |
957 |
|
*/ |
958 |
|
path = locatestring(path, rootdir, MATCH_AT_FIRST); |
959 |
|
if (path == NULL) { |
960 |
if (!qflag) |
if (!qflag) |
961 |
fprintf(stderr, "'%s' is out of source tree.\n", path); |
fprintf(stderr, "'%s' is out of source tree.\n", path); |
962 |
continue; |
continue; |
963 |
} |
} |
964 |
path += rootlen - 1; |
path -= 2; |
965 |
*path = '.'; |
*path = '.'; |
966 |
if (!gpath_path2fid(path)) { |
if (!gpath_path2fid(path)) { |
967 |
if (!qflag) |
if (!qflag) |