diff options
author | harti <harti@FreeBSD.org> | 2005-02-16 12:39:32 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-02-16 12:39:32 +0000 |
commit | dfb7ee3811a6dd2a85a6a0896e88835f32be0a89 (patch) | |
tree | 7fab58f76b2e79bffc1113c32bf6b9034ef12525 /usr.bin | |
parent | e7b22678a48aa80b1d81df24bd9601eb89fe2d21 (diff) | |
download | FreeBSD-src-dfb7ee3811a6dd2a85a6a0896e88835f32be0a89.zip FreeBSD-src-dfb7ee3811a6dd2a85a6a0896e88835f32be0a89.tar.gz |
Better version of the patch in 1.117: bring a variable into local scope
to prepare for function splitting and slightly reorganise the code
in anticipation of Var_Subst returning a Buffer.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (with slight changes)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/main.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index f53e1f2..c481907 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -805,28 +805,33 @@ main(int argc, char **argv) * <directory>:<directory>:<directory>... */ if (Var_Exists("VPATH", VAR_CMD)) { - char *vpath, savec; /* * GCC stores string constants in read-only memory, but * Var_Subst will want to write this thing, so store it * in an array */ static char VPATH[] = "${VPATH}"; + char *vpath; + char *start; + char *ptr; + char savec; vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); - path = vpath; + start = vpath; do { /* skip to end of directory */ - for (cp = path; *cp != ':' && *cp != '\0'; cp++) - continue; + for (ptr = start; *ptr != ':' && *ptr != '\0'; ptr++) + ; + /* Save terminator character so know when to stop */ - savec = *cp; - *cp = '\0'; + savec = *ptr; + *ptr = '\0'; + /* Add directory to search path */ - Dir_AddDir(&dirSearchPath, path); - *cp = savec; - path = cp + 1; - } while (savec == ':'); + Dir_AddDir(&dirSearchPath, start); + + start = ptr + 1; + } while (savec != '\0'); free(vpath); } |