configure.in: Check for fseeko, ftello.
authorToon Moene <toon@moene.indiv.nluug.nl>
Fri, 6 Jul 2001 12:09:39 +0000 (14:09 +0200)
committerToon Moene <toon@gcc.gnu.org>
Fri, 6 Jul 2001 12:09:39 +0000 (12:09 +0000)
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.

Co-Authored-By: Pedro Vazquez <vazquez@penelope.iqm.unicamp.br>
From-SVN: r43806

15 files changed:
libf2c/ChangeLog
libf2c/libI77/backspace.c
libf2c/libI77/config.h.in
libf2c/libI77/configure
libf2c/libI77/configure.in
libf2c/libI77/dfe.c
libf2c/libI77/due.c
libf2c/libI77/endfile.c
libf2c/libI77/err.c
libf2c/libI77/fio.h
libf2c/libI77/ftell_.c
libf2c/libI77/inquire.c
libf2c/libI77/open.c
libf2c/libI77/rdfmt.c
libf2c/libI77/sue.c

index 264efa3..7f5e7d0 100644 (file)
@@ -1,3 +1,22 @@
+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.
index 609f321..8489239 100644 (file)
@@ -34,31 +34,31 @@ integer f_back(alist *a)
        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;
@@ -69,6 +69,6 @@ integer f_back(alist *a)
                err(a->aerr,(EOF),"backspace");
                }
  break2:
-       fseek(f, z, SEEK_SET);
+       FSEEK(f, z, SEEK_SET);
        return 0;
 }
index 58f83af..9bd8516 100644 (file)
 /* 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
 
index ec7988e..d44e657 100755 (executable)
@@ -1134,7 +1134,7 @@ else
 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;
@@ -1297,7 +1297,7 @@ else
   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
@@ -1352,7 +1352,7 @@ else
 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
@@ -1407,7 +1407,7 @@ else
 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
@@ -1462,25 +1462,135 @@ else
 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
@@ -1511,9 +1621,9 @@ fi
 
 # 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
@@ -1558,12 +1668,12 @@ EOF
 
 
 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
index 20f2628..de38d6d 100644 (file)
@@ -136,6 +136,8 @@ else
   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)
index e90b16d..5290a96 100644 (file)
@@ -82,7 +82,7 @@ c_dfe(cilist *a)
        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);
 }
index df34133..0315e7d 100644 (file)
@@ -25,7 +25,7 @@ c_due(cilist *a)
        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);
 }
@@ -60,8 +60,8 @@ integer e_rdue(Void)
        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);
 }
index 462578d..859eb31 100644 (file)
@@ -81,9 +81,9 @@ t_runc(alist *a)
        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
@@ -121,7 +121,7 @@ t_runc(alist *a)
                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
index 67b5009..5cafab7 100644 (file)
@@ -219,7 +219,7 @@ f__nowreading(unit *x)
        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;
@@ -229,7 +229,7 @@ f__nowreading(unit *x)
                        return 1;
                        }
                }
-       fseek(x->ufd,loc,SEEK_SET);
+       FSEEK(x->ufd,loc,SEEK_SET);
        x->urw = urw;
  done:
        x->uwrt = 0;
@@ -257,7 +257,7 @@ f__nowwriting(unit *x)
                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)))
                        {
@@ -267,7 +267,7 @@ f__nowwriting(unit *x)
                        return(1);
                        }
                x->urw = 3;
-               fseek(x->ufd,loc,SEEK_SET);
+               FSEEK(x->ufd,loc,SEEK_SET);
                }
  done:
        x->uwrt = 1;
index b3dca63..aaeb68d 100644 (file)
 #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
index ce61bd8..d2b2432 100644 (file)
@@ -22,7 +22,7 @@ G77_ftell_0 (integer *Unit)
 #endif
 {
        FILE *f;
-       return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
+       return (f = unit_chk(*Unit, "ftell")) ? FTELL(f) : -1L;
        }
 
  integer
@@ -43,5 +43,5 @@ G77_fseek_0 (integer *Unit, integer *offset, integer *xwhence)
        w = wohin[w];
 #endif
        return  !(f = unit_chk(*Unit, "fseek"))
-               || fseek(f, *offset, w) ? 1 : 0;
+               || FSEEK(f, *offset, w) ? 1 : 0;
        }
index 71eb700..5c5575a 100644 (file)
@@ -100,7 +100,7 @@ integer f_inqu(inlist *a)
        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);
index 56bbc52..e28faaf 100644 (file)
@@ -283,7 +283,7 @@ integer f_open(olist *a)
                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);
 }
index 6ddd369..81426ae 100644 (file)
@@ -471,7 +471,7 @@ rd_ed(struct syl *p, char *ptr, ftnlen len)
                        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;
index 50a94b8..8865054 100644 (file)
@@ -62,8 +62,8 @@ integer s_wsue(cilist *a)
        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)
@@ -74,15 +74,15 @@ 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);
 }