builtin/update-index.c: cleanup update_one
[git/mingw/4msysgit.git] / compat / unsetenv.c
blobbf5fd7063bc98964382b193cc9171a734c7aa790
1 #include "../git-compat-util.h"
3 void gitunsetenv (const char *name)
5 #if !defined(__MINGW32__)
6 extern char **environ;
7 #endif
8 int src, dst;
9 size_t nmln;
11 nmln = strlen(name);
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;
23 environ[dst] = environ[src];
24 ++dst;
26 environ[dst] = NULL;