| 1 |
#!/usr/bin/env perl |
| 2 |
require 5.003; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
# |
| 6 |
# Copyright by The HDF Group. |
| 7 |
# All rights reserved. |
| 8 |
# |
| 9 |
# This file is part of HDF4. The full HDF4 copyright notice, including |
| 10 |
# terms governing use, modification, and redistribution, is contained in |
| 11 |
# the COPYING file, which can be found at the root of the source code |
| 12 |
# distribution tree, or in https://www.hdfgroup.org/licenses. |
| 13 |
# If you do not have access to either file, you may request a copy from |
| 14 |
# [email protected]. |
| 15 |
# |
| 16 |
# Purpose: Given an input file containing the output from a build of the |
| 17 |
# library, gather the file names and line numbers, alias |
| 18 |
# identical types of warnings together into a single bin and |
| 19 |
# report the number of warnings for each type of warning, each file |
| 20 |
# and the total count of warnings |
| 21 |
|
| 22 |
# Perl modules/settings |
| 23 |
use strict; |
| 24 |
use Getopt::Std; |
| 25 |
|
| 26 |
# Global variables, for accumulating information |
| 27 |
my $totalcount = 0; |
| 28 |
my $notecount = 0; |
| 29 |
my $dupcount = 0; |
| 30 |
my %warn_count = (); |
| 31 |
my $warncount; |
| 32 |
my %warn_file = (); |
| 33 |
my %warn_file_line = (); |
| 34 |
my %warn_file_line_offset = (); |
| 35 |
my %file_count = (); |
| 36 |
my $filecount; |
| 37 |
my $ignorecount = 0; |
| 38 |
my @ignorenames; |
| 39 |
my %ignored_files = (); |
| 40 |
my %warn_file_indices = (); |
| 41 |
my %file_warn_indices = (); |
| 42 |
my @warn_match_strings; |
| 43 |
my @file_match_strings; |
| 44 |
my %file_warn = (); |
| 45 |
my %file_warn_line = (); |
| 46 |
my $current_warning = 0; |
| 47 |
my $current_file = 0; |
| 48 |
my $warn_index; |
| 49 |
my $genericize = 1; |
| 50 |
|
| 51 |
# Info about last name / line / offset for file |
| 52 |
my $last_c_name; |
| 53 |
my $last_fort_name; |
| 54 |
my $last_fort_line; |
| 55 |
my $last_fort_offset; |
| 56 |
|
| 57 |
# Display usage |
| 58 |
sub do_help { |
| 59 |
print "Usage: 'warnhist [-h, --help] [-t <prefix>] [-w <n>] [-W] [-f <n>] [-F] [-s <warning string list>] [-S <file string list] [-l] [-u] [-i <name list>] [file]'\n"; |
| 60 |
print "\t-h, --help\tDisplay this usage\n"; |
| 61 |
print "\t-t <prefix>\tTrim pathname prefix from filenames, <prefix>\n"; |
| 62 |
print "\t-w <n>\tDisplay files for a given warning index list, <n>\n"; |
| 63 |
print "\t\t<n> can be a single value, a range, or a comma separated list\n"; |
| 64 |
print "\t\tFor example: '0' or '0,4' or '8-10' or '0,2-4,8-10,13'\n"; |
| 65 |
print "\t-W\tDisplay files for all warnings\n"; |
| 66 |
print "\t-f <n>\tDisplay warnings for a given file index list, <n>\n"; |
| 67 |
print "\t\t<n> can be a single value, a range, or a comma separated list\n"; |
| 68 |
print "\t\tFor example: '0' or '0,4' or '8-10' or '0,2-4,8-10,13'\n"; |
| 69 |
print "\t-F\tDisplay warnings for all files\n"; |
| 70 |
print "\t-s <warning string list>\tDisplay files for warnings which contain a string, <warning string list>\n"; |
| 71 |
print "\t\t<warning string list> is a comma separated list, with no spaces\n"; |
| 72 |
print "\t\tFor example: 'Wunused-dummy-argument' or 'Wunused-dummy-argument,Wunused-variable'\n"; |
| 73 |
print "\t-S <file string list>\tDisplay warnings for files which contain a string, <file string list>\n"; |
| 74 |
print "\t\t<file string list> is a comma separated list, with no spaces\n"; |
| 75 |
print "\t\tFor example: 'H5Fint' or 'H5Fint,H5Gnode'\n"; |
| 76 |
print "\t-l\tDisplay line numbers for file/warning\n"; |
| 77 |
print "\t-u\tLeave 'unique' types in warnings, instead of genericizing them\n"; |
| 78 |
print "\t-i <name list>\tIgnore named files, <name list>\n"; |
| 79 |
print "\t\t<name list> is a comma separated list, with no spaces\n"; |
| 80 |
print "\t\tFor example: 'H5LTparse' or 'H5LTparse,H5LTanalyze'\n"; |
| 81 |
print "\tfile\tFilename containing build output\n"; |
| 82 |
print "\t\tIf no file is given, standard input is used.\n"; |
| 83 |
exit; |
| 84 |
} |
| 85 |
|
| 86 |
sub main::HELP_MESSAGE { |
| 87 |
do_help(); |
| 88 |
} |
| 89 |
|
| 90 |
# declare the Perl command line flags/options we want to allow |
| 91 |
my %options=(); |
| 92 |
getopts("FWhut:w:f:s:S:i:l", \%options); |
| 93 |
|
| 94 |
# Display usage, if requested |
| 95 |
if($options{h}) { |
| 96 |
do_help(); |
| 97 |
} |
| 98 |
|
| 99 |
# Parse list of file names to ignore |
| 100 |
if(exists $options{i}) { |
| 101 |
@ignorenames = split /,/, $options{i}; |
| 102 |
#print STDERR @ignorenames; |
| 103 |
} |
| 104 |
|
| 105 |
# Parse list of warning indices to expand file names |
| 106 |
if(exists $options{w}) { |
| 107 |
my @tmp_indices; |
| 108 |
|
| 109 |
@tmp_indices = split /,/, $options{w}; |
| 110 |
#print STDERR @tmp_indices; |
| 111 |
for my $x (@tmp_indices) { |
| 112 |
#print STDERR "x = '$x'\n"; |
| 113 |
if($x =~ /\-/) { |
| 114 |
my $start_index; |
| 115 |
my $end_index; |
| 116 |
|
| 117 |
#print STDERR "matched = '$x'\n"; |
| 118 |
($start_index, $end_index) = split /\-/, $x; |
| 119 |
#print STDERR "start_index = '$start_index', end_index = '$end_index'\n"; |
| 120 |
for my $y ($start_index..$end_index) { |
| 121 |
#print STDERR "y = '$y'\n"; |
| 122 |
if(!exists $warn_file_indices{$y}) { |
| 123 |
$warn_file_indices{$y} = $y; |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
else { |
| 128 |
if(!exists $warn_file_indices{$x}) { |
| 129 |
$warn_file_indices{$x} = $x; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
#foreach (sort keys %warn_file_indices) { |
| 134 |
# print STDERR "$_ : $warn_file_indices{$_}\n"; |
| 135 |
#} |
| 136 |
} |
| 137 |
|
| 138 |
# Parse list of warning strings to expand file names |
| 139 |
if(exists $options{s}) { |
| 140 |
@warn_match_strings = split /,/, $options{s}; |
| 141 |
# print STDERR @warn_match_strings; |
| 142 |
} |
| 143 |
|
| 144 |
# Parse list of file indices to expand warnings |
| 145 |
if(exists $options{f}) { |
| 146 |
my @tmp_indices; |
| 147 |
|
| 148 |
@tmp_indices = split /,/, $options{f}; |
| 149 |
#print STDERR @tmp_indices; |
| 150 |
for my $x (@tmp_indices) { |
| 151 |
#print STDERR "x = '$x'\n"; |
| 152 |
if($x =~ /\-/) { |
| 153 |
my $start_index; |
| 154 |
my $end_index; |
| 155 |
|
| 156 |
#print STDERR "matched = '$x'\n"; |
| 157 |
($start_index, $end_index) = split /\-/, $x; |
| 158 |
#print STDERR "start_index = '$start_index', end_index = '$end_index'\n"; |
| 159 |
for my $y ($start_index..$end_index) { |
| 160 |
#print STDERR "y = '$y'\n"; |
| 161 |
if(!exists $file_warn_indices{$y}) { |
| 162 |
$file_warn_indices{$y} = $y; |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
else { |
| 167 |
if(!exists $file_warn_indices{$x}) { |
| 168 |
$file_warn_indices{$x} = $x; |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
#foreach (sort keys %warn_file_indices) { |
| 173 |
# print STDERR "$_ : $warn_file_indices{$_}\n"; |
| 174 |
#} |
| 175 |
} |
| 176 |
|
| 177 |
# Parse list of warning strings for files to expand warnings |
| 178 |
if(exists $options{S}) { |
| 179 |
@file_match_strings = split /,/, $options{S}; |
| 180 |
# print STDERR @file_match_strings; |
| 181 |
} |
| 182 |
|
| 183 |
# Check if warnings should stay unique and not be "genericized" |
| 184 |
if($options{u}) { |
| 185 |
$genericize = 0; |
| 186 |
} |
| 187 |
|
| 188 |
PARSE_LINES: |
| 189 |
while (<>) { |
| 190 |
my $name; |
| 191 |
my $line; |
| 192 |
my $prev_line; |
| 193 |
my $toss; |
| 194 |
my $offset; |
| 195 |
my $warning; |
| 196 |
my $extra; |
| 197 |
my $extra2; |
| 198 |
|
| 199 |
# Retain last FORTRAN compile line, which comes a few lines before warning |
| 200 |
if($_ =~ /.*\.[fF]90:.*/) { |
| 201 |
($last_fort_name, $last_fort_line, $last_fort_offset) = split /\:/, $_; |
| 202 |
($last_fort_line, $toss) = split /\./, $last_fort_line; |
| 203 |
} |
| 204 |
|
| 205 |
# Retain last C/C++ compile line, which possibly comes a few lines before warning |
| 206 |
if($_ =~ /.*[A-Za-z0-9_]\.[cC]:.*/) { |
| 207 |
($last_c_name, $toss) = split /\:/, $_; |
| 208 |
} |
| 209 |
|
| 210 |
# Retain C/C++ compile line, which comes with the line of warning |
| 211 |
if($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) { |
| 212 |
$last_c_name = $_; |
| 213 |
} |
| 214 |
|
| 215 |
# Skip lines that don't have the word "warning" |
| 216 |
next if $_ !~ /[Ww]arning/; |
| 217 |
|
| 218 |
# Skip warnings from linker |
| 219 |
next if $_ =~ /ld: warning:/; |
| 220 |
|
| 221 |
# Skip warnings from build_py and install_lib |
| 222 |
next if $_ =~ /warning: (build_py|install_lib)/; |
| 223 |
|
| 224 |
# Skip variables with the word 'warning' in them |
| 225 |
next if $_ =~ /_warning_/; |
| 226 |
|
| 227 |
# Skip AMD Optimizing Compiler (aocc) lines "<#> warning(s) generated." |
| 228 |
next if $_ =~ / warnings? generated\./; |
| 229 |
|
| 230 |
# "Hide" the C++ '::' symbol until we've parsed out the parts of the line |
| 231 |
while($_ =~ /\:\:/) { |
| 232 |
$_ =~ s/\:\:/@@@@/g; |
| 233 |
} |
| 234 |
|
| 235 |
# Check for weird formatting of warning message |
| 236 |
$line = "??"; |
| 237 |
$offset = "??"; |
| 238 |
if($_ =~ /^cc1: warning:.*/) { |
| 239 |
$name = $last_c_name; |
| 240 |
($toss, $toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 241 |
# Check for CMAKE build with warning on first line and no filename |
| 242 |
} elsif($_ =~ /^\s*[Ww]arning:.*/) { |
| 243 |
$name = $last_c_name; |
| 244 |
($toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 245 |
# Check for file-scope gcc Fortran warning output |
| 246 |
} elsif($_ =~ /f\d\d\d: Warning:/) { |
| 247 |
# These are interspersed with the "compiling a file" output |
| 248 |
# when compiling with `make -j` and thus difficult to tie to |
| 249 |
# any particular file. They are due to things like inappropriate |
| 250 |
# build options and don't have a line number. |
| 251 |
# |
| 252 |
# They start with f, as in f951 |
| 253 |
$name = "(generic)"; |
| 254 |
$line = int(rand(1000000)); # Hack to avoid counting as duplictates |
| 255 |
|
| 256 |
($warning) = $_ =~ /\[(.*)\]/x; |
| 257 |
# Check for FORTRAN warning output |
| 258 |
} elsif($_ =~ /^Warning:.*/) { |
| 259 |
$name = $last_fort_name; |
| 260 |
$line = $last_fort_line; |
| 261 |
$offset = $last_fort_offset; |
| 262 |
($toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 263 |
|
| 264 |
# Check for improperly parsed filename or line |
| 265 |
if($name =~ /^$/) { |
| 266 |
print "Filename is a null string! Input line #$. is: '$_'"; |
| 267 |
next |
| 268 |
} |
| 269 |
if($line =~ /^$/) { |
| 270 |
print "Line is a null string! Input line #$. is: '$_'"; |
| 271 |
next |
| 272 |
} |
| 273 |
# Check for non-GCC warning (Solaris/Oracle?) |
| 274 |
} elsif($_ =~ /^\".*, line [0-9]+: *[Ww]arning:.*/) { |
| 275 |
($name, $toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 276 |
($name, $line) = split /\,/, $name; |
| 277 |
$name =~ s/^\"//g; |
| 278 |
$name =~ s/\"$//g; |
| 279 |
$line =~ s/^\s*line\s*//g; |
| 280 |
# Check for Intel icc warning |
| 281 |
} elsif($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) { |
| 282 |
($last_c_name, $toss, $warning) = split /\:/, $last_c_name; |
| 283 |
($name, $line) = split /\(/, $last_c_name; |
| 284 |
$line =~ s/\)//g; |
| 285 |
} else { |
| 286 |
# Check for 'character offset' field appended to file & line # |
| 287 |
# (This is probably specific to GCC) |
| 288 |
if($_ =~ /^.*[0-9]+\:[0-9]+\:/) { |
| 289 |
($name, $line, $offset, $toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 290 |
} else { |
| 291 |
($name, $line, $toss, $warning, $extra, $extra2) = split /\:/, $_; |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
# Check for extra ':' followed by more text in original warning string, |
| 296 |
# and append the ':' and text back onto the parsed warning |
| 297 |
# (Use 'length $extra' idiom to avoid warning when $extra is undefined) |
| 298 |
if(length $extra ) { |
| 299 |
$warning = join ':', $warning, $extra; |
| 300 |
} |
| 301 |
if(length $extra2 ) { |
| 302 |
$warning = join ':', $warning, $extra2; |
| 303 |
} |
| 304 |
|
| 305 |
# Restore the C++ '::' symbol now that we've parsed out the parts of the line |
| 306 |
while($warning =~ /@@@@/) { |
| 307 |
$warning =~ s/@@@@/\:\:/g; |
| 308 |
} |
| 309 |
|
| 310 |
# Trim leading '..' paths from filename |
| 311 |
while($name =~ /^\.\.\//) { |
| 312 |
$name =~ s/^\.\.\///g; |
| 313 |
} |
| 314 |
|
| 315 |
# Check for trimming prefix |
| 316 |
if((exists $options{t}) && ($name =~ /$options{t}/)) { |
| 317 |
$name =~ s/^$options{t}\///g; |
| 318 |
} |
| 319 |
|
| 320 |
# Check for ignored file |
| 321 |
if(exists $options{i}) { |
| 322 |
for my $x (@ignorenames) { |
| 323 |
if($name =~ /$x/) { |
| 324 |
$ignorecount++; |
| 325 |
if(!(exists $ignored_files{$name})) { |
| 326 |
$ignored_files{$name} = $name; |
| 327 |
} |
| 328 |
next PARSE_LINES; |
| 329 |
} |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
# Check for improperly parsed warning (usually an undefined warning string) |
| 334 |
if(!defined $warning) { |
| 335 |
print "Warning Undefined! Input line is: '$_'"; |
| 336 |
next |
| 337 |
} |
| 338 |
|
| 339 |
# Get rid of leading & trailing whitespace |
| 340 |
$warning =~ s/^\s//g; |
| 341 |
$warning =~ s/\s$//g; |
| 342 |
|
| 343 |
# Check for improperly parsed warning |
| 344 |
if($warning =~ /^$/) { |
| 345 |
print "Warning is a null string! Input line is: '$_'"; |
| 346 |
next |
| 347 |
} |
| 348 |
|
| 349 |
# Convert all quotes to ' |
| 350 |
$warning =~ s/‘/'/g; |
| 351 |
$warning =~ s/’/'/g; |
| 352 |
$warning =~ s/"/'/g; |
| 353 |
|
| 354 |
# |
| 355 |
# These skipped messages & "genericizations" may be specific to GCC |
| 356 |
|
| 357 |
# Skip supplemental warning message |
| 358 |
if($warning =~ /near initialization for/) { |
| 359 |
$notecount++; |
| 360 |
next |
| 361 |
} |
| 362 |
|
| 363 |
# Skip C++ supplemental warning message |
| 364 |
if($warning =~ /in call to/) { |
| 365 |
$notecount++; |
| 366 |
next |
| 367 |
} |
| 368 |
|
| 369 |
# Skip GCC warning that should be a note |
| 370 |
if($_ =~ /\(this will be reported only once per input file\)/) { |
| 371 |
$notecount++; |
| 372 |
next |
| 373 |
} |
| 374 |
|
| 375 |
if($genericize) { |
| 376 |
# Eliminate C/C++ "{aka <some type>}" and "{aka '<some type>'}" info |
| 377 |
if($warning =~ /\s(\{|\()aka '?[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\ ]*'?(\}|\))/) { |
| 378 |
$warning =~ s/\s(\{|\()aka '?[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\ ]*'?(\}|\))//g; |
| 379 |
} |
| 380 |
|
| 381 |
# Genericize C/C++ '<some type>', printf format '%<some format>', and |
| 382 |
# "unknown warning group" into '-' |
| 383 |
if($warning =~ /'[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=\ ]*'/) { |
| 384 |
$warning =~ s/'[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=\ ]*'/'-'/g; |
| 385 |
} |
| 386 |
if($warning =~ /'%[\#0\-\ \+]*[,;\:_]?[0-9\*]*\.?[0-9\*]*[hjltzL]*[aAcdeEfFgGinosuxX]'/) { |
| 387 |
$warning =~ s/'%[\#0\-\ \+]*[,;\:_]?[0-9\*]*\.?[0-9\*]*[hjltzL]*[aAcdeEfFgGinosuxX]'/'-'/g; |
| 388 |
} |
| 389 |
|
| 390 |
# Genericize C/C++ "<macro>" warnings into "-" |
| 391 |
if($warning =~ /"[A-Za-z_0-9]*"/) { |
| 392 |
$warning =~ s/"[A-Za-z_0-9]*"/"-"/g; |
| 393 |
} |
| 394 |
|
| 395 |
# Genericize [GCC?] C/C++ warning text about suggested attribute |
| 396 |
if($warning =~ /attribute=[A-Za-z_0-9]*\]/) { |
| 397 |
$warning =~ s/=[A-Za-z_0-9]*\]/=-\]/g; |
| 398 |
} |
| 399 |
|
| 400 |
# Genericize FORTRAN "at (<n>)" into "at (-)", "REAL(<n>)" into "REAL(-)", |
| 401 |
# and "INTEGER(<n>)" into "INTEGER(-)" |
| 402 |
if($warning =~ /.*at\s\([0-9]+\).*/) { |
| 403 |
$warning =~ s/at\s\([0-9]+\)/at \(-\)/g; |
| 404 |
} |
| 405 |
if($warning =~ /.*REAL\([0-9]+\).*/) { |
| 406 |
$warning =~ s/REAL\([0-9]+\)/REAL\(-\)/g; |
| 407 |
} |
| 408 |
if($warning =~ /.*INTEGER\([0-9]+\).*/) { |
| 409 |
$warning =~ s/INTEGER\([0-9]+\)/INTEGER\(-\)/g; |
| 410 |
} |
| 411 |
|
| 412 |
# Genericize standalone numbers in warnings |
| 413 |
if($warning =~ /(\s|')-?[0-9]+(\s|')/) { |
| 414 |
$warning =~ s/-?[0-9]+/-/g; |
| 415 |
} |
| 416 |
|
| 417 |
# Genericize unusual GCC/G++/GFORTRAN warnings that aren't handled above |
| 418 |
if($warning =~ /\[deprecation\] [A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]* has been deprecated.*/) { |
| 419 |
$warning =~ s/[A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]*/-\(-\) in -/g; |
| 420 |
} |
| 421 |
} |
| 422 |
# <end possible GCC-specific code> |
| 423 |
|
| 424 |
# Check if we've already seen this warning on this line in this file |
| 425 |
# (Can happen for warnings from inside header files) |
| 426 |
if( !exists $warn_file_line_offset{$warning}{$name}{$line}{$offset} ) { |
| 427 |
# Increment count for [generic] warning |
| 428 |
$warn_count{$warning}++; |
| 429 |
$warn_file{$warning}{$name}++; |
| 430 |
$warn_file_line{$warning}{$name}{$line}++; |
| 431 |
$warn_file_line_offset{$warning}{$name}{$line}{$offset}++; |
| 432 |
|
| 433 |
# Increment count for filename |
| 434 |
$file_count{$name}++; |
| 435 |
$file_warn{$name}{$warning}++; |
| 436 |
$file_warn_line{$name}{$warning}{$line}++; |
| 437 |
|
| 438 |
# Increment total count of warnings |
| 439 |
$totalcount++; |
| 440 |
} |
| 441 |
else { |
| 442 |
# Increment count of duplicate warnings |
| 443 |
$dupcount++; |
| 444 |
} |
| 445 |
|
| 446 |
# print STDERR "name = $name\n"; |
| 447 |
# print STDERR "line = $line\n"; |
| 448 |
# print STDERR "offset = $offset\n"; |
| 449 |
# print STDERR "warning = \"$warning\"\n"; |
| 450 |
} |
| 451 |
|
| 452 |
print "Total unique [non-ignored] warnings: $totalcount\n"; |
| 453 |
print "Ignored notes / supplemental warning lines [not counted in unique warnings]: $notecount\n"; |
| 454 |
print "Duplicated warning lines [not counted in unique warnings]: $dupcount\n"; |
| 455 |
print "Total ignored warnings: $ignorecount\n"; |
| 456 |
$warncount = keys %warn_count; |
| 457 |
print "Total unique kinds of warnings: $warncount\n"; |
| 458 |
$filecount = keys %file_count; |
| 459 |
print "Total files with warnings: $filecount\n\n"; |
| 460 |
|
| 461 |
# Print warnings in decreasing frequency |
| 462 |
print "# of Warnings by frequency (file count)\n"; |
| 463 |
print "=======================================\n"; |
| 464 |
for my $x (sort {$warn_count{$b} <=> $warn_count{$a}} keys(%warn_count)) { |
| 465 |
printf ("[%2d] %4d (%2d) - %s\n", $current_warning++, $warn_count{$x}, scalar(keys %{$warn_file{$x}}), $x); |
| 466 |
if((exists $options{W}) || (exists $options{w}) || (exists $options{s})) { |
| 467 |
my $curr_index = $current_warning - 1; |
| 468 |
my $match = 0; |
| 469 |
|
| 470 |
# Check for string from list in current warning |
| 471 |
if(exists $options{s}) { |
| 472 |
for my $y (@warn_match_strings) { |
| 473 |
# print STDERR "y = '$y'\n"; |
| 474 |
if($x =~ /$y/) { |
| 475 |
# print STDERR "matched warning = '$x'\n"; |
| 476 |
$match = 1; |
| 477 |
last; |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
# Check if current warning index matches |
| 483 |
if((exists $warn_file_indices{$curr_index}) && $curr_index == $warn_file_indices{$curr_index}) { |
| 484 |
$match = 1; |
| 485 |
} |
| 486 |
|
| 487 |
if($match) { |
| 488 |
for my $y (sort {$warn_file{$x}{$b} <=> $warn_file{$x}{$a}} keys(%{$warn_file{$x}})) { |
| 489 |
printf ("\t%4d - %s\n", $warn_file{$x}{$y}, $y); |
| 490 |
if(exists $options{l}) { |
| 491 |
my $lines = join ", ", sort {$a <=> $b} keys %{$warn_file_line{$x}{$y}}; |
| 492 |
printf("\t\tLines: $lines \n"); |
| 493 |
} |
| 494 |
} |
| 495 |
} |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
# Print warnings in decreasing frequency, by filename |
| 500 |
print "\n# of Warnings by filename (warning type)\n"; |
| 501 |
print "========================================\n"; |
| 502 |
for my $x (sort {$file_count{$b} <=> $file_count{$a}} keys(%file_count)) { |
| 503 |
printf ("[%3d] %4d (%2d) - %s\n", $current_file++, $file_count{$x}, scalar(keys %{$file_warn{$x}}), $x); |
| 504 |
if((exists $options{F}) || (exists $options{f}) || (exists $options{S})) { |
| 505 |
my $curr_index = $current_file - 1; |
| 506 |
my $match = 0; |
| 507 |
|
| 508 |
# Check for string from list in current file |
| 509 |
if(exists $options{S}) { |
| 510 |
for my $y (@file_match_strings) { |
| 511 |
# print STDERR "y = '$y'\n"; |
| 512 |
if($x =~ /$y/) { |
| 513 |
# print STDERR "matched warning = '$x'\n"; |
| 514 |
$match = 1; |
| 515 |
last; |
| 516 |
} |
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
# Check if current file index matches |
| 521 |
if((exists $file_warn_indices{$curr_index}) && $curr_index == $file_warn_indices{$curr_index}) { |
| 522 |
$match = 1; |
| 523 |
} |
| 524 |
|
| 525 |
if($match) { |
| 526 |
for my $y (sort {$file_warn{$x}{$b} <=> $file_warn{$x}{$a}} keys(%{$file_warn{$x}})) { |
| 527 |
printf ("\t%4d - %s\n", $file_warn{$x}{$y}, $y); |
| 528 |
if(exists $options{l}) { |
| 529 |
my $lines = join ", ", sort {$a <=> $b} keys %{$file_warn_line{$x}{$y}}; |
| 530 |
printf("\t\tLines: $lines \n"); |
| 531 |
} |
| 532 |
} |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
# Print names of files that were ignored |
| 538 |
# Check for ignored file |
| 539 |
if(exists $options{i}) { |
| 540 |
print "\nIgnored filenames\n"; |
| 541 |
print "=================\n"; |
| 542 |
for my $x (sort keys(%ignored_files)) { |
| 543 |
print "$x\n"; |
| 544 |
} |
| 545 |
} |
| 546 |
|