summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-01-05 12:45:49 -0500
committerAdrian Thurston <thurston@complang.org>2013-01-05 12:45:49 -0500
commit6c2d1d95cbf0b13f3de71a5eb4f8e65426fa6a47 (patch)
tree93eda989c574c1048cfb00c8534e4d997ddc1935
parent77d5b90279ce68dd2239e9c95a59bcab61ad2930 (diff)
downloadcolm-6c2d1d95cbf0b13f3de71a5eb4f8e65426fa6a47.tar.gz
towards compositional streams
moved attachStream calls to inside recursive getData calls
-rw-r--r--colm/ctinput.cc4
-rw-r--r--colm/input.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/colm/ctinput.cc b/colm/ctinput.cc
index a10d03f5..bde9f424 100644
--- a/colm/ctinput.cc
+++ b/colm/ctinput.cc
@@ -67,6 +67,8 @@ int inputStreamPatternGetData( FsmRun *fsmRun, StreamImpl *ss, int skip, char *d
PatternItem *buf = ss->patItem;
int offset = ss->offset;
+ attachStream( fsmRun, ss );
+
while ( true ) {
if ( buf == 0 )
return INPUT_EOD;
@@ -242,6 +244,8 @@ int inputStreamConsGetData( FsmRun *fsmRun, StreamImpl *ss, int skip, char *dest
ConsItem *buf = ss->consItem;
int offset = ss->offset;
+ attachStream( fsmRun, ss );
+
while ( true ) {
if ( buf == 0 )
return INPUT_EOD;
diff --git a/colm/input.c b/colm/input.c
index 8ff9f56b..64871979 100644
--- a/colm/input.c
+++ b/colm/input.c
@@ -233,6 +233,8 @@ int fdGetData( FsmRun *fsmRun, StreamImpl *ss, int skip, char *dest, int length,
buf = buf->next;
}
+ attachStream( fsmRun, ss );
+
return ret;
}
@@ -450,6 +452,8 @@ int _getData( FsmRun *fsmRun, StreamImpl *is, int skip, char *dest, int length,
int ret = 0;
*copied = 0;
+ attachStream( fsmRun, is );
+
/* Move over skip bytes. */
RunBuf *buf = is->queue;
while ( true ) {
@@ -463,8 +467,6 @@ int _getData( FsmRun *fsmRun, StreamImpl *is, int skip, char *dest, int length,
Stream *stream = (Stream*)buf->tree;
int type = stream->in->funcs->getData( fsmRun, stream->in, skip, dest, length, copied );
- attachStream( fsmRun, stream->in );
-
if ( type == INPUT_EOD && is->eof ) {
ret = INPUT_EOF;
break;
@@ -514,8 +516,6 @@ int _getData( FsmRun *fsmRun, StreamImpl *is, int skip, char *dest, int length,
buf = buf->next;
}
- attachStream( fsmRun, is );
-
#if DEBUG
switch ( ret ) {
case INPUT_DATA: