diff options
author | Adrian Thurston <thurston@complang.org> | 2012-12-30 11:35:26 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2012-12-30 11:35:26 -0500 |
commit | b68e349beb80362e185ebfd934cb9c47be15aa51 (patch) | |
tree | b4edac727cc3b9a5dcac46b7fccf04956dc4bc44 /colm/input.c | |
parent | 2d1b2dc9afb909ccf3ab9dcc91a3ad38ebbbb03c (diff) | |
download | colm-b68e349beb80362e185ebfd934cb9c47be15aa51.tar.gz |
track eof in fd-backed source stream
Track an EOF bit in the fd-backed source stream. Don't call read on an FD that
has already returned EOF. Allows ^D to work.
Diffstat (limited to 'colm/input.c')
-rw-r--r-- | colm/input.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/colm/input.c b/colm/input.c index 787a728d..a5c42806 100644 --- a/colm/input.c +++ b/colm/input.c @@ -290,8 +290,14 @@ void initFileFuncs() int fdGetDataImpl( SourceStream *is, char *dest, int length ) { - long got = read( is->fd, dest, length ); - return got; + if ( is->eof ) + return 0; + else { + long got = read( is->fd, dest, length ); + if ( got == 0 ) + is->eof = true; + return got; + } } void initFdFuncs() |