From e7d1afd46b66ffbdab0ef7989c6f0c0017d6e3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Tue, 5 May 2020 21:22:27 +0200 Subject: include finnally works to a usable extent. --- src/bvr.h | 3 ++- src/bvrcommands.c | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/bvr.h b/src/bvr.h index a2bfe00..55b27de 100644 --- a/src/bvr.h +++ b/src/bvr.h @@ -26,7 +26,8 @@ int bvr_bvrvar_first_time_set = 1; #define BVR_VER_MINOR 1 #define BVR_VER_PATCH 0 -#define BVR_PATH_SEPARATOR ';' +#define BVR_PATH_SEPARATOR ' ' #define BVR_INCLUDE_PATH_VAR_NAME "bvr_include_path" +#define BVR_COMMAND_FILE_EXT ".bvr" int bvr_compose_stream(FILE *, FILE *); diff --git a/src/bvrcommands.c b/src/bvrcommands.c index 747c757..aac4800 100644 --- a/src/bvrcommands.c +++ b/src/bvrcommands.c @@ -60,24 +60,34 @@ int bvr_handle_include(FILE * input, FILE * output) { FILE * stream = fopen(item, "r"); char notgoodatnamingvariables[PATH_MAX]; char * path = bvr_var_get(BVR_INCLUDE_PATH_VAR_NAME); - 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; + 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; + } } char * singlepath; while(stream == NULL) { singlepath = strrchr(path, BVR_PATH_SEPARATOR); - strcpy(notgoodatnamingvariables, singlepath); - strcat(notgoodatnamingvariables, item); - stream = fopen(notgoodatnamingvariables, "r"); - if(strrchr(path, BVR_PATH_SEPARATOR) == NULL) { - stream = fopen(notgoodatnamingvariables, "r"); + if(singlepath == NULL) { + stream = fopen(path, "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; } + break; + } + strcpy(notgoodatnamingvariables, singlepath); + strcat(notgoodatnamingvariables, item); + stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery + if(stream == NULL) { + strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT); + stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery } *singlepath = '\0'; } -- cgit v1.2.3