Module Name: src Committed By: rillig Date: Mon Dec 27 23:06:19 UTC 2021
Modified Files: src/usr.bin/make: main.c Log Message: make: merge local variables holding the path to the object directory This is a similar pattern as in the other situations where a string is fed through Var_Subst. In this case though, the unexpanded string may need to be freed, therefore the FStr_Done that is not needed in the other places. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.555 -r1.556 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.555 src/usr.bin/make/main.c:1.556 --- src/usr.bin/make/main.c:1.555 Mon Dec 27 22:57:26 2021 +++ src/usr.bin/make/main.c Mon Dec 27 23:06:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.555 2021/12/27 22:57:26 rillig Exp $ */ +/* $NetBSD: main.c,v 1.556 2021/12/27 23:06:19 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.555 2021/12/27 22:57:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.556 2021/12/27 23:06:19 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -749,7 +749,6 @@ static bool SetVarObjdir(bool writable, const char *var, const char *suffix) { FStr path = Var_Value(SCOPE_CMDLINE, var); - FStr xpath; if (path.str == NULL || path.str[0] == '\0') { FStr_Done(&path); @@ -757,17 +756,16 @@ SetVarObjdir(bool writable, const char * } /* expand variable substitutions */ - xpath = FStr_InitRefer(path.str); if (strchr(path.str, '$') != 0) { char *expanded; (void)Var_Subst(path.str, SCOPE_GLOBAL, VARE_WANTRES, &expanded); /* TODO: handle errors */ - xpath = FStr_InitOwn(expanded); + FStr_Done(&path); + path = FStr_InitOwn(expanded); } - (void)Main_SetObjdir(writable, "%s%s", xpath.str, suffix); + (void)Main_SetObjdir(writable, "%s%s", path.str, suffix); - FStr_Done(&xpath); FStr_Done(&path); return true; }