summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-12-31 16:43:08 -0500
committerAdrian Thurston <thurston@complang.org>2012-12-31 16:43:08 -0500
commit9c9509f6e6ad70277322e002b6fa7b4bf06c73e5 (patch)
tree1c31517f9c1efeeafa0079980d75abe3ce6f2dc1
parentc6e716adc4a646824715536741ea55aa89a44c5a (diff)
downloadcolm-9c9509f6e6ad70277322e002b6fa7b4bf06c73e5.tar.gz
removed file and fd from Stream struct, it is in the StreamImpl class
-rw-r--r--colm/bytecode.c6
-rw-r--r--colm/tree.c10
-rw-r--r--colm/tree.h2
3 files changed, 8 insertions, 10 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index ac0a8b04..cb8001ab 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -946,10 +946,10 @@ again:
Stream *stream = (Stream*)vm_pop();
while ( n-- > 0 ) {
Tree *tree = vm_pop();
- if ( stream->file != 0 )
- printTreeFile( prg, sp, stream->file, tree, true );
+ if ( stream->in->file != 0 )
+ printTreeFile( prg, sp, stream->in->file, tree, true );
else
- printTreeFd( prg, sp, stream->fd, tree, true );
+ printTreeFd( prg, sp, stream->in->fd, tree, true );
treeDownref( prg, sp, tree );
}
treeDownref( prg, sp, (Tree*)stream );
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 &&
diff --git a/colm/tree.h b/colm/tree.h
index 1c442ad7..2a117171 100644
--- a/colm/tree.h
+++ b/colm/tree.h
@@ -189,8 +189,6 @@ typedef struct _Stream
long refs;
Kid *child;
- FILE *file;
- int fd;
StreamImpl *in;
} Stream;