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); }