From 02fec4701cee79f875c1d02b8b4aee09380dbcb8 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 4 Jan 2001 20:04:45 +0000 Subject: integrate dietlibc/stdio per default for cdrom and disk only installs --- mdk-stage1/dietlibc/lib/putenv.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 mdk-stage1/dietlibc/lib/putenv.c (limited to 'mdk-stage1/dietlibc/lib/putenv.c') diff --git a/mdk-stage1/dietlibc/lib/putenv.c b/mdk-stage1/dietlibc/lib/putenv.c new file mode 100644 index 000000000..274b16b0e --- /dev/null +++ b/mdk-stage1/dietlibc/lib/putenv.c @@ -0,0 +1,37 @@ +#include +#include + +int putenv(const char *string) { + int len; + int envc; + char *tmp; + const char **ep; + char **newenv; + static char **origenv=0; + if (!origenv) origenv=environ; + if (!(tmp=strchr(string,'='))) + len=strlen(string); + else + len=tmp-string+1; + for (envc=0, ep=(const char**)environ; *ep; ++ep) { + if (!memcmp(string,*ep,len)) { /* found */ + if (!tmp) { + for (; ep[1]; ++ep) ep[0]=ep[1]; + ep[0]=0; + return 0; + } + *ep=string; + return 0; + } + ++envc; + } + if (tmp) { + newenv=(char**)malloc((envc+2)*sizeof(char*)); + if (!newenv) return -1; + newenv[0]=(char*)string; + memcpy(newenv+1,environ,(envc+1)*sizeof(char*)); + if (environ!=origenv) free(environ); + environ=newenv; + } + return 0; +} -- cgit v1.2.1