Sync with maint
[git.git] / compat / unsetenv.c
blob4ea18569c240900b0e889873ddc782614c7724a6
1 #include "../git-compat-util.h"
3 void gitunsetenv (const char *name)
5 int src, dst;
6 size_t nmln;
8 nmln = strlen(name);
10 for (src = dst = 0; environ[src]; ++src) {
11 size_t enln;
12 enln = strlen(environ[src]);
13 if (enln > nmln) {
14 /* might match, and can test for '=' safely */
15 if (0 == strncmp (environ[src], name, nmln)
16 && '=' == environ[src][nmln])
17 /* matches, so skip */
18 continue;
20 environ[dst] = environ[src];
21 ++dst;
23 environ[dst] = NULL;