diff options
author | kris <kris@FreeBSD.org> | 2002-10-13 06:08:01 +0800 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2002-10-13 06:08:01 +0800 |
commit | c39f10faccc557ca352402d46cde0119b5f4a052 (patch) | |
tree | 02f88ac68d65493bb014f3919760d1d01ff1aae6 /news/knews/files | |
parent | 49f618f26fcbd47dbc632b89577fd7a93950ca97 (diff) | |
download | freebsd-ports-gnome-c39f10faccc557ca352402d46cde0119b5f4a052.tar.gz freebsd-ports-gnome-c39f10faccc557ca352402d46cde0119b5f4a052.tar.zst freebsd-ports-gnome-c39f10faccc557ca352402d46cde0119b5f4a052.zip |
Fix build on -current (use TMPDIR environment variable to get preferred
tmp directory, and fall back to _PATH_TMP, instead of using header
definitions that are no longer visible by default.)
Submitted by: Steven G. Kargl <kargl@troutmask.apl.washington.edu> (based on)
PR: ports/42510
Diffstat (limited to 'news/knews/files')
-rw-r--r-- | news/knews/files/patch-file.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/news/knews/files/patch-file.c b/news/knews/files/patch-file.c index 83d1cd661508..0237d12c3632 100644 --- a/news/knews/files/patch-file.c +++ b/news/knews/files/patch-file.c @@ -1,27 +1,39 @@ -Use mkstemp instead of tmpnam. Copied from the tmpnam implementation :) - - -mi - ---- src/file.c Fri Jan 9 12:16:19 1998 -+++ src/file.c Fri Jul 13 10:41:01 2001 -@@ -187,13 +187,11 @@ - int fd; -+ static unsigned long tmpcount; -+ static char buf[L_tmpnam]; +--- src/file.c.orig Fri Jan 9 09:16:19 1998 ++++ src/file.c Sat Sep 7 16:51:54 2002 +@@ -4,6 +4,7 @@ + + #include "global.h" + #include <sys/stat.h> ++#include <paths.h> + #include "expand.h" + #include "file.h" +@@ -185,16 +186,18 @@ + int create_temp_fd(char **name) + { + int fd; +- - *name = tmpnam(NULL); - if (!*name) - fd = -1; - else { -+ (void)snprintf(buf, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount++); -+ *name = buf; -+ fd = mkstemp(buf); -+ if (fd < 0) -+ *name = NULL; - unlink(*name); - fd = open(*name, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR); - if (fd < 0) - *name = NULL; - } ++ char filename[FILENAME_MAX]; ++ char *tmpdir; ++ ++ if ((tmpdir = getenv("TMPDIR")) == NULL) ++ tmpdir = _PATH_TMP; ++ strlcpy(filename, tmpdir, FILENAME_MAX); ++ strlcat(filename, "/tmp.XXXXXX", FILENAME_MAX); ++ ++ if ((fd = mkstemp(filename)) == -1) ++ *name = NULL; ++ else ++ *name = filename; return fd; + } |