diff options
author | Adrian Thurston <thurston@colm.net> | 2019-05-22 18:51:58 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2019-05-22 18:51:58 -0400 |
commit | 11bcbbea88466f75990314f58dcc66cbf76ab75b (patch) | |
tree | dd74b0a9a1b8e2ab59a178983564f5032655fd4b /src/stream.c | |
parent | eebed98e759b328f0f0e8ef2fd0afe8f2adf2720 (diff) | |
download | colm-11bcbbea88466f75990314f58dcc66cbf76ab75b.tar.gz |
added and auto_trim flag to stream anad input
When set to true, all tree prints to the stream or sends to the input will
result in a trim. Achieved by passing trim to the generic print.
Diffstat (limited to 'src/stream.c')
-rw-r--r-- | src/stream.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/stream.c b/src/stream.c index ca6e3641..56ea3612 100644 --- a/src/stream.c +++ b/src/stream.c @@ -390,13 +390,18 @@ static void data_close_stream( struct colm_program *prg, struct stream_impl_data } } +static void data_auto_trim( struct colm_program *prg, struct stream_impl_data *si, int auto_trim ) +{ + si->auto_trim = auto_trim ? 1 : 0; +} + static void data_print_tree( struct colm_program *prg, tree_t **sp, struct stream_impl_data *si, tree_t *tree, int trim ) { if ( si->file != 0 ) - colm_print_tree_file( prg, sp, (struct stream_impl*)si, tree, false ); + colm_print_tree_file( prg, sp, (struct stream_impl*)si, tree, si->auto_trim ); else if ( si->collect != 0 ) - colm_print_tree_collect( prg, sp, si->collect, tree, false ); + colm_print_tree_collect( prg, sp, si->collect, tree, si->auto_trim ); } static int data_get_parse_block( struct colm_program *prg, struct stream_impl_data *ss, int *pskip, char **pdp, int *copied ) @@ -593,7 +598,9 @@ struct stream_funcs_data file_funcs = &data_get_collect, &data_flush_stream, &data_close_stream, + &data_auto_trim, &data_print_tree, + &data_split_consumed, &data_append_data, &data_undo_append_data, @@ -613,6 +620,7 @@ struct stream_funcs_data accum_funcs = &data_get_collect, &data_flush_stream, &data_close_stream, + &data_auto_trim, &data_print_tree, &data_split_consumed, |