summaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-05-22 18:51:58 -0400
committerAdrian Thurston <thurston@colm.net>2019-05-22 18:51:58 -0400
commit11bcbbea88466f75990314f58dcc66cbf76ab75b (patch)
treedd74b0a9a1b8e2ab59a178983564f5032655fd4b /src/bytecode.c
parenteebed98e759b328f0f0e8ef2fd0afe8f2adf2720 (diff)
downloadcolm-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/bytecode.c')
-rw-r--r--src/bytecode.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index ee238b31..fbb94646 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -212,7 +212,7 @@ static word_t stream_append_text( program_t *prg, tree_t **sp, input_t *dest, tr
/* Collect the tree data. */
str_collect_t collect;
init_str_collect( &collect );
- colm_print_tree_collect( prg, sp, &collect, input, false );
+ colm_print_tree_collect( prg, sp, &collect, input, ((struct input_impl_seq*)impl)->auto_trim );
/* Load it into the input. */
impl->funcs->append_data( prg, impl, collect.data, collect.length );
@@ -2510,6 +2510,30 @@ again:
vm_push_stream( stream );
break;
}
+ case IN_INPUT_AUTO_TRIM_WC: {
+ debug( prg, REALM_BYTECODE, "IN_INPUT_AUTO_TRIM_WC\n" );
+
+ stream_t *stream = vm_pop_stream();
+ value_t auto_trim = vm_pop_value();
+ struct stream_impl *si = stream->impl;
+
+ si->funcs->auto_trim( prg, si, (long) auto_trim );
+
+ vm_push_stream( stream );
+ break;
+ }
+ case IN_IINPUT_AUTO_TRIM_WC: {
+ debug( prg, REALM_BYTECODE, "IN_INPUT_AUTO_TRIM_WC\n" );
+
+ input_t *input = vm_pop_input();
+ value_t auto_trim = vm_pop_value();
+ struct input_impl *ii = input->impl;
+
+ ii->funcs->auto_trim( prg, ii, (long) auto_trim );
+
+ vm_push_input( input );
+ break;
+ }
case IN_SET_ERROR: {
debug( prg, REALM_BYTECODE, "IN_SET_ERROR\n" );