[klibc] [PATCH] Add support for --param=name=value

maximilian attems max at stro.at
Wed Aug 3 11:32:05 PDT 2011


On Wed, Aug 03, 2011 at 01:07:38PM -0400, Mike Pagano wrote:
<snipp previous sends>
> That last patch did test successfully. 
> 
> I have recombined the two checks into one and tested this patch. It now checks the split as suggested. 
> Thanks for the feedback, it's appreciated.
> ---
> 
> 
> Later versions of gcc include an option in the form of --param=name=value. This patch adds support for this.
> 
> Signed-off-by: Mike Pagano <mpagano at gentoo.org>
> ---
>  klcc/klcc.in |   14 +++++++++++---
>  1 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/klcc/klcc.in b/klcc/klcc.in
> index 711a832..a6f1523 100644
> --- a/klcc/klcc.in
> +++ b/klcc/klcc.in
> @@ -159,9 +159,17 @@ while ( defined($a = shift(@ARGV)) ) {
>  	# gcc options, that force preprocessing mode
>  	push(@ccopt, $a);
>  	$operation = 'E';
> -    } elsif ( $a eq '--param' ) {
> -	push(@ccopt, $a);
> -	push(@ccopt, shift(@ARGV));
> +	} elsif ( $a =~ /^--param/ ) {
> +	# support --param name=value and --param=name=value
> +	my @values=split('=', $a);
> +	if ( @values == 1 ) {

not beeing a Perl wizzard, I still wonder why that should be 1,
does perl follow c numbering, quick testing shows not:

cat /tmp/foo.pl 
#!/usr/bin/perl
use strict;
my @values;
my $string = "--param bla=bar";
@values = split('=', $string); 
if (@values == 2) {
	print "2: $values[1]\n";
} elsif (@values == 1) {
	print "1: $values[1]\n";
}

perl /tmp/foo.pl
2: bar

> +		push(@ccopt, $a);
> +		push(@ccopt, shift(@ARGV));
> +	}
> +	elsif ( @values == 3 ) {
> +		push(@ccopt, $values[0]);
> +		push(@ccopt, join('=', $values[1],$values[2]));
> +	}
>      } elsif ( $a =~ /^-[gp]/ || $a eq '-p' ) {
>  	# Debugging options to gcc
>  	push(@ccopt, $a);
> -- 
> 1.7.3.4

please really test both cases and if you agree that this magic
number is 2 then i can apply your patch with that change?

thank you.

-- 
maks



More information about the klibc mailing list