Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Only need to getcwd() once
details: https://anonhg.NetBSD.org/src/rev/e95ed6feec6d
branches: trunk
changeset: 762965:e95ed6feec6d
user: sjg <sjg%NetBSD.org@localhost>
date: Sun Mar 06 17:41:11 2011 +0000
description:
Only need to getcwd() once
diffstat:
usr.bin/make/meta.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (62 lines):
diff -r 9e8266eecf73 -r e95ed6feec6d usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Sun Mar 06 17:39:34 2011 +0000
+++ b/usr.bin/make/meta.c Sun Mar 06 17:41:11 2011 +0000
@@ -763,15 +763,15 @@
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 @@
*/
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 @@
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 @@
/* 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 @@
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;
Home |
Main Index |
Thread Index |
Old Index