summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-07-13 09:59:05 +0800
committerAdrian Thurston <thurston@colm.net>2018-07-13 09:59:05 +0800
commit62007044d100c310a5f293e96e9376957cb38588 (patch)
tree6eda1eb6a1087d6225bdba3e579512690da2ba05 /src/input.c
parent6cd5ad2ab54bfef99a8372c8de34a58ea5184754 (diff)
downloadcolm-62007044d100c310a5f293e96e9376957cb38588.tar.gz
delegate splitting to the stream_impl class
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/input.c b/src/input.c
index a404b788..c6026328 100644
--- a/src/input.c
+++ b/src/input.c
@@ -110,24 +110,22 @@ static struct seq_buf *input_stream_pop_stash( struct colm_program *prg, struct
return seq_buf;
}
-
-static void maybe_split( struct colm_program *prg, struct input_impl_seq *si )
+static void maybe_split( struct colm_program *prg, struct input_impl_seq *iis )
{
- if ( si->queue.head != 0 && is_stream( si->queue.head ) ) {
-
- /* NOT A GOOD IDEA. Use func instead */
- struct stream_impl_data *sid = (struct stream_impl_data*)si->queue.head->si;
- if ( sid->consumed > 0 ) {
+ struct seq_buf *head = iis->queue.head;
+ if ( head != 0 && is_stream( head ) ) {
+ /* Maybe the stream will split itself off. */
+ struct stream_impl *split_off = head->si->funcs->split_consumed( prg, head->si );
+
+ if ( split_off != 0 ) {
debug( prg, REALM_INPUT, "maybe split: consumed is > 0, splitting\n" );
- struct stream_impl *sub_si = colm_impl_consumed( "<text>", sid->consumed );
- sid->consumed = 0;
struct seq_buf *new_buf = new_seq_buf();
new_buf->type = SB_ACCUM;
- new_buf->si = sub_si;
+ new_buf->si = split_off;
new_buf->own_si = 1;
- input_stream_stash_head( prg, si, new_buf );
+ input_stream_stash_head( prg, iis, new_buf );
}
}
}