DRAFT lib: Add putenv.
* lib/posix/putenv.c: New file. * build-aux/configure-lib.sh (libc_gnu_SOURCES): Add it. * include/stdlib.h (putenv): Add prototype.
This commit is contained in:
parent
14d0eecc31
commit
e87d78afa8
|
@ -331,6 +331,7 @@ lib/posix/alarm.c
|
|||
lib/posix/execl.c
|
||||
lib/posix/execlp.c
|
||||
lib/posix/mktemp.c
|
||||
lib/posix/putenv.c
|
||||
lib/posix/sbrk.c
|
||||
lib/posix/sleep.c
|
||||
lib/posix/unsetenv.c
|
||||
|
|
|
@ -45,6 +45,7 @@ void _exit (int status);
|
|||
void exit (int status);
|
||||
void free (void *ptr);
|
||||
char *getenv (char const *s);
|
||||
int putenv (char *s);
|
||||
int setenv (char const *s, char const *v, int overwrite_p);
|
||||
int unsetenv (char const *name);
|
||||
void *malloc (size_t);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
putenv (char *s)
|
||||
{
|
||||
char *value = strchr (s, '=');
|
||||
if (!value)
|
||||
return unsetenv (s);
|
||||
|
||||
*value++ = '0';
|
||||
value = "";
|
||||
return setenv (s, value, 1);
|
||||
}
|
Loading…
Reference in New Issue