From 157e401636ea82e0afdfd42ab7f8d324e1423381 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Fri, 11 Feb 2005 17:03:18 +0000 Subject: [PATCH] Stylistic fixes: push variable into a local context (this part is going to be split out into a function soon). Also there is no need to write back the colon that we have NUL-ed - the string is going to be freed anyway. Submitted by: Max Okumoto --- usr.bin/make/main.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index f53e1f2ff70f..398cd4318315 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -805,28 +805,30 @@ main(int argc, char **argv) * ::... */ 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 savec; + char *ptr; vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); - path = vpath; do { /* skip to end of directory */ - for (cp = path; *cp != ':' && *cp != '\0'; cp++) - continue; + for (ptr = vpath; *ptr != ':' && *ptr != '\0'; cp++) + ; + /* 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, vpath); + vpath = ptr + 1; + } while (savec != '\0'); free(vpath); }