diff mbox series

[4/5] cgcc: teach about '-o <file>'

Message ID 20181124133004.9077-5-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series teach cgcc (and sparse) about -x and -o | expand

Commit Message

Luc Van Oostenryck Nov. 24, 2018, 1:30 p.m. UTC
The option '-o', in itself, doesn't need to be handled
specially by cgcc but this option takes an argument and
option arguments need to be ignored by cgcc (otherwise
they can be interpreted and filtered-out by cgcc).

Avoid potential problems with -o's argument by simply
ignoring it.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 cgcc | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/cgcc b/cgcc
index 33c2ba974..400044253 100755
--- a/cgcc
+++ b/cgcc
@@ -31,6 +31,14 @@  while (@ARGV) {
     # Ditto for stdin.
     $do_check = 1 if $_ eq '-';
 
+    if ($_ eq '-o') {
+	# Need to be checked explicitly since '-o -' is
+	# sometimes used and the '-' would otherwise be
+	# processed as an option.
+	die ("$0: missing argument for $_") if !@ARGV;
+	$nargs = 1;
+    }
+
     $m32 = 1 if /^-m32$/;
     $m64 = 1 if /^-m64$/;
     $gendeps = 1 if /^-M$/;