1: /* Copyright (c) 1979 Regents of the University of California */
   2: 
   3: static char sccsid[] = "@(#)IOSYNC.c 1.5 6/10/81";
   4: 
   5: #include "h00vars.h"
   6: 
   7: /*
   8:  * insure that a usable image is in the buffer window
   9:  */
  10: IOSYNC(curfile)
  11: 
  12:     register struct iorec   *curfile;
  13: {
  14:     char            *limit, *ptr;
  15: 
  16:     if (curfile->funit & FWRITE) {
  17:         ERROR("%s: Attempt to read, but open for writing\n",
  18:             curfile->pfname);
  19:         return;
  20:     }
  21:     if ((curfile->funit & SYNC) == 0) {
  22:         return;
  23:     }
  24:     if (curfile->funit & EOFF) {
  25:         ERROR("%s: Tried to read past end of file\n", curfile->pfname);
  26:         return;
  27:     }
  28:     curfile->funit &= ~SYNC;
  29:     if (curfile->funit & SPEOLN) {
  30:         curfile->funit &= ~(SPEOLN|EOLN);
  31:         curfile->funit |= EOFF;
  32:         return;
  33:     }
  34:     fread(curfile->fileptr, (int)curfile->fsize, 1, curfile->fbuf);
  35:     if (ferror(curfile->fbuf)) {
  36:         ERROR("%s: Tried to read past end of file\n", curfile->pfname);
  37:         return;
  38:     }
  39:     if (feof(curfile->fbuf)) {
  40:         if (curfile->funit & FTEXT) {
  41:             *curfile->fileptr = ' ';
  42:             if (curfile->funit & EOLN) {
  43:                 curfile->funit &= ~EOLN;
  44:                 curfile->funit |= EOFF;
  45:                 return;
  46:             }
  47:             curfile->funit |= (SPEOLN|EOLN);
  48:             return;
  49:         }
  50:         curfile->funit |= EOFF;
  51:         limit = &curfile->fileptr[curfile->fsize];
  52:         for (ptr = curfile->fileptr; ptr < limit; )
  53:             *ptr++ = 0;
  54:         return;
  55:     }
  56:     if (curfile->funit & FTEXT) {
  57:         if (*curfile->fileptr == '\n') {
  58:             curfile->funit |= EOLN;
  59:             *curfile->fileptr = ' ';
  60:             return;
  61:         }
  62:         curfile->funit &= ~EOLN;
  63:     }
  64: }

Defined functions

Defined variables

sccsid defined in line 3; never used
Last modified: 1983-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1039
Valid CSS Valid XHTML 1.0 Strict