X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fputenv.c;h=a2ec7d3a91d8ade38c2b83a4c69b9d9fb96c8329;hp=fb4a77ce9d69f5f0b441073086635220075e56ba;hb=5ba9c2f13fedf1d8d6ed907ef1f505616290efaa;hpb=81a21a9a97d8633f6d6231e31fdb6e328d0d3ff2 diff --git a/sbr/putenv.c b/sbr/putenv.c index fb4a77c..a2ec7d3 100644 --- a/sbr/putenv.c +++ b/sbr/putenv.c @@ -1,13 +1,10 @@ - /* - * putenv.c -- (un)set an envariable - * - * $Id$ - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** putenv.c -- (un)set an envariable +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include #include @@ -15,65 +12,65 @@ extern char **environ; /* - * prototypes - */ -int m_putenv (char *, char *); -int unputenv (char *); -static int nvmatch (char *, char *); +** prototypes +*/ +int m_putenv(char *, char *); +int unputenv(char *); +static int nvmatch(char *, char *); int -m_putenv (char *name, char *value) +m_putenv(char *name, char *value) { - register int i; - register char **ep, **nep, *cp; + int i; + char **ep, **nep, *cp; - cp = mh_xmalloc ((size_t) (strlen (name) + strlen (value) + 2)); + cp = mh_xmalloc((size_t) (strlen(name) + strlen(value) + 2)); - sprintf (cp, "%s=%s", name, value); + sprintf(cp, "%s=%s", name, value); - for (ep = environ, i = 0; *ep; ep++, i++) - if (nvmatch (name, *ep)) { - *ep = cp; - return 0; - } + for (ep = environ, i = 0; *ep; ep++, i++) + if (nvmatch(name, *ep)) { + *ep = cp; + return 0; + } - nep = (char **) mh_xmalloc ((size_t) ((i + 2) * sizeof(*nep))); + nep = (char **) mh_xmalloc((size_t) ((i + 2) * sizeof(*nep))); - for (ep = environ, i = 0; *ep; nep[i++] = *ep++) - continue; - nep[i++] = cp; - nep[i] = NULL; - environ = nep; - return 0; + for (ep = environ, i = 0; *ep; nep[i++] = *ep++) + continue; + nep[i++] = cp; + nep[i] = NULL; + environ = nep; + return 0; } int -unputenv (char *name) +unputenv(char *name) { - char **ep, **nep; - - for (ep = environ; *ep; ep++) - if (nvmatch (name, *ep)) - break; - if (*ep == NULL) - return 1; - - for (nep = ep + 1; *nep; nep++) - continue; - *ep = *--nep; - *nep = NULL; - return 0; + char **ep, **nep; + + for (ep = environ; *ep; ep++) + if (nvmatch(name, *ep)) + break; + if (*ep == NULL) + return 1; + + for (nep = ep + 1; *nep; nep++) + continue; + *ep = *--nep; + *nep = NULL; + return 0; } static int -nvmatch (char *s1, char *s2) +nvmatch(char *s1, char *s2) { - while (*s1 == *s2++) - if (*s1++ == '=') - return 1; + while (*s1 == *s2++) + if (*s1++ == '=') + return 1; - return (*s1 == '\0' && *--s2 == '='); + return (*s1 == '\0' && *--s2 == '='); }