showbldlog.pl to HTML.

index -|- end

Generated: Sat Oct 24 16:35:28 2020 from showbldlog.pl 2016/10/01 25.9 KB. text copy

#!/usr/bin/perl -w
# NAME: showbldlog.pl
# AIM: Read a bldlog-1.txt file, and show some information
# 2016-10-01 - DO NOT repeat error outputs
# 2016-09-07 - Some small improvements
# 2016-08-11 - Initial cut
use strict;
use warnings;
use File::Basename;  # split path ($name,$dir,$ext) = fileparse($file [, qr/\.[^.]*/] )
use Cwd;
my $os = $^O;
my $perl_dir = '/home/geoff/bin';
my $PATH_SEP = '/';
my $temp_dir = '/tmp';
if ($os =~ /win/i) {
    $perl_dir = 'C:\GTools\perl';
    $temp_dir = $perl_dir;
    $PATH_SEP = "\\";
}
unshift(@INC, $perl_dir);
require 'lib_utils.pl' or die "Unable to load 'lib_utils.pl' Check paths in \@INC...\n";
# log file stuff
our ($LF);
my $pgmname = $0;
if ($pgmname =~ /(\\|\/)/) {
    my @tmpsp = split(/(\\|\/)/,$pgmname);
    $pgmname = $tmpsp[-1];
}
my $outfile = $temp_dir.$PATH_SEP."temp.$pgmname.txt";
open_log($outfile);

# user variables
my $VERS = "0.0.6 2016-08-12";
my $load_log = 0;
my $in_file = '';
my $verbosity = 0;
my $out_file = '';

# ### DEBUG ###
my $debug_on = 0;
my $def_file = 'X:\build-fg.x64\bldlog-1.txt';

### program variables
my @warnings = ();
my $cwd = cwd();

sub VERB1() { return $verbosity >= 1; }
sub VERB2() { return $verbosity >= 2; }
sub VERB5() { return $verbosity >= 5; }
sub VERB9() { return $verbosity >= 9; }

sub show_warnings($) {
    my ($val) = @_;
    if (@warnings) {
        prt( "\nGot ".scalar @warnings." WARNINGS...\n" );
        foreach my $itm (@warnings) {
           prt("$itm\n");
        }
        prt("\n");
    } else {
        prt( "\nNo warnings issued.\n\n" ) if (VERB9());
    }
}

sub pgm_exit($$) {
    my ($val,$msg) = @_;
    if (length($msg)) {
        $msg .= "\n" if (!($msg =~ /\n$/));
        prt($msg);
    }
    show_warnings($val);
    close_log($outfile,$load_log);
    exit($val);
}


sub prtw($) {
   my ($tx) = shift;
   $tx =~ s/\n$//;
   prt("$tx\n");
   push(@warnings,$tx);
}

# Project "X:\build-fg.x64\ALL_BUILD.vcxproj" (1) is building "X:\build-fg.x64\utils\GPSsmooth\GPSsmooth.vcxproj" (3) on node 1 (default targets).
sub get_project($$) {
    my ($line,$ra) = @_;
    my $proj = "Not found";
    my ($tmp,$max,$i);
    my ($n,$d,$e);
    $max = scalar @{$ra};
    for ($i = 0; $i < $max; $i++) {
        $tmp = ${$ra}[$i];
        ($n,$d,$e) = fileparse($tmp, qr/\.[^.]*/);
        if ($e =~ /\.vcxproj/i) {
            $proj = $n; # get the LAST name
        }
    }
    return $proj;
}

