1
/* -*- buffer-read-only: t -*- vi: set ro: */
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3
/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2010 Free Software
6
NOTE: The canonical source of this file is maintained with the GNU C
7
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
9
This program is free software: you can redistribute it and/or modify it
10
under the terms of the GNU General Public License as published by the
11
Free Software Foundation; either version 3 of the License, or any
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program. If not, see <http://www.gnu.org/licenses/>. */
29
/* Include errno.h *after* sys/types.h to work around header problems
33
# define __set_errno(ev) ((errno) = (ev))
40
# define environ __environ
42
extern char **environ;
46
/* This lock protects against simultaneous modifications of `environ'. */
47
# include <bits/libc-lock.h>
48
__libc_lock_define_initialized (static, envlock)
49
# define LOCK __libc_lock_lock (envlock)
50
# define UNLOCK __libc_lock_unlock (envlock)
57
_unsetenv (const char *name)
62
if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
74
if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
76
/* Found it. Remove this pointer by moving later ones back. */
82
/* Continue the loop in case NAME appears again. */
93
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
94
If STRING contains no `=', then remove STRING from the environment. */
98
const char *const name_end = strchr (string, '=');
102
if (name_end == NULL)
104
/* Remove the variable from the environment. */
105
return _unsetenv (string);
109
for (ep = environ; *ep != NULL; ++ep)
110
if (!strncmp (*ep, string, name_end - string) &&
111
(*ep)[name_end - string] == '=')
118
static char **last_environ = NULL;
119
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
120
if (new_environ == NULL)
122
(void) memcpy ((void *) new_environ, (void *) environ,
123
size * sizeof (char *));
124
new_environ[size] = (char *) string;
125
new_environ[size + 1] = NULL;
127
last_environ = new_environ;
128
environ = new_environ;