[hackers] [scc] Revert "[driver] use pointers in tools lookup table" || Quentin Rameau

From: <git_AT_suckless.org>
Date: Tue, 7 Jun 2016 15:22:13 +0200 (CEST)

commit 7942db03e1686a900fbfce75474f1d8024392fb4
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue Jun 7 15:17:49 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Tue Jun 7 15:21:51 2016 +0200

    Revert "[driver] use pointers in tools lookup table"
    
    This reverts commit 86e6d58d2e1059bb493df922bc89a1cc2b92ee83.
    
    This was a leftover from a test I forgot to drop before pushing.
    Sorry for the noise.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index d6cc90e..ed2f511 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -28,25 +28,22 @@ enum {
         LAST_TOOL,
 };
 
-typedef struct tool Tool;
-struct tool {
+static struct tool {
         char cmd[PATH_MAX];
         char *args[NARGS];
         char bin[16];
         char *outfile;
         int nargs, in, out, error;
         pid_t pid;
-};
-
-static Tool *tools[] = {
- [CC1] = &(Tool){ .bin = "cc1", .cmd = PREFIX "/libexec/scc/", },
- [TEEIR] = &(Tool){ .bin = "tee", .cmd = "tee", },
- [CC2] = &(Tool){ .bin = "cc2", .cmd = PREFIX "/libexec/scc/", },
- [TEEQBE] = &(Tool){ .bin = "tee", .cmd = "tee", },
- [QBE] = &(Tool){ .bin = "qbe", .cmd = "qbe", },
- [TEEAS] = &(Tool){ .bin = "tee", .cmd = "tee", },
- [AS] = &(Tool){ .bin = "as", .cmd = "as", },
- [LD] = &(Tool){ .bin = "gcc", .cmd = "gcc", }, /* TODO replace with ld */
+} tools[] = {
+ [CC1] = { .bin = "cc1", .cmd = PREFIX "/libexec/scc/", },
+ [TEEIR] = { .bin = "tee", .cmd = "tee", },
+ [CC2] = { .bin = "cc2", .cmd = PREFIX "/libexec/scc/", },
+ [TEEQBE] = { .bin = "tee", .cmd = "tee", },
+ [QBE] = { .bin = "qbe", .cmd = "qbe", },
+ [TEEAS] = { .bin = "tee", .cmd = "tee", },
+ [AS] = { .bin = "as", .cmd = "as", },
+ [LD] = { .bin = "gcc", .cmd = "gcc", }, /* TODO replace with ld */
 };
 
 char *argv0;
_AT_@ -58,11 +55,11 @@ static int Eflag, Sflag, kflag;
 static void
 terminate(void)
 {
- Tool *t;
+ struct tool *t;
         int tool, failed;
 
         for (tool = 0; tool < LAST_TOOL; ++tool) {
- t = tools[tool];
+ t = &tools[tool];
                 if (t->pid) {
                         kill(t->pid, SIGTERM);
                         if (t->error)
_AT_@ -76,7 +73,7 @@ terminate(void)
 static int
 inittool(int tool)
 {
- Tool *t = tools[tool];
+ struct tool *t = &tools[tool];
         size_t binln;
         int n;
 
_AT_@ -147,7 +144,7 @@ outfilename(char *path, char *ext)
 
 static void
 addarg(int tool, char *arg) {
- Tool *t = tools[tool];
+ struct tool *t = &tools[tool];
 
         if (!(t->nargs < NARGS - 2)) /* 2: argv0, NULL terminator */
                 die("scc: too many parameters given");
_AT_@ -158,7 +155,7 @@ addarg(int tool, char *arg) {
 static int
 settool(int tool, char *infile, int nexttool)
 {
- Tool *t = tools[tool];
+ struct tool *t = &tools[tool];
         int fds[2];
         static int fdin;
 
_AT_@ -208,7 +205,7 @@ settool(int tool, char *infile, int nexttool)
 static void
 spawn(int tool)
 {
- Tool *t = tools[tool];
+ struct tool *t = &tools[tool];
 
         switch (t->pid = fork()) {
         case -1:
_AT_@ -254,10 +251,10 @@ toolfor(char *file)
 static void
 validatetools(void)
 {
- Tool *t;
+ struct tool *t;
         int tool, st;
         for (tool = 0; tool < LAST_TOOL; ++tool) {
- t = tools[tool];
+ t = &tools[tool];
                 if (t->pid) {
                         if (waitpid(t->pid, &st, 0) < 0 ||
                             !WIFEXITED(st) || WEXITSTATUS(st) != 0) {
_AT_@ -331,7 +328,7 @@ build(char *file)
                         if (argfile)
                                 addarg(LD, file);
                         else
- tmpobjs[nobjs++] = xstrdup(tools[AS]->outfile);
+ tmpobjs[nobjs++] = xstrdup(tools[AS].outfile);
                 default:
                         nexttool = LAST_TOOL;
                         continue;
_AT_@ -380,7 +377,7 @@ main(int argc, char *argv[])
                 arch = EARGF(usage());
                 break;
         case 'o':
- tools[LD]->outfile = EARGF(usage());
+ tools[LD].outfile = EARGF(usage());
                 break;
         case 'w':
                 addarg(CC1, "-w");
Received on Tue Jun 07 2016 - 15:22:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 07 2016 - 15:24:13 CEST