From 731043fd4d55b1561ebb5a53daa4b9ff6dfac046 Mon Sep 17 00:00:00 2001 From: Jason Riedy Date: Wed, 25 Jan 2006 12:38:36 -0800 Subject: Add compat/unsetenv.c . Implement a (slow) unsetenv() for older systems. Signed-off-by: Jason Riedy Signed-off-by: Junio C Hamano --- compat/unsetenv.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 compat/unsetenv.c (limited to 'compat') diff --git a/compat/unsetenv.c b/compat/unsetenv.c new file mode 100644 index 0000000000..3a5e4ec04a --- /dev/null +++ b/compat/unsetenv.c @@ -0,0 +1,26 @@ +#include +#include + +void gitunsetenv (const char *name) +{ + extern char **environ; + int src, dst; + size_t nmln; + + nmln = strlen(name); + + for (src = dst = 0; environ[src]; ++src) { + size_t enln; + enln = strlen(environ[src]); + if (enln > nmln) { + /* might match, and can test for '=' safely */ + if (0 == strncmp (environ[src], name, nmln) + && '=' == environ[src][nmln]) + /* matches, so skip */ + continue; + } + environ[dst] = environ[src]; + ++dst; + } + environ[dst] = NULL; +} -- cgit v1.2.3