xref: /csrg-svn/usr.bin/pascal/libpc/READ8.c (revision 2309)
11680Smckusick /* Copyright (c) 1979 Regents of the University of California */
21680Smckusick 
3*2309Smckusic static char sccsid[] = "@(#)READ8.c 1.3 01/28/81";
41680Smckusick 
51680Smckusick #include "h00vars.h"
61680Smckusick #include "h01errs.h"
71680Smckusick 
81680Smckusick double
91680Smckusick READ8(curfile)
101680Smckusick 
111680Smckusick 	register struct iorec	*curfile;
121680Smckusick {
131680Smckusick 	double			data;
142223Smckusic 	int			retval;
151680Smckusick 
161680Smckusick 	if (curfile->funit & FWRITE) {
171680Smckusick 		ERROR(EREADIT, curfile->pfname);
181680Smckusick 		return;
191680Smckusick 	}
201680Smckusick 	UNSYNC(curfile);
212223Smckusic 	retval = fscanf(curfile->fbuf, "%lf", &data);
222223Smckusic 	if (retval == EOF) {
232223Smckusic 		ERROR(EPASTEOF, curfile->pfname);
242223Smckusic 		return;
252223Smckusic 	}
262223Smckusic 	if (retval == 0) {
271680Smckusick 		ERROR(EBADFNUM, curfile->pfname);
281680Smckusick 		return;
291680Smckusick 	}
30*2309Smckusic 	curfile->funit &= ~EOLN;
311680Smckusick 	curfile->funit |= SYNC;
321680Smckusick 	return data;
331680Smckusick }
34