summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xa.outbin17000 -> 17036 bytes
-rw-r--r--src/tape.c46
-rw-r--r--test/tape-test.bvr2
-rw-r--r--tmp/output.htm11
4 files changed, 30 insertions, 29 deletions
diff --git a/a.out b/a.out
index a79367d..e9a6c8e 100755
--- a/a.out
+++ b/a.out
Binary files differ
diff --git a/src/tape.c b/src/tape.c
index 5bbec7d..5c574fb 100644
--- a/src/tape.c
+++ b/src/tape.c
@@ -92,38 +92,29 @@ int bvr_inline_command_processor(FILE * page_source_file, FILE * output_file, ch
copy_buffer[(ftell(page_source_file)% COPY_BUFFER_SIZE)] = fgetc(page_source_file); // remove closing command tag character
return what_to_return;
}
-
-int bvr_compose_page(char page_source_file_path[], int this_is_a_top_level_page, char * temp_output_path) {
- if(temp_output_path != NULL) {
- char * temp_output_filename = randstring(16);
- char temp_output_path[80] = "tmp/";
- strcat(temp_output_path, temp_output_filename);
- }
+int bvr_compose_stream(FILE * page_source_file, FILE * temp_output_file) {
char copy_buffer[COPY_BUFFER_SIZE];
- FILE * temp_output_file = fopen_mkdir(temp_output_path, "w");
- FILE * page_source_file = fopen(page_source_file_path, "r");
-
- for(int i = 0; i < sizeof(copy_buffer); i++) { // da garbage vrednosti ne bodo slučajno ukazi! --- useless!, todo: delete
- copy_buffer[i] = ' ';
- }
- 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;
+ for(int i = 0; i < sizeof(copy_buffer); i++) { // da garbage vrednosti ne bodo slučajno ukazi!
+ copy_buffer[i] = '\n';
}
+ // 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;
+ // }
while (1) {
copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file);
if(copy_buffer[(ftell(page_source_file)-1)% COPY_BUFFER_SIZE] == OPENING_COMMAND_TAG_CHAR_1 &&
copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] == OPENING_COMMAND_TAG_CHAR_2) {
if(bvr_inline_command_processor(page_source_file, temp_output_file, copy_buffer) == FAILURE) {
- fprintf(temp_output_file, "\nbvr_inline_command_processor returned an error status whilst composing %s\n", page_source_file_path);
- fprintf(stderr, "[tape.c] bvr_inline_command_processor returned an error status whilst composing %s\n", page_source_file_path);
+ fprintf(temp_output_file, "\nbvr_inline_command_processor returned an error status.\n");
+ fprintf(stderr, "[tape.c] bvr_inline_command_processor returned an error status.\n");
}
copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file); // remove last > that just wants to be there... OB1
continue;
}
if(copy_buffer[(ftell(page_source_file)-1)% COPY_BUFFER_SIZE] == '\n' && copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] == LINE_COMMENT_CHAR) {
- copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file); // idk, OB1 is a bitch
- while(copy_buffer[(ftell(page_source_file)-1)% COPY_BUFFER_SIZE] != '\n') { // idk, OB1 is a bitch
+ // copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file); // idk, OB1 is a bitch
+ while(copy_buffer[(ftell(page_source_file)-0)% COPY_BUFFER_SIZE] != '\n') { // idk, OB1 is a bitch
copy_buffer[ftell(page_source_file)% COPY_BUFFER_SIZE] = fgetc(page_source_file); // idk, OB1 is a bitch
}
continue;
@@ -141,6 +132,21 @@ int bvr_compose_page(char page_source_file_path[], int this_is_a_top_level_page,
}
fputc(copy_buffer[(ftell(page_source_file)-1)% COPY_BUFFER_SIZE], temp_output_file);
}
+ return SUCCESS;
+}
+
+int bvr_compose_page(char page_source_file_path[], int this_is_a_top_level_page, char * temp_output_path) {
+ if(temp_output_path != NULL) {
+ char * temp_output_filename = randstring(16);
+ char temp_output_path[80] = "tmp/";
+ strcat(temp_output_path, temp_output_filename);
+ }
+ FILE * temp_output_file = fopen_mkdir(temp_output_path, "w");
+ FILE * page_source_file = fopen(page_source_file_path, "r");
+ if(bvr_compose_stream(page_source_file, temp_output_file) != SUCCESS) {
+ fprintf(stderr, "[tape.c] bvr_compose_page: bvr_compose_stream returned a non-successful response whilst composing %s. Nevertheless, we are continuing.\n",
+ page_source_file_path);
+ }
done_reading_write_file:
diff --git a/test/tape-test.bvr b/test/tape-test.bvr
index 525cccf..fbed8d3 100644
--- a/test/tape-test.bvr
+++ b/test/tape-test.bvr
@@ -3,7 +3,7 @@
<@?m abc bbc@>
<@?g abc@>
<@?g bbc@>
-
+hello?
# <@?g abc@>
# <@?s abc 123@>
# <@?g abc@>
diff --git a/tmp/output.htm b/tmp/output.htm
index ce4890d..a2d7bed 100644
--- a/tmp/output.htm
+++ b/tmp/output.htm
@@ -1,13 +1,8 @@
-1232
-command handler for m with argument "abc bbc" returned an error code.
-
-bvr_inline_command_processor returned an error status whilst composing test/tape-test.bvr
1232
+
BVR_UNDEFINED
-# # 123# BVR_UNDEFINED# # to je komentar in se ne rendera#
-bVerbose unknown command 2
-# #
-bVerbose unknown command 6
+1232
+hello?
in tako so srečno živeli do konca svojih dni!