From 60876a75445b1b65e4a0ec54e18205a79f79466b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 14 Dec 1998 15:23:56 +0000 Subject: Update. * include/stdio.h: Add new parameter to __path_search. * libio/oldtmpfile.c: Add 0 as new parameter to __path_search. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpfile64.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. * stdio-common/tempnam.c: Add 1 as new parameter to __path_search. * sysdeps/posix/tempname.c: Add new parameter. If value is nonzero consider TMPDIR environment variable and dir parameter. Otherwise not. * stdio-common/Makefile (tests): Add tst-tmpnam. * stdio-common/tst-tmpnam.c: New file. --- sysdeps/posix/tempname.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'sysdeps/posix/tempname.c') diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index 97a01d2..1a11375 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -43,7 +43,8 @@ direxists (const char *dir) doesn't exist, none of the searched dirs exists, or there's not enough space in TMPL. */ int -__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx) +__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, + int try_tmpdir) { const char *d; size_t dlen, plen; @@ -60,14 +61,17 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx) plen = 5; } - d = __secure_getenv ("TMPDIR"); - if (d != NULL && direxists (d)) - dir = d; - else if (dir != NULL && direxists (dir)) - /* nothing */ ; - else if (direxists (P_tmpdir)) + if (try_tmpdir) + { + d = __secure_getenv ("TMPDIR"); + if (d != NULL && direxists (d)) + dir = d; + else if (dir != NULL && direxists (dir)) + /* nothing */ ; + } + if (direxists (P_tmpdir)) dir = P_tmpdir; - else if (direxists ("/tmp")) + else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) dir = "/tmp"; else { -- cgit v1.1