summaryrefslogtreecommitdiff
path: root/usr.bin/make/main.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>1998-03-26 19:20:36 +0000
committerchristos <christos@NetBSD.org>1998-03-26 19:20:36 +0000
commitf46f2d693ea899371cf704323e0db1dbff3765c7 (patch)
treec5ccdf0415543ce8bad914b7d0c8182f8b26fa03 /usr.bin/make/main.c
parent531db9e0d34f755c147d58f79e07983fea5e522d (diff)
PR/5210: Hauke Fath: make core dumps with .SHELL
Unfortunately this revealed a deeper problem with the brk_string code. To fix it: - remove sharing of the buffer between brk_string invocations - change the semantics of brk_string so that the argument array starts with 0, and return the buffer where the strings are stored
Diffstat (limited to 'usr.bin/make/main.c')
-rw-r--r--usr.bin/make/main.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 636356a2a2b..5a188b2a437 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.39 1997/11/08 09:33:16 lukem Exp $ */
+/* $NetBSD: main.c,v 1.40 1998/03/26 19:20:37 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,7 +39,7 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.39 1997/11/08 09:33:16 lukem Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.40 1998/03/26 19:20:37 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.39 1997/11/08 09:33:16 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.40 1998/03/26 19:20:37 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -377,6 +377,9 @@ Main_ParseArgLine(line)
{
char **argv; /* Manufactured argument vector */
int argc; /* Number of arguments in argv */
+ char *args; /* Space used by the args */
+ char *buf, *p1;
+ char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1);
if (line == NULL)
return;
@@ -385,8 +388,16 @@ Main_ParseArgLine(line)
if (!*line)
return;
- argv = brk_string(line, &argc, TRUE);
+ buf = emalloc(strlen(line) + strlen(argv0) + 2);
+ (void)sprintf(buf, "%s %s", argv0, line);
+ if (p1)
+ free(p1);
+
+ argv = brk_string(line, &argc, TRUE, &args);
MainParseArgs(argc, argv);
+
+ free(args);
+ free(argv);
}
char *
@@ -599,7 +610,6 @@ main(argc, argv)
* directories */
Var_Init(); /* As well as the lists of variables for
* parsing arguments */
- str_init();
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
@@ -820,10 +830,10 @@ main(argc, argv)
Suff_End();
Targ_End();
Arch_End();
- str_end();
Var_End();
Parse_End();
Dir_End();
+ Job_End();
if (queryFlag && outOfDate)
return(1);