From 1006e7fb17e31ea501eca6834253d288c2f6da59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 9 Jun 2020 17:31:19 +0200 Subject: fix --- bin/bvr-compose-html | Bin 31936 -> 31984 bytes bin/bvr-compose-single | Bin 31792 -> 31840 bytes src/bvr.h | 4 ++++ src/bvrcommands.c | 8 +++++++- src/tape.c | 13 ++++++++----- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bin/bvr-compose-html b/bin/bvr-compose-html index 6f5bcb4..505c2ec 100755 Binary files a/bin/bvr-compose-html and b/bin/bvr-compose-html differ diff --git a/bin/bvr-compose-single b/bin/bvr-compose-single index 50eb2ab..5500b8f 100755 Binary files a/bin/bvr-compose-single and b/bin/bvr-compose-single differ diff --git a/src/bvr.h b/src/bvr.h index 82187cd..27ae526 100644 --- a/src/bvr.h +++ b/src/bvr.h @@ -5,6 +5,7 @@ #define SUCCESS 0 #define FAILURE -1 #define COPY_BUFFER_SIZE 128 +#define BVR_COPY_BUFFER_SIZE COPY_BUFFER_SIZE #define OPENING_COMMAND_TAG_LENGTH 2 #define OPENING_COMMAND_TAG_CHAR_1 '<' #define OPENING_COMMAND_TAG_CHAR_2 '@' @@ -49,3 +50,6 @@ int bvr_command_processor(FILE *, FILE *); #define BVR_ESCAPE_CHAR '\\' #define BVR_NEWLINE_CHAR '\n' + +int init_tape_copy_buffer(char [], int); +int bvr_inline_command_processor(FILE *, FILE *, char []); diff --git a/src/bvrcommands.c b/src/bvrcommands.c index 75a5967..3468d98 100644 --- a/src/bvrcommands.c +++ b/src/bvrcommands.c @@ -292,7 +292,13 @@ int bvr_handle_if(FILE * input, FILE * output) { // ?f 1 <@this is all executed@ char * item = bvr_commands_get_value(input, chars_to_break_value); int return_value = 0; if(strcmp(bvr_var_get(item), "1") == 0) { - return_value = bvr_compose_stream(input, output); + char chars_to_break_value[3] = {OPENING_COMMAND_TAG_CHAR_2, EOF, '\0'}; + char * temp = bvr_commands_get_value(input, chars_to_break_value); + free(temp); + temp = NULL; + char copy_buffer[BVR_COPY_BUFFER_SIZE]; + init_tape_copy_buffer(copy_buffer, COPY_BUFFER_SIZE); + return_value = bvr_inline_command_processor(input, output, copy_buffer); } else { char input_char = fgetc(input); char previous_char = 'a'; diff --git a/src/tape.c b/src/tape.c index 442ba53..0492313 100644 --- a/src/tape.c +++ b/src/tape.c @@ -93,13 +93,16 @@ int bvr_inline_command_processor(FILE * page_source_file, FILE * output_file, ch return what_to_return; } -int bvr_compose_stream(FILE * page_source_file, FILE * temp_output_file) { - char copy_buffer[COPY_BUFFER_SIZE]; - int cycles = 0; - for(int i = 0; i < sizeof(copy_buffer); i++) { // da garbage vrednosti ne bodo slučajno ukazi! - copy_buffer[i] = '\n'; // čeprav OS verjetno nastavi ram na \0\0\0\0\0\0 preden ga da procesu +int init_tape_copy_buffer(char copy_buffer[], int buffer_size) { + for(int i = 0; i