summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2000-10-13 08:29:20 +0000
committerespie <espie@openbsd.org>2000-10-13 08:29:20 +0000
commitac3def53bdced96c45b6ebcabc97cf341bbd4914 (patch)
tree3f6505af6956b4f07fb45073e5a7eea6637e590e
parentClean up static constructor/destructor discovery and calling. Instead (diff)
downloadwireguard-openbsd-ac3def53bdced96c45b6ebcabc97cf341bbd4914.tar.xz
wireguard-openbsd-ac3def53bdced96c45b6ebcabc97cf341bbd4914.zip
esetenv: does a setenv and bails out if error.
-rw-r--r--usr.bin/make/error.c20
-rw-r--r--usr.bin/make/error.h3
-rw-r--r--usr.bin/make/main.c10
-rw-r--r--usr.bin/make/var.c6
4 files changed, 27 insertions, 12 deletions
diff --git a/usr.bin/make/error.c b/usr.bin/make/error.c
index 03fb423a632..e6902228938 100644
--- a/usr.bin/make/error.c
+++ b/usr.bin/make/error.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: error.c,v 1.3 2000/06/23 16:27:29 espie Exp $ */
+/* $OpenBSD: error.c,v 1.4 2000/10/13 08:29:20 espie Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -142,9 +142,23 @@ void
enomem(size)
size_t size;
{
- int myerr = errno;
+ fprintf(stderr, "make: %s (%lu)\n", strerror(errno), (u_long)size);
+ exit(2);
+}
+
+/*
+ * esetenv --
+ * change environment, die on error.
+ */
+void
+esetenv(name, value)
+ const char *name;
+ const char *value;
+{
+ if (setenv(name, value, 1) == 0)
+ return;
- fprintf(stderr, "make: %s (%lu)\n", strerror(myerr), (u_long)size);
+ fprintf(stderr, "make: setenv failed (%s)\n", strerror(errno));
exit(2);
}
diff --git a/usr.bin/make/error.h b/usr.bin/make/error.h
index 6e54c70e3fd..5872cad2efe 100644
--- a/usr.bin/make/error.h
+++ b/usr.bin/make/error.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: error.h,v 1.3 2000/09/14 13:32:06 espie Exp $ */
+/* $OpenBSD: error.h,v 1.4 2000/10/13 08:29:20 espie Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -46,6 +46,7 @@ extern char *estrdup __P((const char *));
extern void *erealloc __P((void *, size_t));
extern void *ecalloc __P((size_t, size_t));
extern int eunlink __P((const char *));
+extern void esetenv __P((const char *, const char *));
/* efree(x) works when x==NULL. STDC behavior, may need some different
* definition for cross-builds on deficient systems */
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 26a0bd8a47e..a391ad5fc0b 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.43 2000/09/14 13:46:45 espie Exp $ */
+/* $OpenBSD: main.c,v 1.44 2000/10/13 08:29:20 espie Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
@@ -105,7 +105,7 @@ static char copyright[] =
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: main.c,v 1.43 2000/09/14 13:46:45 espie Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.44 2000/10/13 08:29:20 espie Exp $";
#endif
#endif /* not lint */
@@ -633,7 +633,7 @@ main(argc, argv)
objdir = curdir;
}
- setenv("PWD", objdir, 1);
+ esetenv("PWD", objdir);
unsetenv("CDPATH");
Lst_Init(&create);
@@ -781,9 +781,9 @@ main(argc, argv)
/* Install all the flags into the MAKE envariable. */
if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL)) != NULL) && *p)
#ifdef POSIX
- setenv("MAKEFLAGS", p, 1);
+ esetenv("MAKEFLAGS", p);
#else
- setenv("MAKE", p, 1);
+ esetenv("MAKE", p);
#endif
/*
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 894da926ea7..2d222cf09b6 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.48 2000/09/14 13:32:08 espie Exp $ */
+/* $OpenBSD: var.c,v 1.49 2000/10/13 08:29:21 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
@@ -126,7 +126,7 @@
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: var.c,v 1.48 2000/09/14 13:32:08 espie Exp $";
+static char rcsid[] = "$OpenBSD: var.c,v 1.49 2000/10/13 08:29:21 espie Exp $";
#endif
#endif /* not lint */
@@ -640,7 +640,7 @@ Var_Set(name, val, ctxt)
* actually empty at this point).
*/
if (ctxt == VAR_CMD) {
- setenv(name, val, 1);
+ esetenv(name, val);
(void)VarAdd(name, val, VAR_ENV);
}
}