summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/bvr-compose-htmlbin31936 -> 31984 bytes
-rwxr-xr-xbin/bvr-compose-singlebin31792 -> 31840 bytes
-rw-r--r--src/bvr.h4
-rw-r--r--src/bvrcommands.c8
-rw-r--r--src/tape.c13
5 files changed, 19 insertions, 6 deletions
diff --git a/bin/bvr-compose-html b/bin/bvr-compose-html
index 6f5bcb4..505c2ec 100755
--- a/bin/bvr-compose-html
+++ b/bin/bvr-compose-html
Binary files differ
diff --git a/bin/bvr-compose-single b/bin/bvr-compose-single
index 50eb2ab..5500b8f 100755
--- a/bin/bvr-compose-single
+++ b/bin/bvr-compose-single
Binary files 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 <buffer_size; 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
} // ampak kaj pa, ko funkcijo zaženemo drugič, pointer bo kazal na isto mesto! // nočemo \0
+}
+int bvr_compose_stream(FILE * page_source_file, FILE * temp_output_file) {
+ int cycles = 0;
+ char copy_buffer[COPY_BUFFER_SIZE];
+ init_tape_copy_buffer(copy_buffer, COPY_BUFFER_SIZE);
// copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file);
// if(copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] == EOF) {
// goto done_reading_write_file;