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

Mike Pagano mpagano at gentoo.org
Tue Aug 2 17:59:45 PDT 2011


On Friday 29 July 2011 10:38:42 maximilian attems wrote:
> On Wed, 20 Jul 2011, Mike Pagano wrote:
> > Later versions of gcc include an option in the form of
> > --param=name=value. This patch adds support for this and continues to
> > support the --param name=value option.
> > 
> > Signed-off-by: Mike Pagano <mpagano at gentoo.org>
> > ---
> > 
> >  klcc/klcc.in |   15 +++++++++++----
> >  1 files changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/klcc/klcc.in b/klcc/klcc.in
> > index 711a832..5d00bfd 100644
> > --- a/klcc/klcc.in
> > +++ b/klcc/klcc.in
> > @@ -159,10 +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 =~ /^-[gp]/ || $a eq '-p' ) {
> > +	} elsif ( $a =~ /(--param)[=]?/ ) {
> 
> shouldn't the match start with /^
> 
> > +	# support --param name=value and --param=name=value
> > +	push(@ccopt, $1);
> > +	$a =~ /[=](.*)/;
> 
> as a rule of thumb I don't like this .* matching,
> can you try it differently? maybe split helps?
> 
> > +	my $val = $1;
> > +	if ( $a =~ /[=]/ ) {
> > +		push(@ccopt, $val);
> > +	}
> > +	else {
> > +		push(@ccopt, shift(@ARGV));
> > +	} elsif ( $a =~ /^-[gp]/ || $a eq '-p' ) {
> 
> why is that last line changed?
> was it whitespace damaged?
> 
> >  	# Debugging options to gcc
> >  	push(@ccopt, $a);
> >  	$debugging = 1;
> 
> thank you.

Thanks for the input. I've attached a patch that keeps the check for --param and --param=name=value separate, took some of your pointers and hopefully simplied everything in a 
more acceptable manner.
---

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 |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/klcc/klcc.in b/klcc/klcc.in
index 711a832..c69389b 100644
--- a/klcc/klcc.in
+++ b/klcc/klcc.in
@@ -162,6 +162,13 @@ while ( defined($a = shift(@ARGV)) ) {
     } elsif ( $a eq '--param' ) {
 	push(@ccopt, $a);
 	push(@ccopt, shift(@ARGV));
+	} elsif ( $a =~ /^--param+=/ ) {
+	# support --param=name=value
+	my (@values) = split('=', $a);
+	if (@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



More information about the klibc mailing list