[hackers] [scc] [driver] continue building sources on failure || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 17 Jun 2016 21:45:13 +0200 (CEST)

commit e45b100a355a77e396196d4822f5d8b154111c6b
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu Jun 16 17:15:57 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Fri Jun 17 21:41:10 2016 +0200

    [driver] continue building sources on failure

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 603b063..1f569fc 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -32,7 +32,7 @@ static struct tool {
         char **args;
         char bin[16];
         char *outfile;
- int nparams, nargs, in, out, init, error;
+ int nparams, nargs, in, out, init;
         pid_t pid;
 } tools[] = {
         [CC1] = { .bin = "cc1", .cmd = PREFIX "/libexec/scc/", },
_AT_@ -51,22 +51,12 @@ static char *arch, *outfile;
 static struct items objtmp, objout;
 static int Eflag, Sflag, cflag, kflag, sflag;
 
+extern int failure;
+
 static void
 terminate(void)
 {
- struct tool *t;
- int i, tool, failed = LAST_TOOL;
-
- for (tool = 0; tool < LAST_TOOL; ++tool) {
- t = &tools[tool];
- if (t->pid) {
- kill(t->pid, SIGTERM);
- if (t->error)
- failed = tool;
- if (tool >= failed && t->outfile)
- unlink(t->outfile);
- }
- }
+ int i;
 
         if (!kflag) {
                 for (i = 0; i < objtmp.n; ++i)
_AT_@ -279,28 +269,32 @@ toolfor(char *file)
         die("scc: do not recognize filetype of %s", file);
 }
 
-static void
+static int
 validatetools(void)
 {
         struct tool *t;
- int i, tool, st;
+ int i, tool, st, failed = LAST_TOOL;
+
         for (tool = 0; tool < LAST_TOOL; ++tool) {
                 t = &tools[tool];
                 if (t->pid) {
                         if (waitpid(t->pid, &st, 0) < 0 ||
                             !WIFEXITED(st) || WEXITSTATUS(st) != 0) {
- t->error = 1;
- exit(-1);
+ failure = 1;
+ failed = tool;
                         }
+ if (tool >= failed && t->outfile)
+ unlink(t->outfile);
                         for (i = t->nparams; i < t->nargs; ++i)
                                 free(t->args[i]);
                         t->nargs = t->nparams;
                         t->pid = 0;
- t->error = 0;
                         t->in = -1;
                         t->out = -1;
                 }
         }
+
+ return failed == LAST_TOOL;
 }
 
 static void
_AT_@ -347,9 +341,8 @@ build(char *file)
                 spawn(settool(inittool(tool), file, nexttool));
         }
 
- validatetools();
-
- objs->s = newitem(objs->s, objs->n++, outfilename(file, "o"));
+ if (validatetools())
+ objs->s = newitem(objs->s, objs->n++, outfilename(file, "o"));
 }
 
 static void
_AT_@ -434,9 +427,9 @@ main(int argc, char *argv[])
                 build(*argv);
 
         if (Eflag || Sflag)
- return 0;
+ return failure;
 
- if (!cflag) {
+ if (!cflag && !failure) {
                 spawn(settool(inittool(LD), NULL, LAST_TOOL));
                 validatetools();
         }
_AT_@ -446,5 +439,5 @@ main(int argc, char *argv[])
                 validatetools();
         }
 
- return 0;
+ return failure;
 }
Received on Fri Jun 17 2016 - 21:45:13 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 17 2016 - 21:48:40 CEST