diff options
author | Adrian Thurston <thurston@complang.org> | 2012-12-31 16:43:08 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2012-12-31 16:43:08 -0500 |
commit | 9c9509f6e6ad70277322e002b6fa7b4bf06c73e5 (patch) | |
tree | 1c31517f9c1efeeafa0079980d75abe3ce6f2dc1 /colm/tree.c | |
parent | c6e716adc4a646824715536741ea55aa89a44c5a (diff) | |
download | colm-9c9509f6e6ad70277322e002b6fa7b4bf06c73e5.tar.gz |
removed file and fd from Stream struct, it is in the StreamImpl class
Diffstat (limited to 'colm/tree.c')
-rw-r--r-- | colm/tree.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/colm/tree.c b/colm/tree.c index 7ed3d5d0..df409cc8 100644 --- a/colm/tree.c +++ b/colm/tree.c @@ -234,7 +234,6 @@ Stream *openStreamFile( Program *prg, FILE *file ) { Stream *res = (Stream*)mapElAllocate( prg ); res->id = LEL_ID_STREAM; - res->file = file; res->in = newSourceStreamFile( file ); initSourceStream( res->in ); return res; @@ -244,7 +243,6 @@ Stream *openStreamFd( Program *prg, long fd ) { Stream *res = (Stream*)mapElAllocate( prg ); res->id = LEL_ID_STREAM; - res->fd = fd; res->in = newSourceStreamFd( fd ); initSourceStream( res->in ); return res; @@ -1072,8 +1070,10 @@ free_tree: Stream *stream = (Stream*)tree; clearSourceStream( prg, sp, stream->in ); free( stream->in ); - if ( stream->file != 0 ) - fclose( stream->file ); + if ( stream->in->file != 0 ) + fclose( stream->in->file ); + else + close( stream->in->fd ); streamFree( prg, stream ); } else if ( tree->id == LEL_ID_INPUT ) { @@ -2373,7 +2373,7 @@ void printTermTree( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Ki else if ( kid->tree->id == LEL_ID_STREAM ) { char buf[INT_SZ]; printArgs->out( printArgs, "#", 1 ); - sprintf( buf, "%p", (void*) ((Stream*)kid->tree)->file ); + sprintf( buf, "%p", (void*) ((Stream*)kid->tree)->in->file ); printArgs->out( printArgs, buf, strlen(buf) ); } else if ( kid->tree->tokdata != 0 && |