<<< Date Index >>>     <<< Thread Index >>>

[PATCH] replace setenv() with putenv()



setenv() is nice, but BSD-conformant; thus many systems don't have
it.  This replaces it with POSIX putenv().  I don't believe putenv() is
required to make a copy -- at any rate, not all implementations do -- so
mutt does not free the buffer.

-- 
 -D.    dgc@xxxxxxxxxxxx        NSIT    University of Chicago
CVSROOT = 
Using: /opt/bin/cvs diff
? stamp-h1
? doc/manual.xml
? doc/mutt.1
Index: pgp.c
===================================================================
RCS file: /home/roessler/cvs/mutt/pgp.c,v
retrieving revision 3.58
diff -u -r3.58 pgp.c
--- pgp.c       21 Sep 2005 04:50:31 -0000      3.58
+++ pgp.c       5 Oct 2005 16:56:48 -0000
@@ -107,12 +107,20 @@
 int pgp_use_gpg_agent (void)
 {
   char *tty;
+  char *ttybuf;
 
   if (!option (OPTUSEGPGAGENT) || !getenv ("GPG_AGENT_INFO"))
     return 0;
 
   if ((tty = ttyname(0)))
-    setenv("GPG_TTY", tty, 0);
+  {
+    ttybuf = malloc(sizeof("GPG_TTY") + strlen(tty) + 1);
+    if (ttybuf)
+    {
+      snprintf(ttybuf, sizeof(ttybuf), "GPG_TTY=%s", tty);
+      putenv(ttybuf);
+    }
+  }
 
   return 1;
 }