scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 91088df2692cc0c89f0828c12dd8ff8850e39de3
parent 33e76ce23d79e16f3e4bc0abfcb62e2e43c1845a
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sat, 18 Jun 2016 15:03:30 +0200

[driver] use struct items int tool

Replace args and nargs with our defined struct items.

Diffstat:
Mdriver/posix/scc.c | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -29,10 +29,10 @@ enum { static struct tool { char cmd[PATH_MAX]; - char **args; char bin[16]; char *outfile; - int nparams, nargs, in, out, init; + struct items args; + int nparams, in, out, init; pid_t pid; } tools[] = { [CC1] = { .bin = "cc1", .cmd = PREFIX "/libexec/scc/", }, @@ -69,10 +69,10 @@ addarg(int tool, char *arg) { struct tool *t = &tools[tool]; - if (t->nargs < 1) - t->nargs = 1; + if (t->args.n < 1) + t->args.n = 1; - t->args = newitem(t->args, t->nargs++, arg); + t->args.s = newitem(t->args.s, t->args.n++, arg); } static void @@ -80,10 +80,10 @@ setargv0(int tool, char *arg) { struct tool *t = &tools[tool]; - if (t->nargs > 0) - t->args[0] = arg; + if (t->args.n > 0) + t->args.s[0] = arg; else - t->args = newitem(t->args, t->nargs++, arg); + t->args.s = newitem(t->args.s, t->args.n++, arg); } static int @@ -126,7 +126,7 @@ inittool(int tool) } setargv0(tool, t->bin); - t->nparams = t->nargs; + t->nparams = t->args.n; t->init = 1; return tool; @@ -239,7 +239,7 @@ spawn(int tool) dup2(t->out, 1); if (t->in > -1) dup2(t->in, 0); - execvp(t->cmd, t->args); + execvp(t->cmd, t->args.s); fprintf(stderr, "scc: execvp %s: %s\n", t->cmd, strerror(errno)); _exit(1); @@ -289,9 +289,9 @@ validatetools(void) } if (tool >= failed && t->outfile) unlink(t->outfile); - for (i = t->nparams; i < t->nargs; ++i) - free(t->args[i]); - t->nargs = t->nparams; + for (i = t->nparams; i < t->args.n; ++i) + free(t->args.s[i]); + t->args.n = t->nparams; t->pid = 0; } }