[hackers] [scc] [driver] use struct items int tool || Quentin Rameau

From: <git_AT_suckless.org>
Date: Tue, 21 Jun 2016 08:32:07 +0200 (CEST)

commit 91088df2692cc0c89f0828c12dd8ff8850e39de3
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Jun 18 15:03:30 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sat Jun 18 15:03:30 2016 +0200

    [driver] use struct items int tool
    
    Replace args and nargs with our defined struct items.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index f8bf4c7..71d8185 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -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/", },
_AT_@ -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
_AT_@ -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
_AT_@ -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;
_AT_@ -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);
_AT_@ -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;
                 }
         }
Received on Tue Jun 21 2016 - 08:32:07 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 21 2016 - 08:36:21 CEST