diff options
author | AndreyDobrovolskyOdessa <andrey.dobrovolsky.odessa@gmail.com> | 2021-03-19 23:28:25 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-03-26 19:09:25 +0100 |
commit | ca8316c43c52bd9961530f218fc4736ed71c6764 (patch) | |
tree | 7084b5edb944d114dba8489fe7a7344aaf018ac6 | |
parent | c7d55166043e524d37dfc49baae62203047ad9b7 (diff) | |
download | redo-c-ca8316c43c52bd9961530f218fc4736ed71c6764.tar.gz redo-c-ca8316c43c52bd9961530f218fc4736ed71c6764.tar.xz redo-c-ca8316c43c52bd9961530f218fc4736ed71c6764.zip |
Incorporating sourcefile() call inside check_deps()
Now sourcefile() is called from inside check_deps() only. Simplifies skip[] assignment logics in redo_ifchange(). Closes: #17 [via git-merge-pr]
-rw-r--r-- | redo.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/redo.c b/redo.c index 227d9db..139142a 100644 --- a/redo.c +++ b/redo.c @@ -397,8 +397,6 @@ targetlock(char *target) static int sourcefile(char *target) { - target = targetchdir(target); - if (access(targetdep(target), F_OK) == 0) return 0; @@ -419,6 +417,12 @@ check_deps(char *target) target = targetchdir(target); + if (sourcefile(target)) + return 1; + + if (fflag > 0) + return 0; + depfile = targetdep(target); f = fopen(depfile, "r"); if (!f) @@ -451,8 +455,7 @@ check_deps(char *target) } // hash is good, recurse into dependencies if (ok && strcmp(target, filename) != 0) { - if (!sourcefile(filename)) - ok = check_deps(filename); + ok = check_deps(filename); fchdir(dir_fd); } break; @@ -807,7 +810,7 @@ redo_ifchange(int targetc, char *targetv[]) // check all targets whether needing rebuild for (targeti = 0; targeti < targetc; targeti++) - skip[targeti] = fflag > 0 ? 0 : check_deps(targetv[targeti]); + skip[targeti] = check_deps(targetv[targeti]); targeti = 0; while (1) { @@ -815,7 +818,7 @@ redo_ifchange(int targetc, char *targetv[]) if (targeti < targetc) { char *target = targetv[targeti]; - if (skip[targeti] || sourcefile(target)) { + if (skip[targeti]) { targeti++; continue; } |