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(1): improve variable names in Arch_ParseAr...



details:   https://anonhg.NetBSD.org/src/rev/9a130ccfb81c
branches:  trunk
changeset: 946605:9a130ccfb81c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 04 14:51:46 2020 +0000

description:
make(1): improve variable names in Arch_ParseArchive

The variable buf used to be a Buffer, now it is a simple string pointer.

diffstat:

 usr.bin/make/arch.c |  26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diffs (68 lines):

diff -r a8cdd0d66f5c -r 9a130ccfb81c usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Dec 04 14:39:56 2020 +0000
+++ b/usr.bin/make/arch.c       Fri Dec 04 14:51:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.183 2020/12/04 14:39:56 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.184 2020/12/04 14:51:46 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.183 2020/12/04 14:39:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.184 2020/12/04 14:51:46 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -304,9 +304,9 @@
                 * thing would be taken care of later.
                 */
                if (doSubst) {
-                       char *buf;
-                       char *sacrifice;
-                       char *oldMemName = memName;
+                       char *fullName;
+                       char *p;
+                       char *unexpandedMemName = memName;
 
                        (void)Var_Subst(memName, ctxt,
                                        VARE_WANTRES | VARE_UNDEFERR,
@@ -317,27 +317,29 @@
                         * Now form an archive spec and recurse to deal with
                         * nested variables and multi-word variable values.
                         */
-                       sacrifice = str_concat4(libName, "(", memName, ")");
-                       buf = sacrifice;
+                       fullName = str_concat4(libName, "(", memName, ")");
+                       p = fullName;
 
                        if (strchr(memName, '$') != NULL &&
-                           strcmp(memName, oldMemName) == 0) {
+                           strcmp(memName, unexpandedMemName) == 0) {
                                /*
                                 * Must contain dynamic sources, so we can't
                                 * deal with it now. Just create an ARCHV node
                                 * for the thing and let SuffExpandChildren
                                 * handle it.
                                 */
-                               gn = Targ_GetNode(buf);
+                               gn = Targ_GetNode(fullName);
                                gn->type |= OP_ARCHV;
                                Lst_Append(gns, gn);
 
-                       } else if (!Arch_ParseArchive(&sacrifice, gns, ctxt)) {
+                       } else if (!Arch_ParseArchive(&p, gns, ctxt)) {
                                /* Error in nested call. */
-                               free(buf);
+                               free(fullName);
+                               /* XXX: does unexpandedMemName leak? */
                                return FALSE;
                        }
-                       free(buf);
+                       free(fullName);
+                       /* XXX: does unexpandedMemName leak? */
 
                } else if (Dir_HasWildcards(memName)) {
                        StringList members = LST_INIT;



Home | Main Index | Thread Index | Old Index