Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: merge local variables holding the path to...



details:   https://anonhg.NetBSD.org/src/rev/909db87b5539
branches:  trunk
changeset: 1029220:909db87b5539
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 27 23:06:19 2021 +0000

description:
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.

diffstat:

 usr.bin/make/main.c |  12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diffs (47 lines):

diff -r c59ae94b5d6f -r 909db87b5539 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Dec 27 23:04:19 2021 +0000
+++ b/usr.bin/make/main.c       Mon Dec 27 23:06:19 2021 +0000
@@ -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 @@
 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 @@
        }
 
        /* 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;
 }



Home | Main Index | Thread Index | Old Index