]>
Commit | Line | Data |
---|---|---|
85023577 | 1 | #include "../git-compat-util.h" |
731043fd JR |
2 | |
3 | void gitunsetenv (const char *name) | |
4 | { | |
f1e2a48d BS |
5 | #if !defined(__MINGW32__) |
6 | extern char **environ; | |
7 | #endif | |
731043fd JR |
8 | int src, dst; |
9 | size_t nmln; | |
10 | ||
11 | nmln = strlen(name); | |
12 | ||
13 | for (src = dst = 0; environ[src]; ++src) { | |
14 | size_t enln; | |
15 | enln = strlen(environ[src]); | |
16 | if (enln > nmln) { | |
17 | /* might match, and can test for '=' safely */ | |
18 | if (0 == strncmp (environ[src], name, nmln) | |
19 | && '=' == environ[src][nmln]) | |
20 | /* matches, so skip */ | |
21 | continue; | |
22 | } | |
23 | environ[dst] = environ[src]; | |
24 | ++dst; | |
25 | } | |
26 | environ[dst] = NULL; | |
27 | } |