summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5ea06e2)
raw | patch | inline | side by side (parent: 5ea06e2)
author | Jason Riedy <ejr@EECS.Berkeley.EDU> | |
Wed, 25 Jan 2006 20:38:36 +0000 (12:38 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 25 Jan 2006 23:10:39 +0000 (15:10 -0800) |
Implement a (slow) unsetenv() for older systems.
Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile | patch | blob | history | |
compat/unsetenv.c | [new file with mode: 0644] | patch | blob |
connect.c | patch | blob | history | |
git-compat-util.h | patch | blob | history |
diff --git a/Makefile b/Makefile
index 245f658375ab560cc04a25e9082d1ca409a1bb26..2e953531af8135f3b15225c07cef70b078f8c21a 100644 (file)
--- a/Makefile
+++ b/Makefile
SHELL_PATH = /bin/bash
NO_STRCASESTR = YesPlease
ifeq ($(uname_R),5.8)
+ NO_UNSETENV = YesPlease
NO_SETENV = YesPlease
endif
INSTALL = ginstall
COMPAT_CFLAGS += -DNO_SETENV
COMPAT_OBJS += compat/setenv.o
endif
+ifdef NO_SETENV
+ COMPAT_CFLAGS += -DNO_UNSETENV
+ COMPAT_OBJS += compat/unsetenv.o
+endif
ifdef NO_MMAP
COMPAT_CFLAGS += -DNO_MMAP
COMPAT_OBJS += compat/mmap.o
diff --git a/compat/unsetenv.c b/compat/unsetenv.c
--- /dev/null
+++ b/compat/unsetenv.c
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <string.h>
+
+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;
+}
diff --git a/connect.c b/connect.c
index e1c04e1eaeb5b1d7c86f70fbad1a5167b58c1b17..3f2d65c313418c9e6b433a18f4b7d03c6ff276c2 100644 (file)
--- a/connect.c
+++ b/connect.c
+#include "git-compat-util.h"
#include "cache.h"
#include "pkt-line.h"
#include "quote.h"
diff --git a/git-compat-util.h b/git-compat-util.h
index 12ce6590bb926de2d27eee9520dd2017dd34554e..f982b8e48469a5f09698808d1e55ded04d5923b8 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
extern int gitsetenv(const char *, const char *, int);
#endif
+#ifdef NO_UNSETENV
+#define unsetenv gitunsetenv
+extern void gitunsetenv(const char *);
+#endif
+
#ifdef NO_STRCASESTR
#define strcasestr gitstrcasestr
extern char *gitstrcasestr(const char *haystack, const char *needle);