aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2015-06-13 16:50:08 +0200
committerTharre <tharre3@gmail.com>2015-06-13 16:50:08 +0200
commit15583cad7daef5ced710cd20d1aa1a696a3ed057 (patch)
treeec3b8eb5eb31668172e30e7b839fdab18ffdae6b
parent77b4af02c298b385d109719eac50b15f464be2cd (diff)
downloadredo-15583cad7daef5ced710cd20d1aa1a696a3ed057.tar.gz
redo-15583cad7daef5ced710cd20d1aa1a696a3ed057.tar.xz
redo-15583cad7daef5ced710cd20d1aa1a696a3ed057.zip
Make `general` path from get_doscripts() absolute
-rw-r--r--src/build.c22
1 files 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. */