Commit 97897047 by Toon Moene Committed by Toon Moene

configure.in: Test for ftruncate.

2001-02-26  Toon Moene  <toon@moene.indiv.nluug.nl>

	* libI77/configure.in: Test for ftruncate.
	* libI77/configure: Rebuilt.
	* libI77/endfile.c: Use fflush/ftruncate when available.

From-SVN: r40072
parent 3914b81a
2001-02-26 Toon Moene <toon@moene.indiv.nluug.nl>
* libI77/configure.in: Test for ftruncate.
* libI77/configure: Rebuilt.
* libI77/endfile.c: Use fflush/ftruncate when available.
2001-02-19 Joseph S. Myers <jsm28@cam.ac.uk> 2001-02-19 Joseph S. Myers <jsm28@cam.ac.uk>
* libF77/Version.c, libI77/Version.c, libU77/Version.c: Update G77 * libF77/Version.c, libI77/Version.c, libU77/Version.c: Update G77
......
...@@ -1132,7 +1132,7 @@ else ...@@ -1132,7 +1132,7 @@ else
int main() { int main() {
/* Ultrix mips cc rejects this. */ /* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x; typedef int charset[2]; const charset x = {0,0};
/* SunOS 4.1.1 cc rejects this. */ /* SunOS 4.1.1 cc rejects this. */
char const *const *ccp; char const *const *ccp;
char **p; char **p;
...@@ -1295,7 +1295,7 @@ else ...@@ -1295,7 +1295,7 @@ else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
fi fi
for ac_func in mkstemp for ac_func in ftruncate
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:1302: checking for $ac_func" >&5 echo "configure:1302: checking for $ac_func" >&5
...@@ -1350,7 +1350,7 @@ else ...@@ -1350,7 +1350,7 @@ else
fi fi
done done
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:1357: checking for $ac_func" >&5 echo "configure:1357: checking for $ac_func" >&5
...@@ -1405,25 +1405,80 @@ else ...@@ -1405,25 +1405,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:1412: 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 1417 "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:1440: \"$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:1415: checking for ansi/posix sprintf result" >&5 echo "configure:1470: 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 1420 "configure" #line 1475 "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:1427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null if { (eval echo configure:1482: \"$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
...@@ -1454,9 +1509,9 @@ fi ...@@ -1454,9 +1509,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:1458: checking NON_ANSI_RW_MODES" >&5 echo "configure:1513: checking NON_ANSI_RW_MODES" >&5
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1460 "configure" #line 1515 "configure"
#include "confdefs.h" #include "confdefs.h"
#ifdef unix #ifdef unix
yes yes
......
...@@ -134,6 +134,7 @@ else ...@@ -134,6 +134,7 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
AC_CHECK_FUNCS(ftruncate)
AC_CHECK_FUNCS(mkstemp) AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(tempnam) AC_CHECK_FUNCS(tempnam)
......
#include "f2c.h" #include "f2c.h"
#include "fio.h" #include "fio.h"
#include <unistd.h>
#ifdef KR_headers #ifdef KR_headers
extern char *strcpy(); extern char *strcpy();
extern FILE *tmpfile(); extern FILE *tmpfile();
...@@ -38,6 +40,7 @@ integer f_end(alist *a) ...@@ -38,6 +40,7 @@ integer f_end(alist *a)
return(b->useek ? t_runc(a) : 0); return(b->useek ? t_runc(a) : 0);
} }
#ifndef HAVE_FTRUNCATE
static int static int
#ifdef KR_headers #ifdef KR_headers
copy(from, len, to) FILE *from, *to; register long len; copy(from, len, to) FILE *from, *to; register long len;
...@@ -56,6 +59,7 @@ copy(FILE *from, register long len, FILE *to) ...@@ -56,6 +59,7 @@ copy(FILE *from, register long len, FILE *to)
} }
return 0; return 0;
} }
#endif /* !defined(HAVE_FTRUNCATE) */
int int
#ifdef KR_headers #ifdef KR_headers
...@@ -66,8 +70,11 @@ t_runc(alist *a) ...@@ -66,8 +70,11 @@ t_runc(alist *a)
{ {
long loc, len; long loc, len;
unit *b; unit *b;
FILE *bf, *tf; int rc;
int rc = 0; FILE *bf;
#ifndef HAVE_FTRUNCATE
FILE *tf;
#endif /* !defined(HAVE_FTRUNCATE) */
b = &f__units[a->aunit]; b = &f__units[a->aunit];
if(b->url) if(b->url)
...@@ -77,6 +84,8 @@ t_runc(alist *a) ...@@ -77,6 +84,8 @@ t_runc(alist *a)
len=ftell(bf); len=ftell(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL) if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0); return(0);
#ifndef HAVE_FTRUNCATE
rc = 0;
fclose(b->ufd); fclose(b->ufd);
if (!loc) { if (!loc) {
if (!(bf = fopen(b->ufnm, f__w_mode[b->ufmt]))) if (!(bf = fopen(b->ufnm, f__w_mode[b->ufmt])))
...@@ -118,6 +127,10 @@ done1: ...@@ -118,6 +127,10 @@ done1:
fclose(tf); fclose(tf);
done: done:
f__cf = b->ufd = bf; f__cf = b->ufd = bf;
#else /* !defined(HAVE_FTRUNCATE) */
fflush(b->ufd);
rc = ftruncate(fileno(b->ufd),loc);
#endif /* !defined(HAVE_FTRUNCATE) */
if (rc) if (rc)
err(a->aerr,111,"endfile"); err(a->aerr,111,"endfile");
return 0; return 0;
......
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