]> git.ipfire.org Git - thirdparty/git.git/blame - compat/unsetenv.c
Add script for importing bits-and-pieces to Git.
[thirdparty/git.git] / compat / unsetenv.c
CommitLineData
85023577 1#include "../git-compat-util.h"
731043fd
JR
2
3void gitunsetenv (const char *name)
4{
5 extern char **environ;
6 int src, dst;
7 size_t nmln;
8
9 nmln = strlen(name);
10
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;
20 }
21 environ[dst] = environ[src];
22 ++dst;
23 }
24 environ[dst] = NULL;
25}