Only need to getcwd() once
This commit is contained in:
parent
206ef381bf
commit
c37859c219
@ -763,15 +763,15 @@ Boolean
|
||||
meta_oodate(GNode *gn, Boolean oodate)
|
||||
{
|
||||
static char *tmpdir = NULL;
|
||||
static char cwd[MAXPATHLEN];
|
||||
char ldir_vname[64];
|
||||
char cwd[MAXPATHLEN];
|
||||
char latestdir[MAXPATHLEN];
|
||||
char fname[MAXPATHLEN];
|
||||
char fname1[MAXPATHLEN];
|
||||
char fname2[MAXPATHLEN];
|
||||
char *p;
|
||||
char *cp;
|
||||
size_t cwdlen;
|
||||
static size_t cwdlen = 0;
|
||||
static size_t tmplen = 0;
|
||||
FILE *fp;
|
||||
Boolean ignoreOODATE = FALSE;
|
||||
@ -787,9 +787,6 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
*/
|
||||
Make_DoAllVar(gn);
|
||||
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
||||
err(1, "Could not get current working directory");
|
||||
|
||||
meta_name(gn, fname, sizeof(fname), NULL, NULL);
|
||||
|
||||
#ifdef DEBUG_META_MODE
|
||||
@ -813,6 +810,12 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
buf = bmake_malloc(bufsz);
|
||||
}
|
||||
|
||||
if (!cwdlen) {
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
||||
err(1, "Could not get current working directory");
|
||||
cwdlen = strlen(cwd);
|
||||
}
|
||||
|
||||
if (!tmpdir) {
|
||||
tmpdir = getTmpdir();
|
||||
tmplen = strlen(tmpdir);
|
||||
@ -821,8 +824,6 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
/* we want to track all the .meta we read */
|
||||
Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL);
|
||||
|
||||
cwdlen = strlen(cwd);
|
||||
|
||||
ln = Lst_First(gn->commands);
|
||||
while (!oodate && (x = fgetLine(&buf, &bufsz, 0, fp)) > 0) {
|
||||
lineno++;
|
||||
@ -1091,7 +1092,7 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
ln = Lst_Succ(ln);
|
||||
}
|
||||
} else if (strcmp(buf, "CWD") == 0) {
|
||||
if (strcmp(p, cwd) != 0) {
|
||||
if (strcmp(p, cwd) != 0) {
|
||||
if (DEBUG(META))
|
||||
fprintf(debug_file, "%s: %d: the current working directory has changed from '%s' to '%s'\n", fname, lineno, p, curdir);
|
||||
oodate = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user