[hackers] [scc] [driver] introduce handling of per tool flags || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 30 May 2016 13:07:28 +0200 (CEST)

commit 4a3200bdb91d2a77d43fafd5fc536f08c6f497e3
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Mon May 30 13:05:50 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
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
_AT_@ -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;
_AT_@ -38,6 +39,7 @@ static struct {
 
 char *argv0;
 static char *arch;
+static int Eflag;
 
 static void
 terminate(void)
_AT_@ -53,7 +55,6 @@ terminate(void)
 int
 settool(int tool, int pipeout)
 {
- char *namefmt, *cmdfmt;
         int fds[2], n;
         static int fdin;
 
_AT_@ -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;
_AT_@ -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) {
Received on Mon May 30 2016 - 13:07:28 CEST

This archive was generated by hypermail 2.3.0 : Mon May 30 2016 - 13:12:13 CEST