summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-15 15:21:23 +0200
committerAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-15 15:21:23 +0200
commita9fae18d69cd07ddd48df5fbda20432725129cfd (patch)
treee3bc9102d6f8fb5794874df6e884926729377850
parenttesting (diff)
downloadbverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar.gz
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar.bz2
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar.lz
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar.xz
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.tar.zst
bverbose-a9fae18d69cd07ddd48df5fbda20432725129cfd.zip
Diffstat (limited to '')
-rwxr-xr-xa.outbin22544 -> 22552 bytes
-rw-r--r--src/bvrcommands.c46
-rw-r--r--test/krnkeni.bvr2
-rw-r--r--test/tape-test.bvr3
-rw-r--r--tmp/output.htm3
5 files changed, 36 insertions, 18 deletions
diff --git a/a.out b/a.out
index 0f4b7d4..80970bc 100755
--- a/a.out
+++ b/a.out
Binary files differ
diff --git a/src/bvrcommands.c b/src/bvrcommands.c
index 2a73abe..b040d46 100644
--- a/src/bvrcommands.c
+++ b/src/bvrcommands.c
@@ -2,17 +2,27 @@
#include <bvr.h>
#include <tape.c>
#include <bvrvar.c>
-int bvr_commands_check_for_command(char * input_char, char * value, int *i, FILE * input) {
+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.
+ size_t buf_size;
+ command_return = open_memstream(&(*value)+((*i)++), &buf_size); // 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);
+ fflush(command_return);
+ // fprintf(stderr, "debug: \"%s\"\n", (*value)+((*i)-1));
+ // fprintf(stderr, "debug: \"%s\"\n", (*value));
+ // fprintf(stderr, "debug: \"%d\"\n", (*i));
+ // fprintf(stderr, "debug: \"%ld\"\n", (buf_size));
+ (*i) = (*i)+buf_size;
+ // fprintf(stderr, "debug: \"%d\"\n", (*i));
(*input_char) = CLOSING_COMMAND_TAG_CHAR_1; // da zaključimo loop (drugače ostane notri ?)
+ //\\ zelo slabo. znak, ki ga najde izveden ukaz, se izgubi. rešitev bi bila dobiti zadnji input char, ki triggera break
+ // prejšnjega ukaza, kar pa je nemogoče.
fflush(command_return);
fclose(command_return);
+ // fprintf(stderr, "debug: \"%s\"\n", (*value));
return BVR_CONTINUE;
}
return BVR_KEEPGOING;
@@ -27,12 +37,12 @@ char bvr_var_skip_separator_chars(FILE * input) {
return input_char;
}
int bvr_handle_get(FILE * input, FILE * output) {
- char item[BVR_MAX_VARIABLE_SIZE+1];
+ char * item = (char*) malloc(BVR_MAX_VARIABLE_SIZE+1);
char input_char = bvr_var_skip_separator_chars(input);
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) {
+ if(bvr_commands_check_for_command(&input_char, &item, &i, input) == BVR_CONTINUE) {
continue;
}
item[i++] = input_char;
@@ -44,13 +54,13 @@ int bvr_handle_get(FILE * input, FILE * output) {
return SUCCESS;
}
int bvr_handle_set(FILE * input, FILE * output) {
- char item[BVR_MAX_VARIABLE_SIZE+1];
- char value[BVR_MAX_VARIABLE_SIZE+1];
+ char * item = (char *) malloc(BVR_MAX_VARIABLE_SIZE+1);
+ char * value = (char *) malloc(BVR_MAX_VARIABLE_SIZE+1);
char input_char = bvr_var_skip_separator_chars(input);
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) {
+ if(bvr_commands_check_for_command(&input_char, &item, &i, input) == BVR_CONTINUE) {
continue;
}
item[i++] = input_char;
@@ -60,25 +70,28 @@ int bvr_handle_set(FILE * input, FILE * output) {
i = 0;
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) {
+ input_char != '\0' && i < BVR_MAX_VARIABLE_SIZE) {
+ if(bvr_commands_check_for_command(&input_char, &value, &i, input) == BVR_CONTINUE) {
+ // fprintf(stderr, "debug3: \"%s\"\n", value);
continue;
}
value[i++] = input_char;
input_char = fgetc(input);
}
value[i++] = '\0';
+ // fprintf(stderr, "debug2: \"%s\"\n", value);
+ // fprintf(stderr, "debug2: \"%d\"\n", i);
return bvr_var_set(item, value);
fflush(output);
return SUCCESS;
}
int bvr_handle_include(FILE * input, FILE * output) {
- char item[BVR_MAX_VARIABLE_SIZE+1];
+ char * item = (char *) malloc(BVR_MAX_VARIABLE_SIZE+1);
char input_char = bvr_var_skip_separator_chars(input);
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) {
+ if(bvr_commands_check_for_command(&input_char, &item, &i, input) == BVR_CONTINUE) {
continue;
}
item[i++] = input_char;
@@ -135,12 +148,15 @@ int bvr_handle_include(FILE * input, FILE * output) {
fflush(output);
}
int bvr_handle_move(FILE * input, FILE * output) {
- char item[BVR_MAX_VARIABLE_SIZE+1];
- char value[BVR_MAX_VARIABLE_SIZE+1];
+ char * item = (char *) malloc(BVR_MAX_VARIABLE_SIZE+1);
+ char * value = (char *) malloc(BVR_MAX_VARIABLE_SIZE+1);
char input_char = bvr_var_skip_separator_chars(input);
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);
}
@@ -149,7 +165,7 @@ 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) {
+ if(bvr_commands_check_for_command(&input_char, &value, &i, input) == BVR_CONTINUE) {
continue;
}
value[i++] = input_char;
diff --git a/test/krnkeni.bvr b/test/krnkeni.bvr
index 8c911a9..aa7bfe1 100644
--- a/test/krnkeni.bvr
+++ b/test/krnkeni.bvr
@@ -1 +1 @@
-krnkeni file inclusion complete
+69krnkeni file inclusion complete
diff --git a/test/tape-test.bvr b/test/tape-test.bvr
index 2c57f30..0ae5679 100644
--- a/test/tape-test.bvr
+++ b/test/tape-test.bvr
@@ -1,3 +1,4 @@
<@?i assets/content/global.bvr @>
<@?s testing krnkeni@>
-<@?i ?g testing@>
+<@?s abcdefghijklmnopr ?i krnkeni@>
+<@?g abcdefghijklmnopr@>
diff --git a/tmp/output.htm b/tmp/output.htm
index e3fb01c..5948d6a 100644
--- a/tmp/output.htm
+++ b/tmp/output.htm
@@ -20,5 +20,6 @@
-krnkeni file inclusion complete
+
+69krnkeni file inclusion complete