Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mkdep Rather than hardcoding _PATH_TMP (and relying ...



details:   https://anonhg.NetBSD.org/src/rev/6425e334d1f5
branches:  trunk
changeset: 474811:6425e334d1f5
user:      kleink <kleink%NetBSD.org@localhost>
date:      Wed Jul 21 15:20:55 1999 +0000

description:
Rather than hardcoding _PATH_TMP (and relying on const string concatenation),
try TMPDIR (if set in the environment).

diffstat:

 usr.bin/mkdep/mkdep.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r cf097a58b9eb -r 6425e334d1f5 usr.bin/mkdep/mkdep.c
--- a/usr.bin/mkdep/mkdep.c     Wed Jul 21 13:34:34 1999 +0000
+++ b/usr.bin/mkdep/mkdep.c     Wed Jul 21 15:20:55 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkdep.c,v 1.3 1999/03/31 11:26:45 kleink Exp $ */
+/*     $NetBSD: mkdep.c,v 1.4 1999/07/21 15:20:55 kleink Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #endif /* not lint */
 
 #ifndef lint
-__RCSID("$NetBSD: mkdep.c,v 1.3 1999/03/31 11:26:45 kleink Exp $");
+__RCSID("$NetBSD: mkdep.c,v 1.4 1999/07/21 15:20:55 kleink Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -120,6 +120,7 @@
        int     aflag, pflag, index, tmpfd, status;
        pid_t   cpid, pid;
        char   *filename, *CC, *pathname, tmpfilename[MAXPATHLEN], **args;
+       const char *tmpdir;
        /* LINTED local definition of tmpfile */
        FILE   *tmpfile, *dependfile;
        char    buffer[32768];
@@ -166,7 +167,10 @@
        args[1] = "-M";
        (void)memcpy(&args[2], argv, (argc + 1) * sizeof(char *));
 
-       (void)strcpy(tmpfilename, _PATH_TMP "mkdepXXXXXX");
+       if ((tmpdir = getenv("TMPDIR")) == NULL)
+               tmpdir = _PATH_TMP;
+       (void)snprintf(tmpfilename, sizeof (tmpfilename), "%s/%s", tmpdir,
+           "mkdepXXXXXX");
        if ((tmpfd = mkstemp (tmpfilename)) < 0) {
                warn("unable to create temporary file %s", tmpfilename);
                return EXIT_FAILURE;



Home | Main Index | Thread Index | Old Index