summaryrefslogtreecommitdiff
path: root/usr.bin/make/main.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-12-06 22:20:35 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-12-06 22:20:35 +0000
commitf5c2e61a2aec3614bbeed31c49ac9979f4e483fc (patch)
tree78a66f20d652e625d61f89260e2a06d5d20b3487 /usr.bin/make/main.c
parent327f7931464da5c5165795ac810b88847228f691 (diff)
Fix handling of
VAR!= specifically, properly distinguish between bad commands and empty results.
Diffstat (limited to 'usr.bin/make/main.c')
-rw-r--r--usr.bin/make/main.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index a030406a5c0..109d59e5f15 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.16 1999/11/10 14:11:49 espie Exp $ */
+/* $OpenBSD: main.c,v 1.17 1999/12/06 22:20:34 espie Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
@@ -49,7 +49,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.16 1999/11/10 14:11:49 espie Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.17 1999/12/06 22:20:34 espie Exp $";
#endif
#endif /* not lint */
@@ -933,7 +933,8 @@ Cmd_Exec(cmd, err)
int status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
- int cc;
+ ssize_t cc;
+ int length;
*err = NULL;
@@ -1007,10 +1008,10 @@ Cmd_Exec(cmd, err)
while(((pid = wait(&status)) != cpid) && (pid >= 0))
continue;
- res = (char *)Buf_GetAll (buf, &cc);
+ res = (char *)Buf_GetAll (buf, &length);
Buf_Destroy (buf, FALSE);
- if (cc == 0)
+ if (cc == -1)
*err = "Couldn't read shell's output for \"%s\"";
if (status)
@@ -1020,8 +1021,8 @@ Cmd_Exec(cmd, err)
* Null-terminate the result, convert newlines to spaces and
* install it in the variable.
*/
- res[cc] = '\0';
- cp = &res[cc] - 1;
+ res[length] = '\0';
+ cp = res + length - 1;
if (*cp == '\n') {
/*