xref: /csrg-svn/usr.bin/pascal/libpc/UNSYNC.c (revision 62096)
140865Sbostic /*-
2*62096Sbostic  * Copyright (c) 1979, 1993
3*62096Sbostic  *	The Regents of the University of California.  All rights reserved.
440865Sbostic  *
540865Sbostic  * %sccs.include.redist.c%
640865Sbostic  */
71714Smckusick 
840865Sbostic #ifndef lint
9*62096Sbostic static char sccsid[] = "@(#)UNSYNC.c	8.1 (Berkeley) 06/06/93";
1040865Sbostic #endif /* not lint */
111714Smckusick 
121714Smckusick #include "h00vars.h"
131714Smckusick 
141714Smckusick /*
151714Smckusick  * push back last char read to prepare for formatted read
161714Smckusick  */
UNSYNC(curfile)171714Smckusick UNSYNC(curfile)
181714Smckusick 
191714Smckusick 	register struct iorec	*curfile;
201714Smckusick {
211714Smckusick 	if (curfile->funit & FWRITE) {
223869Smckusic 		ERROR("%s: Attempt to read, but open for writing\n",
233869Smckusic 			curfile->pfname);
241714Smckusick 		return;
251714Smckusick 	}
262224Smckusic 	if (curfile->funit & EOFF) {
273869Smckusic 		ERROR("%s: Tried to read past end of file\n", curfile->pfname);
282224Smckusic 		return;
292224Smckusic 	}
301714Smckusick 	if ((curfile->funit & SYNC) == 0) {
311714Smckusick 		ungetc(*curfile->fileptr, curfile->fbuf);
321714Smckusick 	}
3315303Smckusick 	curfile->funit &= ~EOLN;
3415303Smckusick 	curfile->funit |= SYNC;
351714Smckusick }
36