xref: /csrg-svn/usr.bin/pascal/libpc/READ8.c (revision 3869)
11680Smckusick /* Copyright (c) 1979 Regents of the University of California */
21680Smckusick 
3*3869Smckusic static char sccsid[] = "@(#)READ8.c 1.4 06/10/81";
41680Smckusick 
51680Smckusick #include "h00vars.h"
61680Smckusick 
71680Smckusick double
81680Smckusick READ8(curfile)
91680Smckusick 
101680Smckusick 	register struct iorec	*curfile;
111680Smckusick {
121680Smckusick 	double			data;
132223Smckusic 	int			retval;
141680Smckusick 
151680Smckusick 	if (curfile->funit & FWRITE) {
16*3869Smckusic 		ERROR("%s: Attempt to read, but open for writing\n",
17*3869Smckusic 			curfile->pfname);
181680Smckusick 		return;
191680Smckusick 	}
201680Smckusick 	UNSYNC(curfile);
212223Smckusic 	retval = fscanf(curfile->fbuf, "%lf", &data);
222223Smckusic 	if (retval == EOF) {
23*3869Smckusic 		ERROR("%s: Tried to read past end of file\n", curfile->pfname);
242223Smckusic 		return;
252223Smckusic 	}
262223Smckusic 	if (retval == 0) {
27*3869Smckusic 		ERROR("%s: Bad data found on real read\n", curfile->pfname);
281680Smckusick 		return;
291680Smckusick 	}
302309Smckusic 	curfile->funit &= ~EOLN;
311680Smckusick 	curfile->funit |= SYNC;
321680Smckusick 	return data;
331680Smckusick }
34