Re: [PATCH] cgcc: accept any file type with '-x c'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 21 Nov 2018 22:27:16 +0100
Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote:

> Currently cgcc only process file given as stdin or if their

processes files

> name end with '.c'. Other files are explicitly ignored.
> 
> This generally correspond to what is wanted but GCC also accept
> files with any extension if their type is given via the option
> '-x <language>'. Some projects use this mechanism, for example
> to use the C pre-processor on some files containing no code.
> This fails when cgcc is used as wrapper around sparse + GCC.
> 
> Fix this by teaching sparse about the '-x c' option.
> 
> Reported-by: Antonio Ospite <ao2@xxxxxx>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  cgcc | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/cgcc b/cgcc
> index 7611dc9ff..188197369 100755
> --- a/cgcc
> +++ b/cgcc
> @@ -25,6 +25,14 @@ while (@ARGV) {
>      # Ditto for stdin.
>      $do_check = 1 if $_ eq '-';
>  
> +    # accept any file type input language is specified with '-x c'

A missing "if" after "file type"?

> +    if ($_ eq '-x') {
> +	my $lang = shift(@ARGV);
> +	die ("$0: missing argument for -x") if !$lang;

This does not catch errors like "-x -o file", but I guess it's not a
big deal, is it? I guess cgcc can generally assume that the command line
is already a valid gcc command line.

Thanks you,
   Antonio

> +	$do_check = 1 if $lang eq 'c';
> +	next;
> +    }
> +
>      $m32 = 1 if /^-m32$/;
>      $m64 = 1 if /^-m64$/;
>      $gendeps = 1 if /^-M$/;
> -- 
> 2.19.0
> 


-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux