xref: /original-bsd/usr.bin/pascal/libpc/UNSYNC.c (revision 4f485440)
1 /* Copyright (c) 1979 Regents of the University of California */
2 
3 static char sccsid[] = "@(#)UNSYNC.c 1.3 06/10/81";
4 
5 #include "h00vars.h"
6 
7 /*
8  * push back last char read to prepare for formatted read
9  */
10 UNSYNC(curfile)
11 
12 	register struct iorec	*curfile;
13 {
14 	if (curfile->funit & FWRITE) {
15 		ERROR("%s: Attempt to read, but open for writing\n",
16 			curfile->pfname);
17 		return;
18 	}
19 	if (curfile->funit & EOFF) {
20 		ERROR("%s: Tried to read past end of file\n", curfile->pfname);
21 		return;
22 	}
23 	if ((curfile->funit & SYNC) == 0) {
24 		ungetc(*curfile->fileptr, curfile->fbuf);
25 	}
26 }
27