[hackers] [scc] [driver] Add -d option to print buildchain errors || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sat, 18 Feb 2017 18:42:58 +0100 (CET)

commit c2c3889b60b5f0bc11d1b89f405aa5346134bd76
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Feb 18 12:59:52 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sat Feb 18 18:38:48 2017 +0100

    [driver] Add -d option to print buildchain errors

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index f53cc4c..8705851 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -55,7 +55,7 @@ static char *arch, *execpath, *objfile, *outfile;
 static char *tmpdir;
 static size_t tmpdirln;
 static struct items objtmp, objout;
-static int Mflag, Eflag, Sflag, cflag, kflag, sflag;
+static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag;
 static int devnullfd;
 
 extern int failure;
_AT_@ -248,7 +248,7 @@ spawn(int tool)
                         dup2(t->out, 1);
                 if (t->in > -1)
                         dup2(t->in, 0);
- if (tool != CC1)
+ if (!dflag && tool != CC1)
                         dup2(devnullfd, 2);
                 execvp(t->cmd, t->args.s);
                 fprintf(stderr, "scc: execvp %s: %s\n",
_AT_@ -406,13 +406,13 @@ usage(void)
 {
         die("usage: scc [-D def[=val]]... [-U def]... [-I dir]... "
             "[-L dir]... [-l dir]...\n"
- " [-gksw] [-m arch] [-M|-E|-S] [-o outfile] file...\n"
+ " [-dgksw] [-m arch] [-M|-E|-S] [-o outfile] file...\n"
             " scc [-D def[=val]]... [-U def]... [-I dir]... "
             "[-L dir]... [-l dir]...\n"
- " [-gksw] [-m arch] [-M|-E|-S] -c file...\n"
+ " [-dgksw] [-m arch] [-M|-E|-S] -c file...\n"
             " scc [-D def[=val]]... [-U def]... [-I dir]... "
             "[-L dir]... [-l dir]...\n"
- " [-gksw] [-m arch] -c -o outfile file");
+ " [-dgksw] [-m arch] -c -o outfile file");
 }
 
 int
_AT_@ -462,6 +462,9 @@ main(int argc, char *argv[])
         case 'c':
                 cflag = 1;
                 break;
+ case 'd':
+ dflag = 1;
+ break;
         case 'g':
                 addarg(AS, "-g");
                 addarg(LD, "-g");
_AT_@ -507,13 +510,15 @@ operand:
             linkchain.n > 1 && cflag && outfile)
                 usage();
 
+ if (dflag) {
+ if ((devnullfd = open("/dev/null", O_WRONLY)) < 0)
+ fputs("scc: could not open /dev/null\n", stderr);
+ }
+
         if (!(tmpdir = getenv("TMPDIR")) || !tmpdir[0])
                 tmpdir = ".";
         tmpdirln = strlen(tmpdir);
 
- if ((devnullfd = open("/dev/null", O_WRONLY)) < 0)
- fputs("scc: could not open /dev/null\n", stderr);
-
         build(&linkchain, (link = !(Mflag || Eflag || Sflag || cflag)));
 
         if (!(link || cflag))
Received on Sat Feb 18 2017 - 18:42:58 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 18 2017 - 18:48:18 CET