lint fixes
[unix-history] / usr / src / usr.bin / pascal / libpc / IOSYNC.c
index e308433..4d64685 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)IOSYNC.c 1.2 %G%";
+static char sccsid[] = "@(#)IOSYNC.c 1.3 %G%";
 
 #include "h00vars.h"
 #include "h01errs.h"
 
 #include "h00vars.h"
 #include "h01errs.h"
@@ -12,44 +12,53 @@ IOSYNC(curfile)
 
        register struct iorec   *curfile;
 {
 
        register struct iorec   *curfile;
 {
-       register short          unit = curfile->funit;
        char                    *limit, *ptr;
 
        char                    *limit, *ptr;
 
-       if (unit & FWRITE) {
+       if (curfile->funit & FWRITE) {
                ERROR(EREADIT, curfile->pfname);
                return;
        }
                ERROR(EREADIT, curfile->pfname);
                return;
        }
-       if ((unit & SYNC) == 0) {
+       if ((curfile->funit & SYNC) == 0) {
                return;
        }
                return;
        }
-       if (unit & EOFF) {
+       if (curfile->funit & EOFF) {
                ERROR(EPASTEOF, curfile->pfname);
                return;
        }
                ERROR(EPASTEOF, curfile->pfname);
                return;
        }
-       unit &= ~SYNC;
+       curfile->funit &= ~SYNC;
+       if (curfile->funit & SPEOLN) {
+               curfile->funit &= ~(SPEOLN|EOLN);
+               curfile->funit |= EOFF;
+               return;
+       }
        fread(curfile->fileptr, curfile->fsize, 1, curfile->fbuf);
        if (ferror(curfile->fbuf)) {
                ERROR(EPASTEOF, curfile->pfname);
                return;
        }
        if (feof(curfile->fbuf)) {
        fread(curfile->fileptr, curfile->fsize, 1, curfile->fbuf);
        if (ferror(curfile->fbuf)) {
                ERROR(EPASTEOF, curfile->pfname);
                return;
        }
        if (feof(curfile->fbuf)) {
-               curfile->funit = unit | EOFF;
-               if (unit & FTEXT) {
+               if (curfile->funit & FTEXT) {
                        *curfile->fileptr = ' ';
                        *curfile->fileptr = ' ';
+                       if (curfile->funit & EOLN) {
+                               curfile->funit &= ~EOLN;
+                               curfile->funit |= EOFF;
+                               return;
+                       }
+                       curfile->funit |= (SPEOLN|EOLN);
                        return;
                }
                        return;
                }
+               curfile->funit |= EOFF;
                limit = &curfile->fileptr[curfile->fsize];
                for (ptr = curfile->fileptr; ptr < limit; )
                        *ptr++ = 0;
                return;
        }
                limit = &curfile->fileptr[curfile->fsize];
                for (ptr = curfile->fileptr; ptr < limit; )
                        *ptr++ = 0;
                return;
        }
-       if (unit & FTEXT) {
+       if (curfile->funit & FTEXT) {
                if (*curfile->fileptr == '\n') {
                if (*curfile->fileptr == '\n') {
-                       unit |= EOLN;
+                       curfile->funit |= EOLN;
                        *curfile->fileptr = ' ';
                        *curfile->fileptr = ' ';
-               } else {
-                       unit &= ~EOLN;
+                       return;
                }
                }
+               curfile->funit &= ~EOLN;
        }
        }
-       curfile->funit = unit;
 }
 }