summaryrefslogtreecommitdiff
path: root/ghc/lib/cbits/fileLookAhead.lc
blob: df0d332ca72b98c69dd220c62116ab7536fdd29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%
% (c) The GRASP/AQUA Project, Glasgow University, 1994
%
\subsection[fileLookAhead.lc]{hLookAhead Runtime Support}

\begin{code}

#include "rtsdefs.h"
#include "stgio.h"

StgInt
fileLookAhead(fp)
StgAddr fp;
{
    int c;

    if ((c = fileGetc(fp)) == EOF) {
	return c;
    } else if (ungetc(c, (FILE *) fp) == EOF) {
	cvtErrno();
	stdErrno();
	return EOF;
    } else
	return c;
}

\end{code}