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): merge duplicate code for concatenating...



details:   https://anonhg.NetBSD.org/src/rev/b7aa3877814c
branches:  trunk
changeset: 974468:b7aa3877814c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 01 08:55:28 2020 +0000

description:
make(1): merge duplicate code for concatenating strings

diffstat:

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

diffs (48 lines):

diff -r 21497d0ace54 -r b7aa3877814c usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Aug 01 08:49:47 2020 +0000
+++ b/usr.bin/make/main.c       Sat Aug 01 08:55:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.286 2020/08/01 08:49:47 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.287 2020/08/01 08:55:28 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -694,9 +694,8 @@
        char **argv;                    /* Manufactured argument vector */
        int argc;                       /* Number of arguments in argv */
        char *args;                     /* Space used by the args */
-       char *buf, *p1;
+       char *p1;
        char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1);
-       size_t len;
 
        if (line == NULL)
                return;
@@ -705,8 +704,7 @@
        if (!*line)
                return;
 
-       buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2);
-       (void)snprintf(buf, len, "%s %s", argv0, line);
+       char *buf = str_concat(argv0, line, STR_ADDSPACE);
        free(p1);
 
        argv = brk_string(buf, &argc, TRUE, &args);



Home | Main Index | Thread Index | Old Index