summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-11-22 23:17:34 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-11-24 17:57:22 +0100
commit7bd25cdec3ffd4611540d56bd3470f66fb866ff2 (patch)
treee66218fcadfc7554133c6c11808144e45e4710bd
parent3d41c2d953c15c455081276f64ae30676e3f9f38 (diff)
downloadsparse-7bd25cdec3ffd4611540d56bd3470f66fb866ff2.tar.gz
cgcc: add support to ignore argument(s) of options
cgcc only does a minimal processing and filtering of its command line and most options are simply forwarded to sparse and gcc. However, if one of the ignored options takes an argument that matches one of the non-ignored options, this argument will be processed as an option with undesirable effect. Allow options to specify the number of arguments they're taking and avoid any processing or filtering of these arguments while still forwarding them to sparse and gcc. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rwxr-xr-xcgcc11
1 files changed, 9 insertions, 2 deletions
diff --git a/cgcc b/cgcc
index 736cb704..33c2ba97 100755
--- a/cgcc
+++ b/cgcc
@@ -14,12 +14,18 @@ my $do_compile = 1;
my $gcc_base_dir;
my $multiarch_dir;
my $verbose = 0;
+my $nargs = 0;
while (@ARGV) {
$_ = shift(@ARGV);
+
+ if ($nargs) {
+ $nargs--;
+ goto add_option;
+ }
+
# Look for a .c file. We don't want to run the checker on .o or .so files
- # in the link run. (This simplistic check knows nothing about options
- # with arguments, but it seems to do the job.)
+ # in the link run.
$do_check = 1 if /^[^-].*\.c$/;
# Ditto for stdin.
@@ -57,6 +63,7 @@ while (@ARGV) {
$verbose = 1 if $_ eq '-v';
+add_option:
my $this_arg = ' ' . &quote_arg ($_);
$cc .= $this_arg unless &check_only_option ($_);
$check .= $this_arg;