Module Name:    src
Committed By:   rillig
Date:           Sat Aug  1 08:55:28 UTC 2020

Modified Files:
        src/usr.bin/make: main.c

Log Message:
make(1): merge duplicate code for concatenating strings


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 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.286 src/usr.bin/make/main.c:1.287
--- src/usr.bin/make/main.c:1.286	Sat Aug  1 08:49:47 2020
+++ src/usr.bin/make/main.c	Sat Aug  1 08:55:28 2020
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #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 @@ Main_ParseArgLine(const char *line)
 	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 @@ Main_ParseArgLine(const char *line)
 	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);

Reply via email to