]> diplodocus.org Git - nmh/commitdiff
Replace calls to unputenv() with unsetenv(3).
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 14 May 2017 22:17:36 +0000 (23:17 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 14 May 2017 22:17:36 +0000 (23:17 +0100)
Makefile.am
h/prototypes.h
sbr/putenv.c [deleted file]
uip/whatnowproc.c

index a284150..4b1cb3d 100644 (file)
@@ -1000,7 +1000,6 @@ sbr_libmh_a_SOURCES = \
     sbr/print_sw.c \
     sbr/print_version.c \
     sbr/push.c \
-    sbr/putenv.c \
     sbr/r1bindex.c \
     sbr/read_line.c \
     sbr/read_switch.c \
index fa37c87..dfc3b5c 100644 (file)
@@ -414,7 +414,6 @@ char *snprintb (char *buffer, size_t size, unsigned flags, char *bitfield);
 int ssequal (const char *, const char *);
 int stringdex (char *, char *);
 char *trimcpy (char *);
-int unputenv (char *);
 
 /*
  * Remove quotes and quoted-pair sequences from RFC-5322 atoms.
diff --git a/sbr/putenv.c b/sbr/putenv.c
deleted file mode 100644 (file)
index d8fb56f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 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 <h/mh.h>
-#include <h/utils.h>
-
-extern char **environ;
-
-/*
- * prototypes
- */
-int unputenv (char *);
-static int nvmatch (char *, char *);
-
-/* FIXME: These functions leak memory.  No easy fix since they might not
- * be malloc'd.  Switch to setenv(3) and unsetenv(3). */
-
-int
-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;
-}
-
-
-static int
-nvmatch (char *s1, char *s2)
-{
-    while (*s1 == *s2++)
-       if (*s1++ == '=')
-           return 1;
-
-    return (*s1 == '\0' && *--s2 == '=');
-}
index 600dd5b..ca2236e 100644 (file)
@@ -35,7 +35,7 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist,
     if (mp)
        setenv("mhfolder", mp->foldpath, 1);
     else
-       unputenv ("mhfolder");
+       unsetenv("mhfolder");
     if (altmsg) {
        if (mp == NULL || *altmsg == '/' || cwd == NULL)
            setenv("mhaltmsg", altmsg, 1);
@@ -44,14 +44,14 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist,
            setenv("mhaltmsg", buffer, 1);
        }
     } else {
-       unputenv ("mhaltmsg");
+       unsetenv("mhaltmsg");
     }
     if ((bp = getenv ("mhaltmsg")))/* XXX */
        setenv("editalt", bp, 1);
     snprintf (buffer, sizeof(buffer), "%d", dist);
     setenv("mhdist", buffer, 1);
     if (nedit) {
-       unputenv ("mheditor");
+       unsetenv("mheditor");
     } else {
         if (!ed)
             ed = get_default_editor();
@@ -62,9 +62,9 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist,
     snprintf (buffer, sizeof(buffer), "%d", atfile);
     setenv("mhatfile", buffer, 1);
 
-    unputenv ("mhmessages");
-    unputenv ("mhannotate");
-    unputenv ("mhinplace");
+    unsetenv("mhmessages");
+    unsetenv("mhannotate");
+    unsetenv("mhinplace");
 
     if (text && mp && !is_readonly(mp)) {
        found = 0;