summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-08-29 11:13:43 +0000
committerrillig <rillig@NetBSD.org>2020-08-29 11:13:43 +0000
commita98e19a0e5e8b45f1d19f4e8440c0b3edf2e9cea (patch)
treeb8500f86c5140e9f3bbc757120825c8e2027728d /usr.bin/make/parse.c
parent41ff265441a363e490edde743e754b4d42e5041c (diff)
make(1): merge duplicate code for bmake_strldup
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 8db626917c9..48fc8426532 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.270 2020/08/29 11:13:43 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.270 2020/08/29 11:13:43 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.270 2020/08/29 11:13:43 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -2395,18 +2395,14 @@ ParseSetParseFile(const char *filename)
{
char *slash, *dirname;
const char *pd, *pf;
- int len;
slash = strrchr(filename, '/');
if (slash == NULL) {
Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL);
Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL);
- dirname= NULL;
+ dirname = NULL;
} else {
- len = slash - filename;
- dirname = bmake_malloc(len + 1);
- memcpy(dirname, filename, len);
- dirname[len] = '\0';
+ dirname = bmake_strldup(filename, (size_t)(slash - filename));
Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL);
Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL);
}