summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-15 14:33:43 +0200
committerAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-15 14:33:43 +0200
commit8e6dea6ac1efe566387e0a6fc113a5f8d95af231 (patch)
tree17424d98487426689171963e29411e812d52b00b /src
parentjsbundle alphabetical order (diff)
downloadbverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar.gz
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar.bz2
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar.lz
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar.xz
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.tar.zst
bverbose-8e6dea6ac1efe566387e0a6fc113a5f8d95af231.zip
Diffstat (limited to 'src')
-rw-r--r--src/bvr.h4
-rw-r--r--src/bvrcommands.c31
2 files changed, 35 insertions, 0 deletions
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);
}