Merge branch 'ao/send-email-irt'
[git/kirr.git] / compat / unsetenv.c
blobeb29f5e0849370afe90c400271fea12e0f9090aa
1 #include "../git-compat-util.h"
3 void gitunsetenv (const char *name)
5 extern char **environ;
6 int src, dst;
7 size_t nmln;
9 nmln = strlen(name);
11 for (src = dst = 0; environ[src]; ++src) {
12 size_t enln;
13 enln = strlen(environ[src]);
14 if (enln > nmln) {
15 /* might match, and can test for '=' safely */
16 if (0 == strncmp (environ[src], name, nmln)
17 && '=' == environ[src][nmln])
18 /* matches, so skip */
19 continue;
21 environ[dst] = environ[src];
22 ++dst;
24 environ[dst] = NULL;