diff options
| author | welinder@troll.com <welinder@troll.com> | 2004-08-19 17:13:42 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:02:51 -0700 |
| commit | 34686eac3ebc040e0cc6703bc132081c3be9616e (patch) | |
| tree | f337a57c6d33e6840cb85493031ceb961a23fb45 /cgcc | |
| parent | cf874564fd4c2bc89f6359826fac7ae0b60962a1 (diff) | |
| download | sparse-dev-34686eac3ebc040e0cc6703bc132081c3be9616e.tar.gz | |
Teach cgcc about flags that are for sparse only.
Diffstat (limited to 'cgcc')
| -rw-r--r-- | cgcc | 41 |
1 files changed, 31 insertions, 10 deletions
@@ -4,19 +4,40 @@ my $cc = $ENV{'REAL_CC'} || 'cc'; my $check = $ENV{'CHECK'} || 'check'; -# 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.) my $seen_a_c_file = 0; foreach (@ARGV) { - if (/^[^-].*\.c/) { - $seen_a_c_file = 1; - last; - } + # 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.) + $seen_a_c_file = 1 if /^[^-].*\.c/; + + my $this_arg = ' ' . "e_arg ($_); + $cc .= $this_arg unless &check_only_option ($_); + $check .= $this_arg; } -if ($seen_a_c_file) { - system ($check, @ARGV); +system ($check) if $seen_a_c_file; +exec ($cc); + +# ----------------------------------------------------------------------------- +# Check if an option is for "check" only. + +sub check_only_option { + my ($arg) = @_; + return 1 if $arg =~ /^-W(no-?)?default-bitfield-sign$/; + return 0; } -exec ($cc, @ARGV); +# ----------------------------------------------------------------------------- +# Simple arg-quoting function. Just adds backslashes when needed. + +sub quote_arg { + my ($arg) = @_; + return "''" if $arg eq ''; + return join ('', + map { + m|^[-a-zA-Z0-9._/,=]+$| ? $_ : "\\" . $_; + } (split (//, $arg))); +} + +# ----------------------------------------------------------------------------- |
