360f119f6620f5c0caaf6949f0ff06b1acc74397
[ghc-hetmet.git] / ghc / lib / std / cbits / fileLookAhead.c
1 /* 
2  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
3  *
4  * $Id: fileLookAhead.c,v 1.1 1998/04/10 10:54:24 simonm Exp $
5  *
6  * hLookAhead Runtime Support
7  */
8
9 #include "Rts.h"
10 #include "stgio.h"
11
12 StgInt
13 fileLookAhead(StgAddr fp)
14 {
15     int c;
16
17     if ((c = fileGetc((FILE *)fp)) == EOF) {
18         return c;
19     } else if (ungetc(c, (FILE *)fp) == EOF) {
20         cvtErrno();
21         stdErrno();
22         return EOF;
23     } else
24         return c;
25 }