From: Peter O. <obe...@us...> - 2012-10-05 15:10:01
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory vz-cvs-4.sog:/tmp/cvs-serv13595/bin Modified Files: genhtml Log Message: genhtml: fix source path prefix calculation Fix the following problems of the algorithm used to identify an optimal source path prefix: - the last two path components (filename and first parent directory) are ignored when trying to identify the optimal prefix - if a path prefix matches a longer path prefix, the weight of the filenames associated with the latter is incorrectly attributed to the former Index: genhtml =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/genhtml,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** genhtml 5 Oct 2012 12:00:57 -0000 1.64 --- genhtml 5 Oct 2012 15:09:58 -0000 1.65 *************** *** 172,176 **** sub get_info_entry($); sub set_info_entry($$$$$$$$$;$$$$$$); ! sub get_prefix(@); sub shorten_prefix($); sub get_dir_list(@); --- 172,176 ---- sub get_info_entry($); sub set_info_entry($$$$$$$$$;$$$$$$); ! sub get_prefix($@); sub shorten_prefix($); sub get_dir_list(@); *************** *** 740,744 **** { # Get prefix common to most directories in list ! $dir_prefix = get_prefix(@dir_list); if ($dir_prefix) --- 740,744 ---- { # Get prefix common to most directories in list ! $dir_prefix = get_prefix(1, keys(%info_data)); if ($dir_prefix) *************** *** 2151,2164 **** # ! # get_prefix(filename_list) # # Search FILENAME_LIST for a directory prefix which is common to as many # list entries as possible, so that removing this prefix will minimize the ! # sum of the lengths of all resulting shortened filenames. # ! sub get_prefix(@) { ! my @filename_list = @_; # provided list of filenames my %prefix; # mapping: prefix -> sum of lengths my $current; # Temporary iteration variable --- 2151,2165 ---- # ! # get_prefix(min_dir, filename_list) # # Search FILENAME_LIST for a directory prefix which is common to as many # list entries as possible, so that removing this prefix will minimize the ! # sum of the lengths of all resulting shortened filenames while observing ! # that no filename has less than MIN_DIR parent directories. # ! sub get_prefix($@) { ! my ($min_dir, @filename_list) = @_; my %prefix; # mapping: prefix -> sum of lengths my $current; # Temporary iteration variable *************** *** 2169,2178 **** # Need explicit assignment to get a copy of $_ so that # shortening the contained prefix does not affect the list ! $current = shorten_prefix($_); while ($current = shorten_prefix($current)) { # Skip rest if the remaining prefix has already been # added to hash ! if ($prefix{$current}) { last; } # Initialize with 0 --- 2170,2181 ---- # Need explicit assignment to get a copy of $_ so that # shortening the contained prefix does not affect the list ! $current = $_; while ($current = shorten_prefix($current)) { + $current .= "/"; + # Skip rest if the remaining prefix has already been # added to hash ! if (exists($prefix{$current})) { last; } # Initialize with 0 *************** *** 2182,2185 **** --- 2185,2199 ---- } + # Remove all prefixes that would cause filenames to have less than + # the minimum number of parent directories + foreach my $filename (@filename_list) { + my $dir = dirname($filename); + + for (my $i = 0; $i < $min_dir; $i++) { + delete($prefix{$dir."/"}); + $dir = shorten_prefix($dir); + } + } + # Calculate sum of lengths for all prefixes foreach $current (keys(%prefix)) *************** *** 2210,2213 **** --- 2224,2229 ---- } + $current =~ s/\/$//; + return($current); } |