summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xa.outbin0 -> 22544 bytes
-rw-r--r--src/bvr.h4
-rw-r--r--src/bvrcommands.c31
-rw-r--r--test/krnkeni.bvr1
-rw-r--r--test/tape-test.bvr35
-rw-r--r--test/tape-test.c2
-rw-r--r--tmp/output.htm5
7 files changed, 43 insertions, 35 deletions
diff --git a/a.out b/a.out
new file mode 100755
index 0000000..0f4b7d4
--- /dev/null
+++ b/a.out
Binary files differ
diff --git a/src/bvr.h b/src/bvr.h
index 413fe99..0008bef 100644
--- a/src/bvr.h
+++ b/src/bvr.h
@@ -32,4 +32,8 @@ int bvr_bvrvar_first_time_set = 1;
#define BVR_INCLUDE_PATH_VAR_NAME "bvr_include_path"
#define BVR_COMMAND_FILE_EXT ".bvr"
+#define BVR_CONTINUE 1328
+#define BVR_KEEPGOING 132
+
int bvr_compose_stream(FILE *, FILE *);
+int bvr_command_processor(FILE *, FILE *);
diff --git a/src/bvrcommands.c b/src/bvrcommands.c
index 5f58457..2a73abe 100644
--- a/src/bvrcommands.c
+++ b/src/bvrcommands.c
@@ -2,6 +2,22 @@
#include <bvr.h>
#include <tape.c>
#include <bvrvar.c>
+int bvr_commands_check_for_command(char * input_char, char * value, int *i, FILE * input) {
+ if((*input_char) == LINE_COMMAND_CHAR) {
+ FILE * command_return;
+ command_return = fmemopen(value+((*i)++), sizeof(value)-(*i), "w"); // i bajtov smo že napisali.
+ if(bvr_command_processor(input, command_return) != SUCCESS) {
+ fprintf(stderr, "[bvrcommands.c] bvr_commands_check_for_command: command, passed as argument, didn't return success. Going on.\n");
+ }
+ (*i) = (*i)+ftell(command_return);
+ (*input_char) = CLOSING_COMMAND_TAG_CHAR_1; // da zaključimo loop (drugače ostane notri ?)
+ fflush(command_return);
+ fclose(command_return);
+ return BVR_CONTINUE;
+ }
+ return BVR_KEEPGOING;
+}
+
char bvr_var_skip_separator_chars(FILE * input) {
char input_char = fgetc(input);
while(input_char == ' ' || input_char == CLOSING_COMMAND_TAG_CHAR_1 || input_char == ',' || input_char == ';' || input_char == EOF ||
@@ -16,6 +32,9 @@ int bvr_handle_get(FILE * input, FILE * output) {
int i = 0;
while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF &&
input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, item, &i, input) == BVR_CONTINUE) {
+ continue;
+ }
item[i++] = input_char;
input_char = fgetc(input);
}
@@ -31,6 +50,9 @@ int bvr_handle_set(FILE * input, FILE * output) {
int i = 0;
while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF &&
input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, item, &i, input) == BVR_CONTINUE) {
+ continue;
+ }
item[i++] = input_char;
input_char = fgetc(input);
}
@@ -39,6 +61,9 @@ int bvr_handle_set(FILE * input, FILE * output) {
input_char = bvr_var_skip_separator_chars(input);
while(input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF &&
input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, value, &i, input) == BVR_CONTINUE) {
+ continue;
+ }
value[i++] = input_char;
input_char = fgetc(input);
}
@@ -53,6 +78,9 @@ int bvr_handle_include(FILE * input, FILE * output) {
int i = 0;
while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF &&
input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, item, &i, input) == BVR_CONTINUE) {
+ continue;
+ }
item[i++] = input_char;
input_char = fgetc(input);
}
@@ -121,6 +149,9 @@ int bvr_handle_move(FILE * input, FILE * output) {
input_char = bvr_var_skip_separator_chars(input);
while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF &&
input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, value, &i, input) == BVR_CONTINUE) {
+ continue;
+ }
value[i++] = input_char;
input_char = fgetc(input);
}
diff --git a/test/krnkeni.bvr b/test/krnkeni.bvr
new file mode 100644
index 0000000..8c911a9
--- /dev/null
+++ b/test/krnkeni.bvr
@@ -0,0 +1 @@
+krnkeni file inclusion complete
diff --git a/test/tape-test.bvr b/test/tape-test.bvr
index 90a2b2b..2c57f30 100644
--- a/test/tape-test.bvr
+++ b/test/tape-test.bvr
@@ -1,34 +1,3 @@
-# <@?s 123 123@>
-# <@?g 123@>
-# <@?b@>
-# test navadne datoteke brez ukazov
<@?i assets/content/global.bvr @>
-# <@?i krneski @>
-<@?g post_slug @>
-# <@?g bvr_include_path @>
-# <@?i tape-test-to-includes @>
-# <@?g included_variable @>
-# <@?s abc 1232@>
-# <@?g abc@>
-# <@?m abc bbc@>
-# <@?g abc@>
-# <@?g bbc@>
-# hello?
-# <@?g abc@>
-# <@?s abc 123@>
-# <@?g abc@>
-# <@?g abc@>
-# <@?s ab 12@>
-# <@?g ab@>
-# <@?g ab@>
-# <@?s temp Ime mi je Anton Luka@>
-# <@?g temp@>
-# to je komentar in se ne rendera
-# <@?1 post_author@>
-# <@?2 image_caption This is an example image.@>
-# <@?3 sexample.jpg@>
-# <@#?4 image@>
-# <@?5 image@>
-# <@?6 image@>
-# <@?7 image@>
-# in tako so srečno živeli do konca svojih dni!
+<@?s testing krnkeni@>
+<@?i ?g testing@>
diff --git a/test/tape-test.c b/test/tape-test.c
index fc1b2e5..7d0f7df 100644
--- a/test/tape-test.c
+++ b/test/tape-test.c
@@ -3,7 +3,7 @@
#include <tape.c>
extern int main(int argc, char* argv[]) {
if(argc != 3) {
- printf("usage: %s source-file file-with-commands-replaced-with-a's\n", argv[0]);
+ printf("usage: %s source-file destination-file\n", argv[0]);
return 1;
}
// bvr_var_set("abc", "1234");
diff --git a/tmp/output.htm b/tmp/output.htm
index ebc5866..e3fb01c 100644
--- a/tmp/output.htm
+++ b/tmp/output.htm
@@ -18,4 +18,7 @@
-posts/undefined
+
+
+krnkeni file inclusion complete
+