compat / unsetenv.con commit Git.pm: Try to support ActiveState output pipe (a6065b5)
   1#include <stdlib.h>
   2#include <string.h>
   3
   4void gitunsetenv (const char *name)
   5{
   6     extern char **environ;
   7     int src, dst;
   8     size_t nmln;
   9
  10     nmln = strlen(name);
  11
  12     for (src = dst = 0; environ[src]; ++src) {
  13          size_t enln;
  14          enln = strlen(environ[src]);
  15          if (enln > nmln) {
  16               /* might match, and can test for '=' safely */
  17               if (0 == strncmp (environ[src], name, nmln)
  18                   && '=' == environ[src][nmln])
  19                    /* matches, so skip */
  20                    continue;
  21          }
  22          environ[dst] = environ[src];
  23          ++dst;
  24     }
  25     environ[dst] = NULL;
  26}