Skip to content

Commit

Permalink
lcov: fix whitespace handling in --rc command line option
Browse files Browse the repository at this point in the history
Specifying blanks around --rc options results in the options not
being correctly recognized, for example:

This doesn't work:
geninfo . -o - --rc="geninfo_adjust_src_path = /tmp => /usr"

This works:
geninfo . -o - --rc="geninfo_adjust_src_path=/tmp => /usr"

Fix this by automatically removing whitespaces at the start and end
of --rc options and values.
  • Loading branch information
Peter Oberparleiter authored and oberpar committed Jun 10, 2014
1 parent 4699f8d commit c3be5b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion bin/geninfo
Expand Up @@ -61,7 +61,7 @@ if( $^O eq "msys" )
}

# Constants
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.120 $)';
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.121 $)';
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
our $gcov_tool = "gcov";
our $tool_name = basename($0);
Expand Down Expand Up @@ -275,6 +275,16 @@ GetOptions("config-file=s" => \$opt_config_file,
"rc=s%" => \%opt_rc);
Getopt::Long::Configure("default");

# Remove spaces around rc options
while (my ($key, $value) = each(%opt_rc)) {
delete($opt_rc{$key});

$key =~ s/^\s+|\s+$//g;
$value =~ s/^\s+|\s+$//g;

$opt_rc{$key} = $value;
}

# Read configuration file if available
if (defined($opt_config_file)) {
$config = read_config($opt_config_file);
Expand Down
12 changes: 11 additions & 1 deletion bin/lcov
Expand Up @@ -71,7 +71,7 @@ use Cwd qw /abs_path getcwd/;


# Global constants
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.95 $)';
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.96 $)';
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
our $tool_name = basename($0);

Expand Down Expand Up @@ -228,6 +228,16 @@ GetOptions("config-file=s" => \$opt_config_file,
"rc=s%" => \%opt_rc);
Getopt::Long::Configure("default");

# Remove spaces around rc options
while (my ($key, $value) = each(%opt_rc)) {
delete($opt_rc{$key});

$key =~ s/^\s+|\s+$//g;
$value =~ s/^\s+|\s+$//g;

$opt_rc{$key} = $value;
}

# Read configuration file if available
if (defined($opt_config_file)) {
$config = read_config($opt_config_file);
Expand Down

0 comments on commit c3be5b6

Please sign in to comment.