From 61f9d0a356f84837e3e3af27831ec7d8070f15b7 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 27 Jan 2001 07:07:07 +0000 Subject: Update. * conform/data/stdlib.h-data: Account for XPG6 changes. * stdlib/stdlib.h (__random): Change return value type to long. (posix_memalign): Cleanup parameter names. (setenv, unsetenv): Make available for __USE_XOPEN2K. Change return type of unsetenv to int. (qecvt, qgcvt, qfcvt): Declare only if __USE_MISC. * sysdeps/generic/setenv.c (unsetenv): Change return type to int. Return -1 and set errno if parameter is invalid. * stdlib/random.c (__random): Change return value type to long. --- sysdeps/generic/setenv.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sysdeps/generic') diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c index b8d234929f..6f871a65c7 100644 --- a/sysdeps/generic/setenv.c +++ b/sysdeps/generic/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1992,95,96,97,98,99,2000,2001 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 @@ -263,13 +263,21 @@ setenv (name, value, replace) return __add_to_environ (name, value, NULL, replace); } -void +int unsetenv (name) const char *name; { - const size_t len = strlen (name); + const size_t len; char **ep; + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + len = strlen (name); + LOCK; ep = __environ; @@ -288,6 +296,8 @@ unsetenv (name) ++ep; UNLOCK; + + return 0; } /* The `clearenv' was planned to be added to POSIX.1 but probably -- cgit v1.2.3