summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2008-12-10 16:39:54 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2008-12-10 16:39:54 +0000
commit0f1e140e796f55cf5f07d39707f3e88d335f4ff1 (patch)
treee44d49e4cb8da17389d4ffa57e784f7ee91d3381 /libc/stdlib
parent8acd6170c246b159d26f05d85fa256746391d3d7 (diff)
Merge changes between r7357 and r7510 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@7511 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/Makefile3
-rw-r--r--libc/stdlib/setenv.c29
-rw-r--r--libc/stdlib/tst-unsetenv1.c12
3 files changed, 29 insertions, 15 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile
index 9491229f4..3986ac4a6 100644
--- a/libc/stdlib/Makefile
+++ b/libc/stdlib/Makefile
@@ -77,7 +77,8 @@ tests := tst-strtol tst-strtod testrand testsort testdiv \
tst-limits tst-rand48 bug-strtod tst-setcontext \
test-a64l tst-qsort tst-system bug-strtod2 \
tst-atof1 tst-atof2 tst-strtod2 tst-rand48-2 \
- tst-makecontext tst-qsort2 tst-makecontext2 tst-strtod6
+ tst-makecontext tst-qsort2 tst-makecontext2 tst-strtod6 \
+ tst-unsetenv1
tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+= tst-strtod3 tst-strtod4 tst-strtod5 testmb2
tests-$(OPTION_POSIX_C_LANG_WIDE_CHAR) \
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 48aaecffe..fe591b7db 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1995-2001,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-2001,2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -292,19 +292,20 @@ unsetenv (name)
LOCK;
ep = __environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
+ if (ep != NULL)
+ while (*ep != NULL)
+ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+ {
+ /* Found it. Remove this pointer by moving later ones back. */
+ char **dp = ep;
+
+ do
+ dp[0] = dp[1];
+ while (*dp++);
+ /* Continue the loop in case NAME appears again. */
+ }
+ else
+ ++ep;
UNLOCK;
diff --git a/libc/stdlib/tst-unsetenv1.c b/libc/stdlib/tst-unsetenv1.c
new file mode 100644
index 000000000..a2a760d24
--- /dev/null
+++ b/libc/stdlib/tst-unsetenv1.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ clearenv ();
+ unsetenv ("FOO");
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"