Commit adcee32c by Toon Moene Committed by Toon Moene

configure.in: See if `mkstemp' is available.

2000-11-15  Toon Moene  <toon@moene.indiv.nluug.nl>

	* libI77/configure.in: See if `mkstemp' is available.
	* libI77/configure: Regenerate.
	* libI77/open.c: Use `mkstemp' to create scratch
	file atomically.

From-SVN: r37484
parent 0437a5a8
2000-11-15 Toon Moene <toon@moene.indiv.nluug.nl>
* libI77/configure.in: See if `mkstemp' is available.
* libI77/configure: Regenerate.
* libI77/open.c: Use `mkstemp' to create scratch
file atomically.
2000-07-03 Donn Terry (donnte@microsoft.com) 2000-07-03 Donn Terry (donnte@microsoft.com)
* libU77/aclocal.m4: check for 2 argument gettimeofday without * libU77/aclocal.m4: check for 2 argument gettimeofday without
struct timezone struct timezone
......
...@@ -1338,7 +1338,7 @@ else ...@@ -1338,7 +1338,7 @@ else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
fi fi
for ac_func in tempnam for ac_func in mkstemp
do do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1345: checking for $ac_func" >&5 echo "configure:1345: checking for $ac_func" >&5
...@@ -1393,25 +1393,80 @@ else ...@@ -1393,25 +1393,80 @@ else
fi fi
done done
for ac_func in tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1400: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1405 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func();
int main() {
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
$ac_func();
#endif
; return 0; }
EOF
if { (eval echo configure:1428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_func_$ac_func=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >> confdefs.h <<EOF
#define $ac_tr_func 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
# posix will guarantee the right behaviour for sprintf, else we can't be # posix will guarantee the right behaviour for sprintf, else we can't be
# sure; HEADER_STDC wouldn't be the right check in sunos4, for instance. # sure; HEADER_STDC wouldn't be the right check in sunos4, for instance.
# However, on my sunos4/gcc setup unistd.h leads us wrongly to believe # However, on my sunos4/gcc setup unistd.h leads us wrongly to believe
# we're posix-conformant, so always do the test. # we're posix-conformant, so always do the test.
echo $ac_n "checking for ansi/posix sprintf result""... $ac_c" 1>&6 echo $ac_n "checking for ansi/posix sprintf result""... $ac_c" 1>&6
echo "configure:1403: checking for ansi/posix sprintf result" >&5 echo "configure:1458: checking for ansi/posix sprintf result" >&5
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
g77_cv_sys_sprintf_ansi=no g77_cv_sys_sprintf_ansi=no
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1408 "configure" #line 1463 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
/* does sprintf return the number of chars transferred? */ /* does sprintf return the number of chars transferred? */
main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);} main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);}
EOF EOF
if { (eval echo configure:1415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null if { (eval echo configure:1470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then then
g77_cv_sys_sprintf_ansi=yes g77_cv_sys_sprintf_ansi=yes
else else
...@@ -1442,9 +1497,9 @@ fi ...@@ -1442,9 +1497,9 @@ fi
# define NON_ANSI_RW_MODES on unix (can't hurt) # define NON_ANSI_RW_MODES on unix (can't hurt)
echo $ac_n "checking NON_ANSI_RW_MODES""... $ac_c" 1>&6 echo $ac_n "checking NON_ANSI_RW_MODES""... $ac_c" 1>&6
echo "configure:1446: checking NON_ANSI_RW_MODES" >&5 echo "configure:1501: checking NON_ANSI_RW_MODES" >&5
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1448 "configure" #line 1503 "configure"
#include "confdefs.h" #include "confdefs.h"
#ifdef unix #ifdef unix
yes yes
......
...@@ -129,6 +129,7 @@ else ...@@ -129,6 +129,7 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(tempnam) AC_CHECK_FUNCS(tempnam)
# posix will guarantee the right behaviour for sprintf, else we can't be # posix will guarantee the right behaviour for sprintf, else we can't be
......
...@@ -133,10 +133,11 @@ integer f_open(olist *a) ...@@ -133,10 +133,11 @@ integer f_open(olist *a)
#endif #endif
{ unit *b; { unit *b;
integer rv; integer rv;
char buf[256], *s; char buf[256], *s, *env;
cllist x; cllist x;
int ufmt; int ufmt;
FILE *tf; FILE *tf;
int fd, len;
#ifndef NON_UNIX_STDIO #ifndef NON_UNIX_STDIO
int n; int n;
#endif #endif
...@@ -209,6 +210,19 @@ integer f_open(olist *a) ...@@ -209,6 +210,19 @@ integer f_open(olist *a)
case 's': case 's':
case 'S': case 'S':
b->uscrtch=1; b->uscrtch=1;
#ifdef HAVE_MKSTEMP /* Allow use of TMPDIR preferentially. */
env = getenv("TMPDIR");
if (!env) env = getenv("TEMP");
if (!env) env = "/tmp";
len = strlen(env);
if (len > 256 - sizeof "/tmp.FXXXXXX")
err (a->oerr, 132, "open");
strcpy(buf, env);
strcat(buf, "/tmp.FXXXXXX");
fd = mkstemp(buf);
if (fd == -1 || close(fd))
err (a->oerr, 132, "open");
#else /* ! defined (HAVE_MKSTEMP) */
#ifdef HAVE_TEMPNAM /* Allow use of TMPDIR preferentially. */ #ifdef HAVE_TEMPNAM /* Allow use of TMPDIR preferentially. */
s = tempnam (0, buf); s = tempnam (0, buf);
if (strlen (s) >= sizeof (buf)) if (strlen (s) >= sizeof (buf))
...@@ -223,6 +237,7 @@ integer f_open(olist *a) ...@@ -223,6 +237,7 @@ integer f_open(olist *a)
(void) mktemp(buf); (void) mktemp(buf);
#endif #endif
#endif /* ! defined (HAVE_TEMPNAM) */ #endif /* ! defined (HAVE_TEMPNAM) */
#endif /* ! defined (HAVE_MKSTEMP) */
goto replace; goto replace;
case 'n': case 'n':
case 'N': case 'N':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment