79 |
static char **listarray; /* list for skipping full path */ |
static char **listarray; /* list for skipping full path */ |
80 |
static FILE *ip; |
static FILE *ip; |
81 |
static FILE *temp; |
static FILE *temp; |
82 |
static char root[MAXPATHLEN + 1]; |
static char rootdir[MAXPATHLEN+1]; |
|
static size_t rootlen; |
|
83 |
static int opened; |
static int opened; |
84 |
#define FIND_OPEN 1 |
#define FIND_OPEN 1 |
85 |
#define FILELIST_OPEN 2 |
#define FILELIST_OPEN 2 |
433 |
* |
* |
434 |
* i) filename file including list of file names. |
* i) filename file including list of file names. |
435 |
* When "-" is specified, read from standard input. |
* When "-" is specified, read from standard input. |
436 |
* i) rootdir root directory of source tree |
* i) root root directory of source tree |
437 |
*/ |
*/ |
438 |
void |
void |
439 |
find_open_filelist(filename, rootdir) |
find_open_filelist(filename, root) |
440 |
const char *filename; |
const char *filename; |
441 |
const char *rootdir; |
const char *root; |
442 |
{ |
{ |
443 |
assert(opened == 0); |
assert(opened == 0); |
444 |
opened = FILELIST_OPEN; |
opened = FILELIST_OPEN; |
462 |
if (ip == NULL) |
if (ip == NULL) |
463 |
die("cannot open '%s'.", filename); |
die("cannot open '%s'.", filename); |
464 |
} |
} |
465 |
strlimcpy(root, rootdir, sizeof(root)); |
snprintf(rootdir, sizeof(rootdir), "%s/", root); |
|
rootlen = strlen(root); |
|
466 |
|
|
467 |
/* |
/* |
468 |
* prepare regular expressions. |
* prepare regular expressions. |
594 |
} |
} |
595 |
if (!isabspath(buf)) |
if (!isabspath(buf)) |
596 |
die("realpath(3) is not compatible with BSD version."); |
die("realpath(3) is not compatible with BSD version."); |
597 |
if (strncmp(buf, root, rootlen) || buf[rootlen] != '/') { |
/* |
598 |
|
* Remove the root part of buf and insert './'. |
599 |
|
* rootdir /a/b/ |
600 |
|
* buf /a/b/c/d.c -> c/d.c -> ./c/d.c |
601 |
|
*/ |
602 |
|
path = locatestring(buf, rootdir, MATCH_AT_FIRST); |
603 |
|
if (path == NULL) { |
604 |
if (!qflag) |
if (!qflag) |
605 |
fprintf(stderr, "'%s' is out of source tree.\n", buf); |
fprintf(stderr, "'%s' is out of source tree.\n", buf); |
606 |
continue; |
continue; |
607 |
} |
} |
608 |
path = buf + rootlen - 1; |
path -= 2; |
609 |
*path = '.'; |
*path = '.'; |
610 |
/* |
/* |
611 |
* GLOBAL cannot treat path which includes blanks. |
* GLOBAL cannot treat path which includes blanks. |