Skip to content

Commit

Permalink
Fix #283: callback parameters should be either single comma-separated…
Browse files Browse the repository at this point in the history
… string or list of individual arguments.

See

Signed-off-by: Henry Cox <[email protected]>
  • Loading branch information
henry2cox committed Apr 10, 2024
1 parent 00b1654 commit 1789981
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 16 deletions.
7 changes: 6 additions & 1 deletion lib/lcovutil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,12 @@ sub do_mangle_check

sub configure_callback
{
my @args = split($lcovutil::split_char, join($lcovutil::split_char, @_));
# if there is just one argument, then assume it might be a
# concatentation - otherwise, just use straight.
my @args =
1 == scalar(@_) ?
split($lcovutil::split_char, join($lcovutil::split_char, @_)) :
@_;
my $script = $args[0];
my $rtn;
if ($script =~ /\.pm$/) {
Expand Down
67 changes: 52 additions & 15 deletions man/genhtml.1
Original file line number Diff line number Diff line change
Expand Up @@ -532,21 +532,25 @@ if the source file is not found by the callback.
.RE

.IP 2. 3
The option may be specified as a
The option may be specified as a single
.I split_char
separated string (see
separated string which is divied into words (see
.B man lcovrc(5)
) - which is divied into words. The resulting command line is passed
to a shell interpreter to run the script.
This includes the script path followed by optional additional parameters
), or as a list of arguments.
The resulting command line is passed
to a shell interpreter to be executed.
The command line includes the script path followed by optional additional parameters
separated by spaces. Care must be taken to provide proper quoting if script
path or any parameter contains spaces or shell special characters.
.PP

.IP 3. 3
If an option is specified multiple times, all of the parameters are
split as described above, then concatentated to form the command line.
If an option is specified multiple times, then the parameters are
.I not
split, but are simply concatentated to form the command line - see the examples, below.
.br
For simplicity and ease of understanding: your command line should
pass all arguments individually, or all as a comma-separated list - not a mix of the two.
.PP

.IP 4. 3
Expand All @@ -562,19 +566,19 @@ Example:
.RS
genhtml --annotate-script /bin/script.sh
.br
--annotate-script "full" ...
--annotate-script arg0 ...
.br

results in the same callback as

.br
genhtml --annotate-script "/bin/script.sh full" ...
genhtml --annotate-script "/bin/script.sh arg0" ...
.br

or

.br
genhtml --annotate-script /bin/script.sh,full ...
genhtml --annotate-script /bin/script.sh,arg0 ...
.br

Note that the first form is preferred.
Expand All @@ -587,7 +591,7 @@ callback executes the command line:
.br

.RS
/bin/script.sh "full"
/bin/script.sh arg0
.I source_file_name
.RE
.br
Expand All @@ -598,13 +602,13 @@ Similarly
genhtml --annotate-script
.I /bin/myMoodule.pm
.br
--annotate-script "full" ...
--annotate-script arg0 --annotate-script arg1 ...
.br

or
.br
genhtml --annotate-script
.I /bin/myMoodule.pm,full
.I /bin/myMoodule.pm,arg0,arg1
.br

.br
Expand All @@ -616,10 +620,14 @@ executing
.br

.RS
$annotateCallback = myModule->new("full");
$annotateCallback = myModule->new(arg0, arg1);
.RE

to initialize the class object, and then to execute
to initialize the class object -
.I arg0
and
.I arg1
passed as strings - and then to execute

.RS
($status, $arrayRef) = $annotateCallback(
Expand All @@ -629,6 +637,35 @@ to initialize the class object, and then to execute

to retrieve the annotation information.

In contrast, the command
.br
.RS
genhtml --annotate-script
.I /bin/myMoodule.pm
.br
--annotate-script arg0,arg1 ...
.RE
would result in
.B genhtml
initializing the callback object via
.br

.RS
$annotateCallback = myModule->new("arg0,arg1");
.RE
where "arg0,arg1" is passed as single comma-separated string.

Similarly, the command
.br
.RS
genhtml --annotate-script
.I /bin/myMoodule.pm,arg0
.br
--annotate-script arg1 ...
.RE
would very likely result in an error when genhtml tries to find
a script called "/bin/mymodule.pm,arg0".


Note that multiple instances of each script may execute simultaneously if the
.B \-\-parallel
Expand Down

0 comments on commit 1789981

Please sign in to comment.