aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jobs.c14
-rw-r--r--src/util.c8
2 files changed, 15 insertions, 7 deletions
diff --git a/src/jobs.c b/src/jobs.c
index 2e1e0c4..859c519 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -231,11 +231,11 @@ static int job_read_outputs(struct job *job, cJSON *outputs)
/* for nix-eval-jobs output only, for dag use the htab instead */
struct job *job_search(struct job *job, const char *drv)
{
- if (strcmp(drv, job->drv_path))
+ if (!strcmp(drv, job->drv_path))
return job;
for (size_t i = 0; i < job->deps_filled; i++) {
- if (strcmp(drv, job->deps[i]->drv_path))
+ if (!strcmp(drv, job->deps[i]->drv_path))
return job->deps[i];
}
@@ -274,10 +274,8 @@ static int job_read_cache(struct job *job)
j = job_search(job, trim(line));
if (j == NULL) {
- /* bug in nix-eval-jobs or nix-build */
- print_err("%s", "could not find job");
- ret = -ESRCH;
- goto out_free_line;
+ /* nix-eval-jobs doesn't count src */
+ continue;
}
if (in_fetched_block)
@@ -297,9 +295,11 @@ static int job_read_cache(struct job *job)
}
/* remove stale deps */
- for (size_t i = 0; i < job->deps_filled; i++) {
+ for (size_t i = 0; i < job->deps_filled;) {
if (job->deps[i]->stale)
job_free(job->deps[i]);
+ else
+ i++;
}
out_free_line:
diff --git a/src/util.c b/src/util.c
index 937e1e4..ab2d5a0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -142,8 +142,16 @@ int run(const char *file, char *argv[])
char *trim(char *s)
{
+ size_t end, i;
+
while (isspace(*s))
s++;
+ for (i = 0, end = 0; s[i]; i++) {
+ if (isgraph(s[i]))
+ end = i + 1;
+ }
+ s[end] = '\0';
+
return s;
}