[hackers] [scc] [driver] replace outfiles[] with per tool outfile string || Quentin Rameau
commit eb2bc635310842692b7b00ed6bf77f48d2584b6f
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Jun 4 12:26:02 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sat Jun 4 12:40:14 2016 +0200
[driver] replace outfiles[] with per tool outfile string
diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 7988707..f164faf 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -29,6 +29,7 @@ static struct tool {
char cmd[PATH_MAX];
char *args[NARGS];
char bin[16];
+ char *outfile;
int nargs, in, out;
pid_t pid;
} tools[NR_TOOLS] = {
_AT_@ -41,21 +42,22 @@ static struct tool {
char *argv0;
static char *arch;
-static char *outfiles[NR_TOOLS + 1];
static int failedtool = NR_TOOLS;
static int Eflag, Sflag, kflag;
static void
cleanup(void)
{
+ struct tool *t;
int i;
for (i = 0; i < NR_TOOLS + 1; ++i) {
- if (outfiles[i]) {
+ t = &tools[i];
+ if (t->outfile) {
if (i > failedtool)
- unlink(outfiles[i]);
- free(outfiles[i]);
- outfiles[i] = NULL;
+ unlink(t->outfile);
+ free(t->outfile);
+ t->outfile = NULL;
}
}
}
_AT_@ -63,14 +65,16 @@ cleanup(void)
static void
terminate(void)
{
+ struct tool *t;
int i;
for (i = 0; i < NR_TOOLS; ++i) {
- if (tools[i].pid)
- kill(tools[i].pid, SIGTERM);
+ t = &tools[i];
+ if (t->pid)
+ kill(t->pid, SIGTERM);
+ if (i >= failedtool && t->outfile)
+ unlink(t->outfile);
}
-
- cleanup();
}
static int
_AT_@ -145,30 +149,30 @@ static int
settool(int tool, char *input, int output)
{
struct tool *t = &tools[tool];
- int fds[2];
+ int fds[2], proxiedtool;
char *ext;
static int fdin;
switch (tool) {
case AS:
- outfiles[output] = outfilename(input, "o");
- t->args[t->nargs] = outfiles[output];
- t->args[3] = NULL;
+ t->outfile = outfilename(input, "o");
+ t->args[2] = t->outfile;
break;
case TEE:
switch (output) {
case CC2:
+ proxiedtool = CC1;
ext = "ir"; break;
case QBE:
+ proxiedtool = CC2;
ext = "qbe"; break;
case NR_TOOLS:
- if (!Sflag)
- break;
case AS:
+ proxiedtool = CC2;
ext = "as"; break;
}
- outfiles[output] = outfilename(input, ext);
- t->args[1] = outfiles[output];
+ tools[proxiedtool].outfile = outfilename(input, ext);
+ t->args[1] = tools[proxiedtool].outfile;
break;
default:
break;
Received on Sat Jun 04 2016 - 13:02:20 CEST
This archive was generated by hypermail 2.3.0
: Sat Jun 04 2016 - 13:12:16 CEST