| 1 | #include "../git-compat-util.h" |
| 2 | |
| 3 | int gitunsetenv(const char *name) |
| 4 | { |
| 5 | #if !defined(__MINGW32__) |
| 6 | extern char **environ; |
| 7 | #endif |
| 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 | |
| 28 | return 0; |
| 29 | } |