summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-01-19 15:26:05 +0100
committersijanec <anton@sijanec.eu>2021-01-19 15:26:05 +0100
commit69c8904b2d9a325ab2a8f71c28cbaa34bb830887 (patch)
treea174c437024abb58c8af438281cf24891765c4f6
parentdodal arraye (diff)
downloadbverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar.gz
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar.bz2
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar.lz
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar.xz
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.tar.zst
bverbose-69c8904b2d9a325ab2a8f71c28cbaa34bb830887.zip
Diffstat (limited to '')
-rwxr-xr-xbin/bvr-compose-htmlbin36584 -> 36672 bytes
-rwxr-xr-xbin/bvr-compose-singlebin36400 -> 36528 bytes
-rw-r--r--src/bvrcommands.c100
-rw-r--r--test/tape-test.bvr10
4 files changed, 68 insertions, 42 deletions
diff --git a/bin/bvr-compose-html b/bin/bvr-compose-html
index bf8e2b0..afd91ab 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 9c360a2..954c306 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 b7d14e3..a44954f 100644
--- a/src/bvrcommands.c
+++ b/src/bvrcommands.c
@@ -180,56 +180,82 @@ int bvr_handle_set(FILE * input, FILE * output) {
int bvr_handle_include(FILE * input, FILE * output) {
char chars_to_break_value[69] = " ";
strlcat(chars_to_break_value, BVR_CHARS_TO_BREAK_VALUE, sizeof(chars_to_break_value));
- // fprintf(stderr, "debug: \"%s\"\n", chars_to_break_value);
char * item = bvr_commands_get_value(input, chars_to_break_value);
-
- FILE * stream = fopen(item, "r");
- char notgoodatnamingvariables[PATH_MAX];
- char * path = bvr_var_get(BVR_INCLUDE_PATH_VAR_NAME);
- if(stream == NULL) {
- strcpy(notgoodatnamingvariables, item);
- strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
- stream = fopen(notgoodatnamingvariables, "r");
- if(strcmp(path, BVR_UNDEFINED) == 0 && stream == NULL) {
- fprintf(output, "\nbVerbose include error. File \"%s\" not found. Path is undefined.\n", item);
- fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File \"%s\" not found. Path is undefined.\n", item);
- return FAILURE;
+ FILE * stream;
+ char * cp;
+ int return_status = SUCCESS;
+ // fprintf(stderr, "debug: %s\n", item);
+ if (strncmp(item, "bvr://", strlen("bvr://")) == 0) {
+ switch (item[6]) {
+ case 'v': /* ar */
+ cp = strchr(item+6, '/');
+ if (cp == NULL)
+ goto sike_this_actually_is_a_file;
+ cp = bvr_var_get(cp+1);
+ if (cp == NULL || 0 == strncmp(cp, "BVR_UNDEFINED", strlen("BVR_UNDEFINED")))
+ goto sike_this_actually_is_a_file;
+ stream = fmemopen(cp, strlen(cp), "r");
+ if (stream == NULL)
+ goto sike_this_actually_is_a_file;
+ break;
+ default:
+ goto sike_this_actually_is_a_file;
+ break; /* unreachable "code" */
}
- }
- char * singlepath;
- while(stream == NULL) {
- singlepath = strrchr(path, BVR_PATH_SEPARATOR);
- if(singlepath == NULL) {
- strcpy(notgoodatnamingvariables, path);
- strcat(notgoodatnamingvariables, item);
- stream = fopen(notgoodatnamingvariables, "r"); // ob1 fuckery
- if(stream == NULL) {
+ } else {
+ sike_this_actually_is_a_file:
+ stream = fopen(item, "r");
+ char notgoodatnamingvariables[PATH_MAX];
+ char * path = bvr_var_get(BVR_INCLUDE_PATH_VAR_NAME);
+ if(stream == NULL) {
+ strcpy(notgoodatnamingvariables, item);
+ strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
+ stream = fopen(notgoodatnamingvariables, "r");
+ if(strcmp(path, BVR_UNDEFINED) == 0 && stream == NULL) {
+ fprintf(output, "\nbVerbose include error. File \"%s\" not found. Path is undefined.\n", item);
+ fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File \"%s\" not found. Path is undefined.\n", item);
+ return_status = FAILURE;
+ goto returncleanly;
+ }
+ }
+ char * singlepath;
+ while(stream == NULL) {
+ singlepath = strrchr(path, BVR_PATH_SEPARATOR);
+ if(singlepath == NULL) {
strcpy(notgoodatnamingvariables, path);
strcat(notgoodatnamingvariables, item);
- strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
stream = fopen(notgoodatnamingvariables, "r"); // ob1 fuckery
if(stream == NULL) {
- fprintf(output, "\nbVerbose include error. File \"%s\" not found.\n", item);
- fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File \"%s\" not found.\n", item);
- return FAILURE;
+ strcpy(notgoodatnamingvariables, path);
+ strcat(notgoodatnamingvariables, item);
+ strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
+ stream = fopen(notgoodatnamingvariables, "r"); // ob1 fuckery
+ if(stream == NULL) {
+ fprintf(output, "\nbVerbose include error. File \"%s\" not found.\n", item);
+ fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File \"%s\" not found.\n", item);
+ return_status = FAILURE;
+ goto returncleanly;
+ }
+ break;
}
break;
}
- break;
- }
- strcpy(notgoodatnamingvariables, singlepath);
- strcat(notgoodatnamingvariables, item);
- stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery
- if(stream == NULL) {
- strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
+ strcpy(notgoodatnamingvariables, singlepath);
+ strcat(notgoodatnamingvariables, item);
stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery
- if(stream != NULL) {
- break;
+ if(stream == NULL) {
+ strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
+ stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery
+ if(stream != NULL) {
+ break;
+ }
}
+ *singlepath = '\0';
}
- *singlepath = '\0';
}
- int return_status = bvr_compose_stream(stream, output);
+ return_status = bvr_compose_stream(stream, output);
+ fclose(stream);
+ returncleanly:
fflush(output);
free(item);
item = NULL;
diff --git a/test/tape-test.bvr b/test/tape-test.bvr
index 27faa11..4d53690 100644
--- a/test/tape-test.bvr
+++ b/test/tape-test.bvr
@@ -9,8 +9,8 @@
<@?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@>@>@>
-
+<@?m ?"<@?s s ?g a[#]@><@?w s <@<@?r- s ?\"1\"@><@?s b a@><@?j b ?\"[\"@><@?j b s@><@?j b ?\"]\"@><@?g z@><@?g ?g b@><@?g k@>@>@>" function_that_prints_array_elements_backwards@>
+<@?s a this,is,a,test,of,an,array@><@?e a ?","@>
+<@?s z {@>
+<@?s k }@>
+<@?i bvr://v/function_that_prints_array_elements_backwards@>