From 15583cad7daef5ced710cd20d1aa1a696a3ed057 Mon Sep 17 00:00:00 2001 From: Tharre Date: Sat, 13 Jun 2015 16:50:08 +0200 Subject: Make `general` path from get_doscripts() absolute --- src/build.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/build.c b/src/build.c index 4c752d5..8a4ab48 100644 --- a/src/build.c +++ b/src/build.c @@ -254,19 +254,23 @@ static char **parsecmd(char *cmd, size_t *i, size_t keep_free) { /* Return a struct with all the possible .do scripts, and the chosen one. */ static do_attr *get_doscripts(const char *target) { - do_attr *doscripts = xmalloc(sizeof(do_attr)); + do_attr *ds = xmalloc(sizeof(do_attr)); - doscripts->specific = concat(2, target, ".do"); - doscripts->general = concat(3, "default", take_extension(target), ".do"); + ds->specific = concat(2, target, ".do"); + char *dirc = xstrdup(target); + char *dt = dirname(dirc); - if (fexists(doscripts->specific)) - doscripts->chosen = doscripts->specific; - else if (fexists(doscripts->general)) - doscripts->chosen = doscripts->general; + ds->general = concat(4, dt, "/default", take_extension(target), ".do"); + free(dirc); + + if (fexists(ds->specific)) + ds->chosen = ds->specific; + else if (fexists(ds->general)) + ds->chosen = ds->general; else - doscripts->chosen = NULL; + ds->chosen = NULL; - return doscripts; + return ds; } /* Free the do_attr struct. */ -- cgit v1.2.3-70-g09d2