+2001-07-06 Toon Moene <toon@moene.indiv.nluug.nl>
+ Pedro Vazquez <vazquez@penelope.iqm.unicamp.br>
+
+ * configure.in: Check for fseeko, ftello.
+ * configure: Rebuilt.
+ * config.h.in: Rebuilt.
+ * fio.h: Define FSEEK to be fseek or fseeko, depending
+ on configure's findings. Ditto for FTELL and ftell / ftello.
+ * backspace.c (f_back): Use FSEEK for fseek, FTELL for ftell.
+ * dfe.c (c_dfe): Ditto.
+ * due.c (c_due, e_rdue): Ditto.
+ * endfile.c (t_runc): Ditto.
+ * err.c (f__nowreading, f__nowwriting): Ditto.
+ * ftell_.c (G77_ftell_0, G77_fseek_0): Ditto.
+ * inquire.c (f_inqu): Ditto.
+ * open.c (f_open): Ditto.
+ * rdfmt.c (rd_ed): Ditto.
+ * sue.c (s_wsue, e_wsue, e_rsue): Ditto.
+
2001-07-04 Zack Weinberg <zackw@stanford.edu>
* Makefile.in: Take PICFLAG and RUNTESTFLAGS out of FLAGS_TO_PASS.
f = b->ufd; /* may have changed in t_runc() */
if(b->url>0)
{
- x=ftell(f);
+ x=FTELL(f);
y = x % b->url;
if(y == 0) x--;
x /= b->url;
x *= b->url;
- (void) fseek(f,x,SEEK_SET);
+ FSEEK(f,x,SEEK_SET);
return(0);
}
if(b->ufmt==0)
- { fseek(f,-(long)sizeof(uiolen),SEEK_CUR);
+ { FSEEK(f,-(off_t)sizeof(uiolen),SEEK_CUR);
fread((char *)&n,sizeof(uiolen),1,f);
- fseek(f,-(long)n-2*sizeof(uiolen),SEEK_CUR);
+ FSEEK(f,-(off_t)n-2*sizeof(uiolen),SEEK_CUR);
return(0);
}
- w = x = ftell(f);
+ w = x = FTELL(f);
z = 0;
loop:
while(x) {
x -= x < 64 ? x : 64;
- fseek(f,x,SEEK_SET);
+ FSEEK(f,x,SEEK_SET);
for(y = x; y < w; y++) {
if (getc(f) != '\n')
continue;
- v = ftell(f);
+ v = FTELL(f);
if (v == w) {
if (z)
goto break2;
err(a->aerr,(EOF),"backspace");
}
break2:
- fseek(f, z, SEEK_SET);
+ FSEEK(f, z, SEEK_SET);
return 0;
}
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Define if you have the fseeko function. */
+#undef HAVE_FSEEKO
+
+/* Define if you have the ftello function. */
+#undef HAVE_FTELLO
+
/* Define if you have the ftruncate function. */
#undef HAVE_FTRUNCATE
int main() {
/* 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. */
char const *const *ccp;
char **p;
echo "$ac_t""no" 1>&6
fi
-for ac_func in ftruncate
+for ac_func in fseeko
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1304: checking for $ac_func" >&5
fi
done
-for ac_func in mkstemp
+for ac_func in ftello
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1359: checking for $ac_func" >&5
fi
done
-for ac_func in tempnam
+for ac_func in ftruncate
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1414: checking for $ac_func" >&5
fi
done
+for ac_func in mkstemp
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1469: 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 1474 "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:1497: \"$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
+
+for ac_func in tempnam
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1524: 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 1529 "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:1552: \"$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
# 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
# we're posix-conformant, so always do the test.
echo $ac_n "checking for ansi/posix sprintf result""... $ac_c" 1>&6
-echo "configure:1472: checking for ansi/posix sprintf result" >&5
+echo "configure:1582: checking for ansi/posix sprintf result" >&5
if test "$cross_compiling" = yes; then
g77_cv_sys_sprintf_ansi=no
else
cat > conftest.$ac_ext <<EOF
-#line 1477 "configure"
+#line 1587 "configure"
#include "confdefs.h"
#include <stdio.h>
/* does sprintf return the number of chars transferred? */
main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);}
EOF
-if { (eval echo configure:1484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
g77_cv_sys_sprintf_ansi=yes
else
# define NON_ANSI_RW_MODES on unix (can't hurt)
echo $ac_n "checking NON_ANSI_RW_MODES""... $ac_c" 1>&6
-echo "configure:1515: checking NON_ANSI_RW_MODES" >&5
+echo "configure:1625: checking NON_ANSI_RW_MODES" >&5
cat > conftest.$ac_ext <<EOF
-#line 1517 "configure"
+#line 1627 "configure"
#include "confdefs.h"
#ifdef unix
yes
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:1562: checking for off_t" >&5
+echo "configure:1672: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1567 "configure"
+#line 1677 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
AC_MSG_RESULT(no)
fi
+AC_CHECK_FUNCS(fseeko)
+AC_CHECK_FUNCS(ftello)
AC_CHECK_FUNCS(ftruncate)
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(tempnam)
f__fmtbuf=a->cifmt;
if(a->cirec <= 0)
err(a->cierr,130,"dfe");
- (void) fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET);
+ FSEEK(f__cf,f__curunit->url * (a->cirec-1),SEEK_SET);
f__curunit->uend = 0;
return(0);
}
if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue");
if(a->cirec <= 0)
err(a->cierr,130,"due");
- fseek(f__cf,(long)(a->cirec-1)*f__curunit->url,SEEK_SET);
+ FSEEK(f__cf,(a->cirec-1)*f__curunit->url,SEEK_SET);
f__curunit->uend = 0;
return(0);
}
f__init = 1;
if(f__curunit->url==1 || f__recpos==f__curunit->url)
return(0);
- fseek(f__cf,(long)(f__curunit->url-f__recpos),SEEK_CUR);
- if(ftell(f__cf)%f__curunit->url)
+ FSEEK(f__cf,(f__curunit->url-f__recpos),SEEK_CUR);
+ if(FTELL(f__cf)%f__curunit->url)
err(f__elist->cierr,200,"syserr");
return(0);
}
b = &f__units[a->aunit];
if(b->url)
return(0); /*don't truncate direct files*/
- loc=ftell(bf = b->ufd);
- fseek(bf,0L,SEEK_END);
- len=ftell(bf);
+ loc=FTELL(bf = b->ufd);
+ FSEEK(bf,0,SEEK_END);
+ len=FTELL(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0);
#ifndef HAVE_FTRUNCATE
fclose(bf);
if (!(bf = fopen(b->ufnm, f__w_mode[3])))
goto bad;
- fseek(bf,0L,SEEK_END);
+ FSEEK(bf,0,SEEK_END);
b->urw = 3;
}
#endif
if (!x->ufnm)
goto cantread;
ufmt = x->url ? 0 : x->ufmt;
- loc = ftell(x->ufd);
+ loc = FTELL(x->ufd);
urw = 3;
if (!freopen(x->ufnm, f__w_mode[ufmt|2], x->ufd)) {
urw = 1;
return 1;
}
}
- fseek(x->ufd,loc,SEEK_SET);
+ FSEEK(x->ufd,loc,SEEK_SET);
x->urw = urw;
done:
x->uwrt = 0;
x->urw = 2;
}
else {
- loc=ftell(x->ufd);
+ loc=FTELL(x->ufd);
if (!(f__cf = x->ufd =
freopen(x->ufnm, f__w_mode[ufmt |= 2], x->ufd)))
{
return(1);
}
x->urw = 3;
- fseek(x->ufd,loc,SEEK_SET);
+ FSEEK(x->ufd,loc,SEEK_SET);
}
done:
x->uwrt = 1;
#define SEEK_END 2
#endif
+/* Only use fseeko/ftello if they are both there. */
+
+#if defined (HAVE_FSEEKO) && defined (HAVE_FTELLO)
+#define FSEEK fseeko
+#define FTELL ftello
+#else
+#define FSEEK fseek
+#define FTELL ftell
+#endif
+
#if defined (MSDOS) && !defined (GO32)
#ifndef NON_UNIX_STDIO
#define NON_UNIX_STDIO
#endif
{
FILE *f;
- return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
+ return (f = unit_chk(*Unit, "ftell")) ? FTELL(f) : -1L;
}
integer
w = wohin[w];
#endif
return !(f = unit_chk(*Unit, "fseek"))
- || fseek(f, *offset, w) ? 1 : 0;
+ || FSEEK(f, *offset, w) ? 1 : 0;
}
if(a->inrecl!=NULL && p!=NULL)
*a->inrecl=p->url;
if(a->innrec!=NULL && p!=NULL && p->url>0)
- *a->innrec=ftell(p->ufd)/p->url+1;
+ *a->innrec=FTELL(p->ufd)/p->url+1;
if(a->inblank && p!=NULL && p->ufmt)
if(p->ublnk)
b_char("ZERO",a->inblank,a->inblanklen);
if (a->orl)
rewind(b->ufd);
else if ((s = a->oacc) && (*s == 'a' || *s == 'A')
- && fseek(b->ufd, 0L, SEEK_END))
+ && FSEEK(b->ufd, 0, SEEK_END))
opnerr(a->oerr,129,"open");
return(0);
}
f__icptr += f__cursor;
}
else if(f__curunit && f__curunit->useek)
- (void) fseek(f__cf,(long) f__cursor,SEEK_CUR);
+ FSEEK(f__cf,(off_t)f__cursor,SEEK_CUR);
else
err(f__elist->cierr,106,"fmt");
f__recpos += f__cursor;
f__reclen=0;
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
err(a->cierr, errno, "write start");
- f__recloc=ftell(f__cf);
- (void) fseek(f__cf,(long)sizeof(uiolen),SEEK_CUR);
+ f__recloc=FTELL(f__cf);
+ FSEEK(f__cf,(off_t)sizeof(uiolen),SEEK_CUR);
return(0);
}
integer e_wsue(Void)
if (fflush(f__cf))
err(f__elist->cierr, errno, "write end");
#endif
- loc=ftell(f__cf);
- fseek(f__cf,f__recloc,SEEK_SET);
+ loc=FTELL(f__cf);
+ FSEEK(f__cf,f__recloc,SEEK_SET);
fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
- fseek(f__cf,loc,SEEK_SET);
+ FSEEK(f__cf,loc,SEEK_SET);
return(0);
}
integer e_rsue(Void)
{
f__init = 1;
- (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
+ FSEEK(f__cf,(off_t)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
return(0);
}