summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-01-19 14:24:46 +0100
committersijanec <anton@sijanec.eu>2021-01-19 14:24:46 +0100
commit0725d1263f602f2088e3fab29f056231f9677e98 (patch)
tree77884f2ffb895a3afd352073ee05eed5a3172d9f
parentadded while loops, simple intager math (diff)
downloadbverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar.gz
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar.bz2
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar.lz
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar.xz
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.tar.zst
bverbose-0725d1263f602f2088e3fab29f056231f9677e98.zip
Diffstat (limited to '')
-rwxr-xr-xbin/bvr-compose-htmlbin36496 -> 36584 bytes
-rwxr-xr-xbin/bvr-compose-singlebin32224 -> 36400 bytes
-rw-r--r--src/bvrcommands.c26
-rw-r--r--src/tape.c3
-rw-r--r--test/tape-test.bvr7
5 files changed, 34 insertions, 2 deletions
diff --git a/bin/bvr-compose-html b/bin/bvr-compose-html
index a827b0e..bf8e2b0 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 8c0e29b..9c360a2 100755
--- a/bin/bvr-compose-single
+++ b/bin/bvr-compose-single
Binary files differ
diff --git a/src/bvrcommands.c b/src/bvrcommands.c
index a3c5dba..b7d14e3 100644
--- a/src/bvrcommands.c
+++ b/src/bvrcommands.c
@@ -414,6 +414,23 @@ int bvr_handle_while(FILE * input, FILE * output) {
fflush(output);
return return_value;
}
+int bvr_handle_join(FILE * input, FILE * output) {
+ char operation = fgetc(input);
+ int return_value = SUCCESS;
+ char chars_to_break_value[69] = " ";
+ strlcat(chars_to_break_value, BVR_CHARS_TO_BREAK_VALUE, sizeof(chars_to_break_value));
+ char * item = bvr_commands_get_value(input, chars_to_break_value);
+ char * value = bvr_commands_get_value(input, chars_to_break_value);
+ char * stvar1 = bvr_var_get(item);
+ char * stvar2 = bvr_var_get(value);
+ strncat(stvar1, stvar2, (BVR_MAX_VARIABLE_SIZE-strlen(stvar1))-1);
+ return_value = bvr_var_set(item, stvar1);
+ free(item);
+ free(value);
+ item = NULL;
+ value = NULL;
+ return return_value;
+}
int bvr_handle_math(FILE * input, FILE * output) {
char operation = fgetc(input);
int return_value = SUCCESS;
@@ -467,14 +484,21 @@ int bvr_handle_explode(FILE * input, FILE * output) {
char * rest = string1;
char * charpointer;
int index = strlen(item);
+ size_t len = 0;
+ char lenst[69];
item[index++] = '[';
item[index] = '\0';
index = 0;
while ((token = strtok_r(rest, string2, &rest))) {
charpointer = strrchr(item, BVR_ARRAY_INDEX_CHAR);
snprintf(charpointer+1, (BVR_MAX_VARIABLE_SIZE-(charpointer-string1))-4, "%d" BVR_ARRAY_AFTER_INDEX, index++);
- return_value = return_value != SUCCESS ? return_value : bvr_var_set(charpointer, token); // če je bila prej napaka pač ne poskušamo več!
+ return_value = return_value != SUCCESS ? return_value : bvr_var_set(item, token); // če je bila prej napaka pač ne poskušamo več!
+ len++;
}
+ charpointer = strrchr(item, BVR_ARRAY_INDEX_CHAR);
+ snprintf(charpointer+1, (BVR_MAX_VARIABLE_SIZE-(charpointer-string1))-4, "#" BVR_ARRAY_AFTER_INDEX, index++);
+ snprintf(lenst, 69-1, "%lu", len);
+ return_value = return_value != SUCCESS ? return_value : bvr_var_set(item, lenst);
free(item);
free(value);
item = NULL;
diff --git a/src/tape.c b/src/tape.c
index 88d1950..0af7e4c 100644
--- a/src/tape.c
+++ b/src/tape.c
@@ -50,6 +50,9 @@ int bvr_command_processor(FILE * page_source_file, FILE * temp_output_file) {
case 'r': /* ačunanje */
command_handler_output = bvr_handle_math(page_source_file, temp_output_file);
break;
+ case 'j': /* oin */
+ command_handler_output = bvr_handle_join(page_source_file, temp_output_file);
+ break;
case 'b': /* unden */
// fprintf(stderr, "bunden %c\n", command_entered);
command_handler_output = bvr_handle_info(page_source_file, temp_output_file);
diff --git a/test/tape-test.bvr b/test/tape-test.bvr
index eca71eb..27faa11 100644
--- a/test/tape-test.bvr
+++ b/test/tape-test.bvr
@@ -2,10 +2,15 @@
<@?s testing krneki@>
# <@?u -2 -1 ?g testing @>
<@?s branch_name .git/refs/heads/master@>
-<@?s latest_commit ?u 0 -1 ?i ?g branch_name@>
+<@?s latest_commit ?u 0 6 ?i ?g branch_name@>
<@?g latest_commit@>
<@?f ?"1" <@?g ?"he@>llo!"@>@>
<@?s stevilka 12@>
<@?r- stevilka ?"1" @>
<@?g stevilka@>
<@?w stevilka <@<@?r- stevilka ?"1"@><@?g stevilka@>@>@>
+<@?s arraytest this,is,a,test,of,an,array@>
+<@?e arraytest ?","@>
+<@?s stevilka ?g arraytest[#]@>
+<@?w stevilka <@<@?r- stevilka ?"1"@><@?s buf arraytest@><@?j buf ?"["@><@?j buf stevilka@><@?j buf ?"]"@><@?g buf@>=<@?g ?g buf@>@>@>
+