From: Toon Moene Date: Mon, 9 Feb 1998 21:32:13 +0000 (+0100) Subject: backspace.c: (f_back): Use type `uiolen' to determine size of record length specifier. X-Git-Tag: prereleases/egcs-1.0.2-prerelease~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=490998071c0395a1f6bfda60570dbc4e8db144ab;p=thirdparty%2Fgcc.git backspace.c: (f_back): Use type `uiolen' to determine size of record length specifier. * libI77/backspace.c: (f_back): Use type `uiolen' to determine size of record length specifier. From-SVN: r17815 --- diff --git a/gcc/f/runtime/ChangeLog.egcs b/gcc/f/runtime/ChangeLog.egcs index 9f0680be7e8d..8e4683d76139 100644 --- a/gcc/f/runtime/ChangeLog.egcs +++ b/gcc/f/runtime/ChangeLog.egcs @@ -1,3 +1,8 @@ +Mon Feb 9 22:33:43 1998 Toon Moene + + * libI77/backspace.c: (f_back): Use type `uiolen' to determine size + of record length specifier. + Tue Nov 18 09:49:04 1997 Mumit Khan (khan@xraylith.wisc.edu) * libI77/close.c (f_exit): Reset f__init so that f_clos does not diff --git a/gcc/f/runtime/libI77/backspace.c b/gcc/f/runtime/libI77/backspace.c index 8413d5f68210..14afe413a454 100644 --- a/gcc/f/runtime/libI77/backspace.c +++ b/gcc/f/runtime/libI77/backspace.c @@ -1,101 +1,5 @@ -#include -#include "f2c.h" -#include "fio.h" -#ifdef KR_headers -integer f_back(a) alist *a; -#else -integer f_back(alist *a) -#endif -{ unit *b; - int i, n, ndec; -#if defined (MSDOS) && !defined (GO32) - int j, k; - long w, z; -#endif - long x, y; - char buf[32]; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->aunit >= MXUNIT || a->aunit < 0) - err(a->aerr,101,"backspace"); - b= &f__units[a->aunit]; - if(b->useek==0) err(a->aerr,106,"backspace"); - if(b->ufd==NULL) { - fk_open(1, 1, a->aunit); - return(0); - } - if(b->uend==1) - { b->uend=0; - return(0); - } - if(b->uwrt) { - (void) t_runc(a); - if (f__nowreading(b)) - err(a->aerr,errno,"backspace"); - } - if(b->url>0) - { - x=ftell(b->ufd); - y = x % b->url; - if(y == 0) x--; - x /= b->url; - x *= b->url; - (void) fseek(b->ufd,x,SEEK_SET); - return(0); - } - - if(b->ufmt==0) - { (void) fseek(b->ufd,-(long)sizeof(int),SEEK_CUR); - (void) fread((char *)&n,sizeof(int),1,b->ufd); - (void) fseek(b->ufd,-(long)n-2*sizeof(int),SEEK_CUR); - return(0); - } -#if defined (MSDOS) && !defined (GO32) - w = -1; -#endif - for(ndec = 1;; ndec = 0) - { - y = x = ftell(b->ufd); - if(x < sizeof(buf)) - x = 0; - else - x -= sizeof(buf); - (void) fseek(b->ufd,x,SEEK_SET); - n=fread(buf,1,(size_t)(y-x), b->ufd); - for(i = n - ndec; --i >= 0; ) - { - if(buf[i]!='\n') continue; -#if defined (MSDOS) && !defined (GO32) - for(j = k = 0; j <= i; j++) - if (buf[j] == '\n') - k++; - fseek(b->ufd,x,SEEK_SET); - for(;;) - if (getc(b->ufd) == '\n') { - if ((z = ftell(b->ufd)) >= y && ndec) { - if (w == -1) - goto break2; - break; - } - if (--k <= 0) - return 0; - w = z; - } - fseek(b->ufd, w, SEEK_SET); -#else - fseek(b->ufd,(long)(i+1-n),SEEK_CUR); -#endif - return(0); - } -#if defined (MSDOS) && !defined (GO32) - break2: -#endif - if(x==0) - { - (void) fseek(b->ufd, 0L, SEEK_SET); - return(0); - } - else if(n<=0) err(a->aerr,(EOF),"backspace"); - (void) fseek(b->ufd, x, SEEK_SET); - } -} + int i, ndec; + uiolen n; + { (void) fseek(b->ufd,-(long)sizeof(uiolen),SEEK_CUR); + (void) fread((char *)&n,sizeof(uiolen),1,b->ufd); + (void) fseek(b->ufd,-(long)n-2*sizeof(uiolen),SEEK_CUR);