From dfde7bff94240172d3a2a037ec0b77871b71bf56 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sat, 24 Sep 2022 13:30:39 -0400 Subject: fix go-to-error when build_dir != . --- build.c | 6 +++++- config.c | 4 ++-- util.c | 3 --- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build.c b/build.c index 3f4cc57..f5b916a 100644 --- a/build.c +++ b/build.c @@ -101,14 +101,18 @@ static void build_start(Ted *ted) { ted_path_full(ted, "../..", ted->build_dir, sizeof ted->build_dir); cargo = true; } else - // Check if Makefile exists in this or the parent directory + // Check if Makefile exists in this or the parent/parent's parent directory if (fs_file_exists("Makefile")) { make = true; } else if (fs_file_exists(".." PATH_SEPARATOR_STR "Makefile")) { ted_path_full(ted, "..", ted->build_dir, sizeof ted->build_dir); make = true; + } else if (fs_file_exists(".." PATH_SEPARATOR_STR ".." PATH_SEPARATOR_STR "Makefile")) { + ted_path_full(ted, "../..", ted->build_dir, sizeof ted->build_dir); + make = true; } + // @TODO(eventually): `go build` if (cargo) { diff --git a/config.c b/config.c index 4190fe9..3ed27d8 100644 --- a/config.c +++ b/config.c @@ -172,7 +172,7 @@ typedef struct { } OptionU16; typedef struct { char const *name; - const char *control; + char *control; size_t buf_size; bool per_language; } OptionString; @@ -232,7 +232,7 @@ void config_read(Ted *ted, char const *filename, int pass) { // core options // (these go at the start so they don't need to be re-computed each time) - const Settings *nullset = NULL; + Settings *nullset = NULL; OptionBool const options_bool[] = { {"auto-indent", &nullset->auto_indent, true}, {"auto-add-newline", &nullset->auto_add_newline, true}, diff --git a/util.c b/util.c index 42d9387..71fce88 100644 --- a/util.c +++ b/util.c @@ -283,9 +283,6 @@ static void path_full(char const *dir, char const *relpath, char *abspath, size_ str_cpy(abspath, abspath_size, dir); } - if (strlen(abspath) == 0 || abspath[strlen(abspath) - 1] != PATH_SEPARATOR) - str_cat(abspath, abspath_size, PATH_SEPARATOR_STR); - while (*relpath) { size_t component_len = strcspn(relpath, ALL_PATH_SEPARATORS); char const *component_end = relpath + component_len; -- cgit v1.2.3