compat / unsetenv.con commit Merge branch 'rw/maint-typofix' into rw/typofix (c0a4ae5)
   1#include "../git-compat-util.h"
   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}