summaryrefslogtreecommitdiff
path: root/djgpp/unsetenv.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-12-24 07:38:37 +0000
committer <>2015-02-02 12:02:29 +0000
commit482840e61f86ca321838a91e902c41d40c098bbb (patch)
tree01ea2e242fd2792d19fe192476601587901db794 /djgpp/unsetenv.c
downloadgettext-tarball-482840e61f86ca321838a91e902c41d40c098bbb.tar.gz
Imported from /home/lorry/working-area/delta_gettext-tarball/gettext-0.19.4.tar.xz.gettext-0.19.4
Diffstat (limited to 'djgpp/unsetenv.c')
-rw-r--r--djgpp/unsetenv.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/djgpp/unsetenv.c b/djgpp/unsetenv.c
new file mode 100644
index 0000000..f00c5d0
--- /dev/null
+++ b/djgpp/unsetenv.c
@@ -0,0 +1,41 @@
+/*
+ libc of DJGPP 2.03 does not offer function unsetenv,
+ so this version from DJGPP 2.04 CVS tree is supplied.
+ This file will become superflous and will be removed
+ from the distribution as soon as DJGPP 2.04 has been
+ released.
+*/
+
+/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
+
+#include <libc/stubs.h>
+#include <libc/unconst.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern char **environ;
+
+int
+unsetenv(const char *name)
+{
+ /* No environment == success */
+ if (environ == 0)
+ return 0;
+
+ /* Check for the failure conditions */
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Let putenv() do the work
+ * Note that we can just pass name directly as our putenv() treats
+ * this the same as passing 'name='. */
+ /* The cast is needed because POSIX specifies putenv() to take a non-const
+ * parameter. Our putenv is well-behaved, so this is OK. */
+ putenv (unconst (name, char*));
+
+ return 0;
+}