xref: /original-bsd/usr.bin/pascal/libpc/UNSYNC.c (revision 4f00418d)
1 /*-
2  * Copyright (c) 1979, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)UNSYNC.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 #include "h00vars.h"
13 
14 /*
15  * push back last char read to prepare for formatted read
16  */
17 UNSYNC(curfile)
18 
19 	register struct iorec	*curfile;
20 {
21 	if (curfile->funit & FWRITE) {
22 		ERROR("%s: Attempt to read, but open for writing\n",
23 			curfile->pfname);
24 		return;
25 	}
26 	if (curfile->funit & EOFF) {
27 		ERROR("%s: Tried to read past end of file\n", curfile->pfname);
28 		return;
29 	}
30 	if ((curfile->funit & SYNC) == 0) {
31 		ungetc(*curfile->fileptr, curfile->fbuf);
32 	}
33 	curfile->funit &= ~EOLN;
34 	curfile->funit |= SYNC;
35 }
36