From 3280a6ae3077e35cde9a429b4fb566a07c6a31c7 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Mon, 28 Jan 2013 21:45:07 -0500 Subject: removed the attach/detach calls Still need a clearBuffered call in the undoConsume, not entirely sure why. --- colm/ctinput.cc | 4 ---- colm/input.c | 34 ++-------------------------------- colm/input.h | 1 - colm/pdarun.c | 27 --------------------------- colm/pdarun.h | 3 --- 5 files changed, 2 insertions(+), 67 deletions(-) diff --git a/colm/ctinput.cc b/colm/ctinput.cc index bde9f424..a10d03f5 100644 --- a/colm/ctinput.cc +++ b/colm/ctinput.cc @@ -67,8 +67,6 @@ 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; @@ -244,8 +242,6 @@ 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 ba144d94..bad36f2b 100644 --- a/colm/input.c +++ b/colm/input.c @@ -233,8 +233,6 @@ int fdGetData( FsmRun *fsmRun, StreamImpl *ss, int skip, char *dest, int length, buf = buf->next; } - attachStream( fsmRun, ss ); - return ret; } @@ -452,8 +450,6 @@ 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 ) { @@ -596,8 +592,7 @@ int _undoConsumeData( FsmRun *fsmRun, StreamImpl *is, const char *data, int leng Stream *stream = (Stream*)is->queue->tree; int len = stream->in->funcs->undoConsumeData( fsmRun, stream->in, data, length ); - if ( stream->in->attached != 0 ) - detachStream( stream->in->attached, stream->in ); + clearBuffered( fsmRun ); return len; } @@ -607,8 +602,7 @@ int _undoConsumeData( FsmRun *fsmRun, StreamImpl *is, const char *data, int leng memcpy( newBuf->data, data, length ); inputStreamPrepend( is, newBuf ); - if ( is->attached != 0 ) - detachStream( is->attached, is ); + clearBuffered( fsmRun ); return length; } @@ -635,9 +629,6 @@ Tree *_consumeTree( StreamImpl *is ) void _undoConsumeTree( StreamImpl *is, Tree *tree, int ignore ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - /* Create a new buffer for the data. This is the easy implementation. * Something better is needed here. It puts a max on the amount of * data that can be pushed back to the inputStream. */ @@ -671,9 +662,6 @@ void _undoConsumeLangEl( StreamImpl *is ) void _prependData( StreamImpl *is, const char *data, long length ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - if ( isSourceStream( is ) && ((Stream*)is->queue->tree)->in->funcs == &streamFuncs ) { Stream *stream = (Stream*)is->queue->tree; @@ -695,9 +683,6 @@ void _prependData( StreamImpl *is, const char *data, long length ) void _prependTree( StreamImpl *is, Tree *tree, int ignore ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - /* Create a new buffer for the data. This is the easy implementation. * Something better is needed here. It puts a max on the amount of * data that can be pushed back to the inputStream. */ @@ -720,9 +705,6 @@ void _prependStream( StreamImpl *in, struct ColmTree *tree ) int _undoPrependData( StreamImpl *is, int length ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - debug( REALM_INPUT, "consuming %d bytes\n", length ); int consumed = 0; @@ -769,9 +751,6 @@ int _undoPrependData( StreamImpl *is, int length ) Tree *_undoPrependTree( StreamImpl *is ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - while ( is->queue != 0 && is->queue->type == RunBufDataType && is->queue->offset == is->queue->length ) { RunBuf *runBuf = inputStreamPopHead( is ); free( runBuf ); @@ -809,9 +788,6 @@ void _appendData( StreamImpl *is, const char *data, long len ) Tree *_undoAppendData( StreamImpl *is, int length ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - int consumed = 0; /* Move over skip bytes. */ @@ -871,9 +847,6 @@ void _appendStream( StreamImpl *in, struct ColmTree *tree ) Tree *_undoAppendStream( StreamImpl *is ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - RunBuf *runBuf = inputStreamPopTail( is ); Tree *tree = runBuf->tree; free( runBuf ); @@ -882,9 +855,6 @@ Tree *_undoAppendStream( StreamImpl *is ) Tree *_undoAppendTree( StreamImpl *is ) { - if ( is->attached != 0 ) - detachStream( is->attached, is ); - RunBuf *runBuf = inputStreamPopTail( is ); Tree *tree = runBuf->tree; free( runBuf ); diff --git a/colm/input.h b/colm/input.h index 3bfc43c5..0da468a1 100644 --- a/colm/input.h +++ b/colm/input.h @@ -127,7 +127,6 @@ struct StreamFuncs struct _StreamImpl { struct StreamFuncs *funcs; - struct _FsmRun *attached; char eofSent; char eof; diff --git a/colm/pdarun.c b/colm/pdarun.c index f762689d..6983589a 100644 --- a/colm/pdarun.c +++ b/colm/pdarun.c @@ -251,33 +251,6 @@ static void sendBackIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsm } } -void attachStream( FsmRun *fsmRun, StreamImpl *is ) -{ - if ( is->attached != 0 && is->attached != fsmRun ) - detachStream( is->attached, is ); - - if ( is->attached != fsmRun ) { - debug( REALM_INPUT, "attaching FsmRun to stream: %p %p\n", fsmRun, is ); - is->attached = fsmRun; - } -} - -void detachStream( FsmRun *fsmRun, StreamImpl *is ) -{ - debug( REALM_INPUT, "detaching FsmRun from stream: %p %p\n", fsmRun, is ); - - is->attached = 0; - clearBuffered( fsmRun ); -} - -void detachSource( FsmRun *fsmRun, StreamImpl *is ) -{ - debug( REALM_INPUT, "detaching fsm run from source stream: %p %p\n", fsmRun, is ); - - is->attached = 0; - clearBuffered( fsmRun ); -} - void clearBuffered( FsmRun *fsmRun ) { if ( fsmRun->tokstart != 0 ) { diff --git a/colm/pdarun.h b/colm/pdarun.h index 67e55dbb..81d376c4 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -462,9 +462,6 @@ void undoParseStream( struct ColmProgram *prg, Tree **sp, StreamImpl *inputStrea void clearBuffered( FsmRun *fsmRun ); void resetToken( FsmRun *fsmRun ); -void detachStream( FsmRun *fsmRun, StreamImpl *is ); -void attachStream( FsmRun *fsmRun, StreamImpl *is ); - #ifdef __cplusplus } #endif -- cgit v1.2.1