commit 4a3200bdb91d2a77d43fafd5fc536f08c6f497e3
Author:     Quentin Rameau <[email protected]>
AuthorDate: Mon May 30 13:05:50 2016 +0200
Commit:     Quentin Rameau <[email protected]>
CommitDate: Mon May 30 13:05:50 2016 +0200

    [driver] introduce handling of per tool flags
    
    Add a tool variable for the actual number of parameters.
    Add handling of cc1 -E option.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index d3eb0e9..9040925 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -26,6 +26,7 @@ enum {
 static struct {
        char cmd[PATH_MAX];
        char *args[NARGS];
+       int nargs;
        char bin[16];
        char name[8];
        int in, out;
@@ -38,6 +39,7 @@ static struct {
 
 char *argv0;
 static char *arch;
+static int Eflag;
 
 static void
 terminate(void)
@@ -53,7 +55,6 @@ terminate(void)
 int
 settool(int tool, int pipeout)
 {
-       char *namefmt, *cmdfmt;
        int fds[2], n;
        static int fdin;
 
@@ -131,6 +132,10 @@ main(int argc, char *argv[])
        arch = getenv("ARCH");
 
        ARGBEGIN {
+       case 'E':
+               Eflag = 1;
+               tools[CC1].args[++tools[CC1].nargs] = "-E";
+               break;
        case 'm':
                arch = EARGF(usage());
                break;
@@ -144,14 +149,19 @@ main(int argc, char *argv[])
        if (!argc)
                die("scc: fatal error: no input files");
 
-       tools[CC1].args[1] = *argv;
+       tools[CC1].args[++tools[CC1].nargs] = *argv;
 
-       spawn(settool(CC1, 1));
-       if (!arch || strcmp(arch, "qbe")) {
-               spawn(settool(CC2, 0));
+       if (Eflag) {
+               spawn(settool(CC1, 0));
        } else {
-               spawn(settool(CC2, 1));
-               spawn(settool(QBE, 0));
+               spawn(settool(CC1, 1));
+
+               if (!arch || strcmp(arch, "qbe")) {
+                       spawn(settool(CC2, 0));
+               } else {
+                       spawn(settool(CC2, 1));
+                       spawn(settool(QBE, 0));
+               }
        }
 
        for (i = 0; i < NR_TOOLS; ++i) {

Reply via email to