aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2017-08-27 15:24:46 +0200
committerTharre <tharre3@gmail.com>2018-11-18 15:37:41 +0100
commit8194ca7275c23b3fb34fd54b52837df9dc80c9c8 (patch)
tree2e5c76caebc650a20f29f9ab217b571408a79233
parent1abdcb049d4500f899306cf678e1b1a5e50880bb (diff)
downloadredo-8194ca7275c23b3fb34fd54b52837df9dc80c9c8.tar.gz
redo-8194ca7275c23b3fb34fd54b52837df9dc80c9c8.tar.xz
redo-8194ca7275c23b3fb34fd54b52837df9dc80c9c8.zip
Simplify realpath() error handling
-rw-r--r--src/build.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/build.c b/src/build.c
index a2dfbc1..036bfb7 100644
--- a/src/build.c
+++ b/src/build.c
@@ -81,9 +81,6 @@ static int build_target(dep_info *dep) {
}
char *reltarget = get_relpath(dep->target);
- if (!reltarget)
- fatal("redo: failed to get realpath() of %s", reltarget);
-
printf("\033[32mredo \033[1m\033[37m%s\033[0m\n", reltarget);
free(reltarget);
@@ -182,9 +179,6 @@ static int build_target(dep_info *dep) {
.path = get_dep_path(doscripts->chosen),
};
- if (!dep2.path)
- fatal("redo: failed to get realpath() of %s", doscripts->chosen);
-
if (!fexists(dep2.path)) {
update_dep_info(&dep2, doscripts->chosen);
write_dep_information(&dep2);
@@ -325,11 +319,14 @@ static char *get_relpath(const char *target) {
char *root = getenv("REDO_ROOT");
char *abstarget = xrealpath(target);
- if (!abstarget)
- return NULL;
+ char *path;
+ if (!abstarget) {
+ path = xstrdup(relpath((char*)target, root));
+ } else {
+ path = xstrdup(relpath(abstarget, root));
+ free(abstarget);
+ }
- char *path = xstrdup(relpath(abstarget, root));
- free(abstarget);
return path;
}
@@ -338,8 +335,6 @@ static char *get_dep_path(const char *target) {
char *root = getenv("REDO_ROOT");
char *dep_path;
char *reltarget = get_relpath(target);
- if (!reltarget)
- return NULL;
char *redodir = is_absolute(reltarget) ? "/.redo/abs/" : "/.redo/rel/";
dep_path = concat(3, root, redodir, reltarget);
@@ -360,8 +355,6 @@ static char *get_dep_path(const char *target) {
*/
void add_prereq(const char *target, const char *parent, int ident) {
char *base_path = get_dep_path(parent);
- if (!base_path)
- fatal("redo: failed to get realpath() of %s", parent);
char *dep_path = concat(2, base_path, ".prereq");
@@ -394,8 +387,6 @@ void add_prereq(const char *target, const char *parent, int ident) {
*/
void add_prereq_path(const char *target, const char *parent, int ident) {
char *reltarget = get_relpath(target);
- if (!reltarget)
- fatal("redo: failed to get realpath() of %s", target);
add_prereq(reltarget, parent, ident);
free(reltarget);
@@ -450,9 +441,6 @@ int update_target(const char *target, int ident) {
.path = get_dep_path(target),
};
- if (!dep.path)
- return 1;
-
int retval = handle_ident(&dep, ident);
free(dep.path);
free(dep.hash);