tolerate short records on non-seekable input. DLW
[unix-history] / usr / src / usr.bin / f77 / libI77 / sfe.c
index f3b7c0a..a948645 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-char id_sfe[] = "@(#)sfe.c     1.5";
+char id_sfe[] = "@(#)sfe.c     1.8";
  *
  * sequential formatted external routines
  */
  *
  * sequential formatted external routines
  */
@@ -149,7 +149,7 @@ x_tab()
 {      int n;
        if(reclen < recpos) reclen = recpos;
        if(curunit->useek)
 {      int n;
        if(reclen < recpos) reclen = recpos;
        if(curunit->useek)
-       {       if((recpos+cursor) < 0) return(F_ERBREC);
+       {       if((recpos+cursor) < 0) cursor = -recpos;       /* to BOR */
                n = reclen - recpos;    /* distance to eor, n>=0 */
                if((cursor-n) > 0)
                {       fseek(cf,(long)n,1);  /* find current eor */
                n = reclen - recpos;    /* distance to eor, n>=0 */
                if((cursor-n) > 0)
                {       fseek(cf,(long)n,1);  /* find current eor */
@@ -167,10 +167,7 @@ x_tab()
        while(cursor--)
        {       if(reading)
                {       n = (*getn)();
        while(cursor--)
        {       if(reading)
                {       n = (*getn)();
-                       if(n=='\n')
-                       {       (*ungetn)(n,cf);
-                               return(F_EREREC);
-                       }
+                       if(n=='\n') return(cursor=0);   /* be tolerant */
                        if(n==EOF) return(EOF);
                }
                else    (*putn)(' ');   /* fill in the empty record */
                        if(n==EOF) return(EOF);
                }
                else    (*putn)(' ');   /* fill in the empty record */