# split_space - space_split - 
# like split(/\s/,$txt), but honour double inverted commas
# also accept and split '"something"/>', but ONLY if in the tail
# 2010/05/05 - also want to avoid a tag of '"zlib">'
# 2016/08/12 - avoid closing quote text if '\"' = FAILED!!!!!!!!
sub space_split2 {
   my ($txt) = shift;
   my $len = length($txt);
   my ($k, $ch, $tag, $incomm, $k2, $nch, $pc);
   my @arr = ();
   $tag = '';
   $incomm = 0;
    $ch = '';
   for ($k = 0; $k < $len; $k++) {
        $pc = $ch# keep previous
      $ch = substr($txt,$k,1);
        $k2 = $k + 1;
        $nch = ($k2 < $len) ? substr($txt,$k2,1) : "";
      if ($incomm) {
         $incomm = 0 if ($ch eq '"');
         # $incomm = 0 if (($ch eq '"')&&($pc ne '\\'));
         $tag .= $ch;
            # add 2010/05/05 to avoid say '"zlib">' begin a tag
            if (!$incomm) {
                push(@arr,$tag);
                $tag = '';
            }
      } elsif ($ch =~ /\s/) { # any spacey char
            push(@arr, $tag) if (length($tag));
         $tag = '';
      } elsif (($ch =~ /\//)&&($nch eq '>')) { # 04/10/2008, but only if before '>' 24/09/2008 add this as well
         push(@arr, $tag) if (length($tag));
         $tag = $ch; # restart tag with this character
      } else {
         $tag .= $ch;
         $incomm = 1 if ($ch eq '"');
      }
   }
   push(@arr, $tag) if (length($tag));
   return @arr;
}

# 57:   C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe 
# /c /IX:\flightgear\3rdparty\iaxclient\lib /I"X:\install\msvc100-64\OpenSceneGraph\include" 
# /I"X:\install\msvc100-64\boost\include\boost-1_53" /IX:\3rdParty.x64\include 
# /I"X:\install\msvc100-64\simgear\include" /I"X:\install\msvc100-64\simgear\include\simgear\3rdparty\utf8" 
# /IX:\flightgear\3rdparty\sqlite3 /IX:\flightgear /IX:\flightgear\src /I"X:\build-fg.x64\src" 
# /I"X:\build-fg.x64\src\Include" /IX:\flightgear\3rdparty\hts_engine_API\include 
# /IX:\flightgear\3rdparty\flite_hts_engine\include
# /Zi /nologo /W3 /WX- /MP /Od /Ob0 /D WIN32 /D _WINDOWS /D NOMINMAX /D _USE_MATH_DEFINES 
# /D _CRT_SECURE_NO_WARNINGS /D _SCL_SECURE_NO_WARNINGS /D __CRT_NONSTDC_NO_WARNINGS 
# /D _REENTRANT /D BOOST_BIMAP_DISABLE_SERIALIZATION /D _DEBUG /D HAVE_CONFIG_H /D "CMAKE_INTDIR=\"Debug\"" 
# /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"GPSsmooth.dir\Debug\\" 
# /Fd"GPSsmooth.dir\Debug\vc100.pdb" /Gd /TP /errorReport:queue 
# ..\..\..\flightgear\utils\GPSsmooth\GPSsmooth.cxx ..\..\..\flightgear\utils\GPSsmooth\gps_main.cxx  
# /bigobj 

# begin
# Project "X:\build-fg.x64\ALL_BUILD.vcxproj" (1) is building "X:\build-fg.x64\utils\GPSsmooth\GPSsmooth.vcxproj" (3) on node 1 (default targets).
# stages
# InitializeBuildStatus:
#  Creating "hts_engine.dir\Debug\hts_engine.unsuccessfulbuild" because "AlwaysCreate" was specified.
#CustomBuild:
#  All outputs are up-to-date.
#ClCompile:
#  All outputs are up-to-date.
#Lib:
#  All outputs are up-to-date.
#  hts_engine.vcxproj -> X:\build-fg.x64\3rdparty\hts_engine_API\Debug\hts_engined.lib
#FinalizeBuildStatus:
#  Deleting file "hts_engine.dir\Debug\hts_engine.unsuccessfulbuild".
#  Touching "hts_engine.dir\Debug\hts_engine.lastbuildstate".
# end
# Done Building Project "X:\build-fg.x64\utils\GPSsmooth\GPSsmooth.vcxproj" (default targets).

# Lib:
#  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\Lib.exe 
# /OUT:"X:\build-fg.x64\src\FDM\JSBSim\Debug\JSBSimd.lib" 
# /NOLOGO JSBSim.dir\Debug\FGFDMExec.obj
#    SBSim.dir\Debug\FGJSBBase.obj
#  ....
#   JSBSim.dir\Debug\FGTurboProp.obj
#   JSBSim.vcxproj -> X:\build-fg.x64\src\FDM\JSBSim\Debug\JSBSimd.lib
# FinalizeBuildStatus:

# Link:
#  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\link.exe 
#   /ERRORREPORT:QUEUE /OUT:"X:\build-fg.x64\utils\GPSsmooth\Debug\GPSsmooth.exe" 
#   /INCREMENTAL /NOLOGO /FORCE:MULTIPLE 
#    kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib 
#    advapi32.lib "X:\install\msvc100-64\simgear\lib\SimGearCored.lib" 
#    "X:\install\msvc100-64\simgear\lib\SimGearCored.lib" X:\3rdParty.x64\lib\zlib.lib winmm.lib ws2_32.lib 
#     X:\3rdParty.x64\lib\libcurl_imp.lib X:\3rdParty.x64\lib\sg.lib X:\3rdParty.x64\lib\ul.lib 
#     /MANIFEST /ManifestFile:"GPSsmooth.dir\Debug\GPSsmooth.exe.intermediate.manifest" 
#     /MANIFESTUAC:"level='asInvoker' 
#     uiAccess='false'" /DEBUG /PDB:"X:/build-fg.x64/utils/GPSsmooth/Debug/GPSsmooth.pdb" 
#     /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"X:/build-fg.x64/utils/GPSsmooth/Debug/GPSsmooth.lib" 
#     /MACHINE:X64 GPSsmooth.dir\Debug\GPSsmooth.exe.embed.manifest.res
#  GPSsmooth.dir\Debug\GPSsmooth.obj
#  GPSsmooth.dir\Debug\gps_main.obj  /machine:x64 
#LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification [X:\build-fg.x64\utils\GPSsmooth\GPSsmooth.vcxproj]
#LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library [X:\build-fg.x64\utils\GPSsmooth\GPSsmooth.vcxproj]
#  GPSsmooth.vcxproj -> X:\build-fg.x64\utils\GPSsmooth\Debug\GPSsmooth.exe
#Manifest:


# The target "_ConvertPdbFiles" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist in the project, and will be ignored.
# The target "_CollectPdbFiles" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,70)" does not exist in the project, and will be ignored.

my %all_projects = ();
my %link_out = ();
my %lib_out = ();

my %all_defines = ();
my %all_includes = ();
my %all_others = ();
my %all_sources = ();

sub process_in_file($) {
    my ($inf) = @_;
    if (! open INF, "<$inf") {
        pgm_exit(1,"ERROR: Unable to open file [$inf]\n"); 
    }
    my @lines = <INF>;
    close INF;
    my $lncnt = scalar @lines;
    prt("Processing $lncnt lines, from [$inf]...\n");
    my ($ln,$line,$inc,$lnn,@arr,$cnt,$max,$i,$ch,$proj,$i2,$x2,$tmp);
    my (@defines,@includes,@others,@sources);
    my ($scnt,$dcnt,$icnt,$ocnt,$msg,$clnn);
    my ($n,$d,$e);
    my @proj_stack = ();
    my @projects = ();
    my @warns = ();
    my @error = ();
    my $had_allbld = 0;
    my %shown_errors = ();
    $lnn = 0;
    $proj = 'None yet';
    for ($ln = 0; $ln < $lncnt; $ln++) {
        $line = $lines[$ln];
        chomp $line;
        $lnn = $ln + 1;
        $clnn = sprintf("%4d",$lnn);
        # @arr = split(/\s+/,$line);
        @arr = space_split2($line); # honour double inverted commas
        $max = scalar @arr;
        @defines = ();
        @includes = ();
        @others = ();
        @sources = ();
        if ($line =~ /^Project\s+/) {
            # prt("$line\n");
            $proj = get_project($line,\@arr);
            prt("Build $proj\n") if (VERB2());
            $had_allbld = 1 if ($proj eq 'ALL_BUILD');
            push(@proj_stack,$proj);
        } elsif ($line =~ /^InitializeBuildStatus:/) {
            #  Creating "hts_engine.dir\Debug\hts_engine.unsuccessfulbuild" because "AlwaysCreate" was specified.
        } elsif ($line =~ /^PrepareForBuild:/) {

        } elsif ($line =~ /^MakeDirsForCl:/) {

        } elsif ($line =~ /^PreBuildEvent:/) {

        } elsif ($line =~ /^CustomBuild:/) {
            #  All outputs are up-to-date.
        } elsif ($line =~ /^ResourceCompile:/) {

        } elsif ($line =~ /^ClCompile:/) {
            #  All outputs are up-to-date.
        } elsif ($line =~ /^Lib:/) {
            #  All outputs are up-to-date.
            #  hts_engine.vcxproj -> X:\build-fg.x64\3rdparty\hts_engine_API\Debug\hts_engined.lib
        } elsif ($line =~ /^Link:/) {
            #   C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\link.exe ...
        } elsif ($line =~ /^ManifestResourceCompile:/) {

        } elsif ($line =~ /^Manifest:/) {
            
        } elsif ($line =~ /^LinkEmbedManifest:/) {

        } elsif ($line =~ /^FinalizeBuildStatus:/) {
            #  Deleting file "hts_engine.dir\Debug\hts_engine.unsuccessfulbuild".
            #  Touching "hts_engine.dir\Debug\hts_engine.lastbuildstate".
        } elsif ($line =~ /^Done Building Project\s+/) {
            # prt("$line\n");
            $proj = get_project($line,\@arr);
            $msg = "Not LAST!";
            if (@proj_stack) {
                $tmp = $proj_stack[-1];
                if ($tmp eq $proj) {
                    pop @proj_stack;
                    $msg = 'ok';

                }
            }
            prt("End Build $proj - $msg\n") if (VERB2() || ($msg ne 'ok'));
            $had_allbld = 0 if ($proj eq 'ALL_BUILD');
        } elsif ($line =~ /CL\.exe/i) {
            ########## COMPILE #########
            #prt("$lnn: $line\n");
            #prt("$lnn: ".join("|",@arr)."\n");
            for ($i = 0; $i < $max; $i++) {
                $inc = $arr[$i];
                if ($inc =~ /CL\.exe/i) {
                    prt("$lnn:$i: Found cl.exe...\n") if (VERB9());
                    $i++;
                    last;
                }
            }
            for (; $i < $max; $i++) {
                $i2 = $i + 1;
                $inc = $arr[$i];
                if ($inc =~ /^\//) {
                    $inc = substr($inc,1);
                    $ch = substr($inc,0,1);
                    if ($ch eq 'D') {
                        $inc = substr($inc,1);
                        if (length($inc) == 0) {
                            if ($i2 < $max) {
                                $i++;
                                $inc = $arr[$i];
                            }
                        }
                        if (length($inc)) {
                            if (defined $all_defines{$inc}) {
                                $all_defines{$inc}++;
                            } else {
                                $all_defines{$inc} = 1;
                            }
                            push(@defines,$inc);
                            prt("$lnn: Define: /D $inc\n") if (VERB9());
                        }
                    } elsif ($ch eq 'I') {
                        $inc = substr($inc,1);
                        $all_includes{$inc} = 1;
                        push(@includes,$inc);
                    } else {
                        $all_others{$inc} = 1;
                        push(@others,$inc);
                    }
                } else {
                    $all_sources{$inc} = 1;
                    push(@sources,$inc);
                }
            }
            $dcnt = scalar @defines;
            $icnt = scalar @includes;
            $ocnt = scalar @others;
            $scnt = scalar @sources;
            prt("$clnn:$proj: CL.exe - $dcnt defines, $icnt includes, $ocnt others, $scnt sources\n");
            ##########################################################################################
        } elsif ($line =~ /Lib\.exe/i) {
            ####### LIB,EXE #####
            for ($i = 0; $i < $max; $i++) {
                $inc = $arr[$i];
                if ($inc =~ /Lib\.exe/i) {
                    prt("$lnn:$i: Found Lib.exe...\n") if (VERB9());
                    $i++;
                    last;
                }
            }
            for (; $i < $max; $i++) {
                $i2 = $i + 1;
                $inc = $arr[$i];
                if ($inc =~ /^\//) {
                    $inc = substr($inc,1);
                    $ch = substr($inc,0,1);
                    push(@others,$inc);
                    if ($inc =~ /^OUT:(.+)$/) {
                        $tmp = strip_double_quotes($1);
                        $lib_out{$tmp} = 1;
                        prt("$lnn:$i: Lib OUT: '$tmp'\n") if (VERB5());
                    }
                } else {
                    push(@sources,$inc);
                }
            }
            $x2 = $ln + 1;
            for (; $x2 < $lncnt; $x2++) {
                $tmp = $lines[$x2];
                chomp $tmp;
                if ($tmp =~ /^\s+(.+)$/) {
                    $tmp = trim_all($tmp);
                    push(@sources,$tmp);
                } else {
                    last;
                }
            }
            #### $i2--;
            ### $ln = $l2;
            $dcnt = scalar @defines;
            $icnt = scalar @includes;
            $ocnt = scalar @others;
            $scnt = scalar @sources;
            prt("$clnn:$proj: Lib.exe - $dcnt defines, $icnt includes, $ocnt others, $scnt sources\n");
            ############################################################################################
        } elsif ($line =~ /Link\.exe/i) {
            ##### LINK.EXE #####
            for ($i = 0; $i < $max; $i++) {
                $inc = $arr[$i];
                if ($inc =~ /Link\.exe/i) {
                    prt("$lnn:$i:$max: Found Link.exe...\n") if (VERB9());
                    $i++;
                    last;
                }
            }
            # prt("$lnn: $line\n");
            for (; $i < $max; $i++) {
                $i2 = $i + 1;
                $inc = strip_double_quotes($arr[$i]);
                if ($inc =~ /^\//) {
                    $inc = substr($inc,1);
                    $ch = substr($inc,0,1);
                    #prt("$lnn:$i: $inc (switch)\n");
                    push(@others,$inc);
                    if ($inc =~ /^OUT:(.+)$/) {
                        $tmp = strip_double_quotes($1);
                        prt("$lnn:$i: Link OUT: '$tmp'\n") if (VERB5());
                        $link_out{$tmp} = 1;
                    }
                } else {
                    ($n,$d,$e) = fileparse($inc, qr/\.[^.]*/);
                    #prt("$lnn:$i: $inc ($n,$d,$e)\n");
                    if ($inc =~ /=/) {
                        push(@others,$inc);
                    } elsif ($e =~ /\.lib$/i) {
                        push(@defines,$inc);
                    } elsif ($e =~ /\.res$/i) {
                        push(@includes,$inc);
                    } else {
                        push(@sources,$inc);
                    }
                }
            }
            $x2 = $ln + 1;
            for (; $x2 < $lncnt; $x2++) {
                $tmp = $lines[$x2];
                chomp $tmp;
                if ($tmp =~ /^\s+(.+)$/) {
                    $tmp = trim_all($tmp);
                    if ($tmp =~ /\s+/) {
                        my @a = space_split2($tmp);
                        foreach $tmp (@a) {
                            if ($tmp =~ /^\//) {
                                $tmp = substr($tmp,1);
                                push(@others,$tmp);
                            } else {
                                push(@sources,$tmp);
                            }
                        }
                    } else {
                        push(@sources,$tmp);
                    }
                } else {
                    last;
                }
            }
            $dcnt = scalar @defines;
            $icnt = scalar @includes;
            $ocnt = scalar @others;
            $scnt = scalar @sources;
            prt("$clnn:$proj: Link.exe - $dcnt libraries, $icnt res, $ocnt others, $scnt sources\n");
            #########################################################################################
        } else {
            if ($line =~ /^\s+/) {
                # usually continuation lines
            } else {
                if ($had_allbld) {
                    if ($line =~ /\s+warning\s+/) {
                        # TODO: Show warning
                        prt("$lnn:W: $line\n") if (VERB5());
                        push(@warns,[$lnn,$line,$proj]);
                    } elsif ($line =~ /\s+error\s+/) {
                        # TODO: Show error
                        if (! defined $shown_errors{$line}) {
                            prt("$lnn:E:$proj: $line\n");
                            $shown_errors{$line} = 1;
                        }

                        push(@error,[$lnn,$line,$proj]);
                    } elsif ($line =~ /^The\s+target\s+\"(\w+)\"\s+listed\s+/) {
                        # skip this stuff
                    } else {
                        prtw("WARNING: $lnn: $line - not parsed! ***CEHCK ME***\n");
                    }
                }
            }
        }
    }
    # summary
    @defines = sort keys %all_defines;
    @includes = sort keys %all_includes;
    @others = sort keys %all_others;
    @sources = sort keys %all_sources;
    $dcnt = scalar @defines;
    $icnt = scalar @includes;
    $ocnt = scalar @others;
    $scnt = scalar @sources;
    my $libcnt = scalar keys %lib_out;
    my $execnt = scalar keys %link_out;
    my $wncnt = scalar @warns;
    my $ercnt = scalar @error;
    prt("Total - $dcnt def, $icnt inc, $ocnt others, $scnt srcs, OUT: libs $libcnt, exe $execnt - $wncnt warns, $ercnt errors\n");
    ##prt("Defines: ".join("\n/D ",@defines)."\n");
    my ($btxt,$etxt,$val,$cval,$typ);
    prt("Total: Errors: $ercnt, Warnings: $wncnt\n");
    if (VERB1()) {
        my ($ra);
        my %cwarns = ();
        my %lwarns = ();
        my %dwarns = ();
        my %awarns = ();
        if ($wncnt) {
            prt("\nNote: $wncnt warnings...\n");
            foreach $ra (@warns) {
                $lnn = ${$ra}[0];
                $line = ${$ra}[1];
                $proj = ${$ra}[2];
                # X:\flightgear\3rdparty\iaxclient\lib\libspeex\cb_search.c(133): warning C4311: 'type cast': pointer truncation from 'char *' to 'long' [X:\build-fg\3rdparty\iaxclient\lib\iaxclient_lib.vcxproj]
                if ($line =~ /^(.+)\s+warning\s+(.+)$/) {
                    $btxt = $1;
                    $etxt = $2;
                    if ($etxt =~ /C(\d{4}):\s+/) {
                        $val = $1;
                        if (defined $cwarns{$val}) {
                            $cwarns{$val}++;
                        } else {
                            prt("$lnn:$proj:C$val:\n") if (VERB5());
                            $cwarns{$val} = 1;
                            $cval = "C$val";
                            $awarns{$cval} = [$btxt,$etxt,$proj];
                        }
                    } elsif ($etxt =~ /LNK(\d{4}):\s+/) {
                        $val = $1;
                        if (defined $lwarns{$val}) {
                            $lwarns{$val}++;
                        } else {
                            prt("$lnn:$proj:C$val:\n") if (VERB5());
                            $lwarns{$val} = 1;
                            $cval = "LNK$val";
                            $awarns{$cval} = [$btxt,$etxt,$proj];
                        }
                    } elsif ($etxt =~ /D(\d{4}):\s+/) {
                        $val = $1;
                        if (defined $dwarns{$val}) {
                            $dwarns{$val}++;
                        } else {
                            prt("$lnn:$proj:C$val:\n") if (VERB5());
                            $dwarns{$val} = 1;
                            $cval = "D$val";
                            $awarns{$cval} = [$btxt,$etxt,$proj];
                        }
                    } else {
                        prt("$lnn:$proj:W: $etxt\n");
                    }
                } else {
                    prt("$lnn:$proj:?: $line\n");
                }
            }
            @arr = sort keys(%awarns);
            $cnt = scalar @arr;
            if ($cnt) {
                prt("Sorted into $cnt values: ".join(" ",@arr)."\n");
            }
            foreach $cval (@arr) {
                $ra = $awarns{$cval};
                $cnt = 0;
                if ($cval =~ /(\w+)(\d{4})/) {
                    $typ = $1;
                    $val = $2;
                    if ($typ eq 'C') {
                        $cnt = $cwarns{$val};
                    } elsif ($typ eq 'D') {
                        $cnt = $dwarns{$val};
                    } elsif ($typ eq 'LNK') {
                        $cnt = $lwarns{$val};
                    } else {
                        pgm_exit(1,"Unknonw TYPE $typ! *** FIX ME ***\n");
                    }
                }
                $btxt = ${$ra}[0];
                $etxt = ${$ra}[1];
                $proj = ${$ra}[2];
                if ($etxt =~ /$cval:\s+(.+)$/) {
                    $etxt = $1;
                }
                prt("$proj:$cval:$cnt: $etxt\n");
            }
        }
        if ($ercnt) {
            prt("\nNote: $ercnt errors...\n");
            foreach $ra (@error) {
                $lnn = ${$ra}[0];
                $line = ${$ra}[1];
                $proj = ${$ra}[2];
                #} elsif ($line =~ /\s+error\s+/) {
                prt("$lnn:$proj: $line\n");
            }
        }
    }

    ### $load_log = 1;
}

#########################################
### MAIN ###
parse_args(@ARGV);
process_in_file($in_file);
pgm_exit(0,"");
########################################

sub need_arg {
    my ($arg,@av) = @_;
    pgm_exit(1,"ERROR: [$arg] must have a following argument!\n") if (!@av);
}

sub parse_args {
    my (@av) = @_;
    my ($arg,$sarg);
    my $verb = VERB2();
    while (@av) {
        $arg = $av[0];
        if ($arg =~ /^-/) {
            $sarg = substr($arg,1);
            $sarg = substr($sarg,1) while ($sarg =~ /^-/);
            if (($sarg =~ /^h/i)||($sarg eq '?')) {
                give_help();
                pgm_exit(0,"Help exit(0)");
            } elsif ($sarg =~ /^v/) {
                if ($sarg =~ /^v.*(\d+)$/) {
                    $verbosity = $1;
                } else {
                    while ($sarg =~ /^v/) {
                        $verbosity++;
                        $sarg = substr($sarg,1);
                    }
                }
                $verb = VERB2();
                prt("Verbosity = $verbosity\n") if ($verb);
            } elsif ($sarg =~ /^l/) {
                if ($sarg =~ /^ll/) {
                    $load_log = 2;
                } else {
                    $load_log = 1;
                }
                prt("Set to load log at end. ($load_log)\n") if ($verb);
            } elsif ($sarg =~ /^o/) {
                need_arg(@av);
                shift @av;
                $sarg = $av[0];
                $out_file = $sarg;
                prt("Set out file to [$out_file].\n") if ($verb);
            } else {
                pgm_exit(1,"ERROR: Invalid argument [$arg]! Try -?\n");
            }
        } else {
            $in_file = $arg;
            prt("Set input to [$in_file]\n") if ($verb);
        }
        shift @av;
    }

    if ($debug_on) {
        prtw("WARNING: DEBUG is ON!\n");
        if (length($in_file) ==  0) {
            $in_file = $def_file;
            prt("Set DEFAULT input to [$in_file]\n");
        }
    }
    if (length($in_file) ==  0) {
        pgm_exit(1,"ERROR: No input files found in command!\n");
    }
    if (! -f $in_file) {
        pgm_exit(1,"ERROR: Unable to find in file [$in_file]! Check name, location...\n");
    }
}

sub give_help {
    prt("$pgmname: version $VERS\n");
    prt("Usage: $pgmname [options] in-file\n");
    prt("Options:\n");
    prt(" --help  (-h or -?) = This help, and exit 0.\n");
    prt(" --verb[n]     (-v) = Bump [or set] verbosity. def=$verbosity\n");
    prt(" --load        (-l) = Load LOG at end. ($outfile)\n");
    prt(" --out <file>  (-o) = Write output to this file.\n");
}

# eof - showbldlog.pl

index -|- top

checked by tidy  Valid HTML 4.01 Transitional