shithub: scc

Download patch

ref: eaf9eb8ade3a417bad38096f84a0460be01389ac
parent: 7ae4cdf7ae71be76936061c036d07e7e34545ec4
author: Quentin Rameau <quinq@fifth.space>
date: Tue Jan 22 10:52:01 EST 2019

[driver] Warnings option: W to enable, w to disable

--- a/doc/scc.1
+++ b/doc/scc.1
@@ -3,7 +3,7 @@
 scc \- simple C compiler with magic
 .SH SYNOPSIS
 .B scc
-.RB [ \-cdgkqQsw ]
+.RB [ \-cdgkqQsWw ]
 .RB [ \-M | \-E | \-S ]
 .RB [ \-D
 .IR def[=val] ] ...
@@ -23,8 +23,6 @@
 .IR level ]
 .RB [ \-t
 .IR sys ]
-.RB [ \-W
-.IR warn ]
 .RB sourcefile ...
 .SH DESCRIPTION
 .B scc
@@ -117,12 +115,11 @@
 .I define
 by the -D parameter.
 .TP
-.B \-w
-Do show warning messages.
+.B \-W
+Show warning messages.
 .TP
-.BI \-W " warnings"
-This option only activates -w and is otherwise ignored for compatibility
-reasons.
+.B \-w
+Do not show warning messages (default).
 .SH ENVIRONMENT VARIABLES
 Certain environment variables control the behaviour of scc.
 .TP
--- a/src/cmd/scc/posix/scc.c
+++ b/src/cmd/scc/posix/scc.c
@@ -60,7 +60,8 @@
 static char *tmpdir;
 static size_t tmpdirln;
 static struct items objtmp, objout;
-static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag, Qflag = 1; /* TODO: Remove Qflag */
+static int Mflag, Eflag, Sflag, Wflag,
+           cflag, dflag, kflag, sflag, Qflag = 1; /* TODO: Remove Qflag */
 static int devnullfd = -1;
 
 extern int failure;
@@ -120,6 +121,8 @@
 
 	switch (tool) {
 	case CC1:
+		if (Wflag)
+			addarg(tool, "-w");
 		for (n = 0; sysincludes[n]; ++n) {
 			addarg(tool, "-I");
 			addarg(tool, sysincludes[n]);
@@ -554,10 +557,11 @@
 	case 't':
 		sys = EARGF(usage());
 		break;
-	case 'W':
-		EARGF(usage());
 	case 'w':
-		addarg(CC1, "-w");
+		Wflag = 0;
+		break;
+	case 'W':
+		Wflag = 1;
 		break;
 	case 'q':
 		Qflag = 0;