|
|
1.1 root 1: /* Copyright (c) 1979 Regents of the University of California */
2:
3: static char sccsid[] = "@(#)IOSYNC.c 1.1 10/29/80";
4:
5: #include "h00vars.h"
6: #include "h01errs.h"
7:
8: /*
9: * insure that a usable image is in the buffer window
10: */
11: IOSYNC(curfile)
12:
13: register struct iorec *curfile;
14: {
15: register short unit = curfile->funit;
16: char *limit, *ptr;
17:
18: if (unit & FWRITE) {
19: ERROR(EREADIT, curfile->pfname);
20: return;
21: }
22: if ((unit & SYNC) == 0) {
23: return;
24: }
25: if (unit & EOFF) {
26: ERROR(EPASTEOF, curfile->pfname);
27: return;
28: }
29: unit &= ~SYNC;
30: fread(curfile->fileptr, curfile->fsize, 1, curfile->fbuf);
31: if (ferror(curfile->fbuf)) {
32: ERROR(EPASTEOF, curfile->pfname);
33: return;
34: }
35: if (feof(curfile->fbuf)) {
36: curfile->funit = unit | EOFF;
37: limit = &curfile->fileptr[curfile->fsize];
38: for (ptr = curfile->fileptr; ptr < limit; )
39: *ptr++ = 0;
40: return;
41: }
42: if (unit & FTEXT) {
43: if (*curfile->fileptr == '\n') {
44: unit |= EOLN;
45: *curfile->fileptr = ' ';
46: } else {
47: unit &= ~EOLN;
48: }
49: }
50: curfile->funit = unit;
51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.