You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
56 lines
1.7 KiB
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
# |
|
# Filename: package/.../dietlibc/putenv.patch |
|
# Copyright (C) 2006 The T2 SDE Project |
|
# |
|
# More information can be found in the files COPYING and README. |
|
# |
|
# This patch file is dual-licensed. It is available under the license the |
|
# patched project is licensed under, as long as it is an OpenSource license |
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms |
|
# of the GNU General Public License as published by the Free Software |
|
# Foundation; either version 2 of the License, or (at your option) any later |
|
# version. |
|
# --- SDE-COPYRIGHT-NOTE-END --- |
|
|
|
For clearenv(). |
|
|
|
- Rene Rebe <rene@exactcode.de> |
|
|
|
--- ./lib/putenv.c 19 Feb 2006 15:38:28 -0000 1.9 |
|
+++ ./lib/putenv.c 22 Jun 2006 14:13:24 -0000 |
|
@@ -2,6 +2,8 @@ |
|
#include <string.h> |
|
#include <errno.h> |
|
|
|
+char **__origenv; /* also used by clearenv */ |
|
+ |
|
int putenv(const char *string) { |
|
size_t len; |
|
int envc; |
|
@@ -9,8 +11,7 @@ |
|
char *tmp; |
|
const char **ep; |
|
char **newenv; |
|
- static char **origenv; |
|
- if (!origenv) origenv=environ; |
|
+ if (!__origenv) __origenv=environ; |
|
if (!(tmp=strchr(string,'='))) { |
|
len=strlen(string); |
|
remove=1; |
|
@@ -29,11 +30,11 @@ |
|
++envc; |
|
} |
|
if (tmp) { |
|
- newenv = (char**) realloc(environ==origenv?0:environ, |
|
+ newenv = (char**) realloc(environ==__origenv?0:environ, |
|
(envc+2)*sizeof(char*)); |
|
if (!newenv) return -1; |
|
- if (envc && (environ==origenv)) { |
|
- memcpy(newenv,origenv,envc*sizeof(char*)); |
|
+ if (envc && (environ==__origenv)) { |
|
+ memcpy(newenv,__origenv,envc*sizeof(char*)); |
|
} |
|
newenv[envc]=(char*)string; |
|
newenv[envc+1]=0;
|
|
|