From 1f616ab22d64030f98310898cde6178bbdff390f Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Thu, 5 Jan 2023 12:36:20 +0100 Subject: correct string logic, fix invalid reads on parser, add script to log --- src/build.c | 3 +++ src/config.c | 12 ++++++------ src/parser.c | 3 +-- src/ui.c | 16 ++++++++++++---- 4 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/build.c b/src/build.c index 8d7f369..952389b 100644 --- a/src/build.c +++ b/src/build.c @@ -103,6 +103,9 @@ void create_build() free(build_path); } + printf("Running '%s'\n", current_project->script_path); + fflush(stdout); + int status = system(current_project->script_path); if (status) build.status = STATUS_FAILURE; diff --git a/src/config.c b/src/config.c index 06d82f4..229de19 100644 --- a/src/config.c +++ b/src/config.c @@ -127,7 +127,7 @@ char* project_dir(char* project) cache = realloc(cache, size); strncat(cache, "/", size - strlen(cache) - 1); strncat(cache, project, size - strlen(cache) - 1); - cache[size] = '\0'; + cache[size-1] = '\0'; return cache; } @@ -142,11 +142,11 @@ char* build_dir(char* project, char* build) if (!project_path) return project_path; - size_t size = strlen(project_path) + 1 + strlen(build) ; - project_path = realloc(project_path, size+1); - strncat(project_path, "/", size); - strncat(project_path, build, size); - project_path[size] = '\0'; + size_t size = strlen(project_path) + 1 + strlen(build) + 1; + project_path = realloc(project_path, size); + strncat(project_path, "/", size - strlen(project_path) - 1); + strncat(project_path, build, size - strlen(project_path) - 1); + project_path[size-1] = '\0'; return project_path; } \ No newline at end of file diff --git a/src/parser.c b/src/parser.c index 90705ce..cd7e672 100644 --- a/src/parser.c +++ b/src/parser.c @@ -309,9 +309,8 @@ void parse_query(const char* query_arg) char* key = head; char* value = NULL; - while (head <= end) + while (++head <= end) { - ++head; if (!value && *head == '=') { *head = '\0'; diff --git a/src/ui.c b/src/ui.c index fdfc945..d86532e 100644 --- a/src/ui.c +++ b/src/ui.c @@ -118,9 +118,17 @@ void print_head() } printf(""); + char* token = config.token; + if (current_project) + { + token = current_project->token; + if (!token) + token = config.token; + } + if (current_project && current_project->name && context.action && !strcmp(context.action, "trigger") - && context.token && config.token && !strcmp(context.token, config.token)) + && context.token && token && !strcmp(context.token, token)) printf("", current_project->name); printf("", config.path_prefix ? config.path_prefix : ""); @@ -241,12 +249,12 @@ void print_build_trigger() printf( "
" "
" - "%s" "
" + "%s" "" "
", - context.token ? "Invalid token" : "", - context.token ? context.token : "" + context.token ? context.token : "", + context.token ? "Invalid token
" : "" ); } -- cgit v1.2.3