
sub process_VCPROJ3 {
    my ($fil) = shift;
    $act_vcproj = $fil;
    my (@lines, $xlncnt, $lncnt, $lnnum, $xln, $line, $tag);
    my (@attribs, %atthash, %lnmap);
    my ($pname, $adddeps, $adddefs, $ppdefs);
    my ($var1, $var2, $var3, $seek, $tmp);
    my (@arr,$cnt,$i);
    my @configs = ();
    my $rdsp_current_sub = get_default_sub_ref(0); # copy the DEFAULTS
    my ($dsp_sub_sub);
    my $sub_count = 0;
    if (open INF, "<$fil") {
        %lnmap = ();
        @lines = <INF>;
        close INF;
        $xlncnt = scalar @lines;
        @lines = fg_xml_to_lines(\%lnmap, @lines);
        $lncnt = scalar @lines;
        $lnnum = 0;
        prt( "Processing file [$fil], $lncnt lines ($xlncnt) ...\n" );
        my $invcproj = 0;
        my @tag_stack = ();
        my $inconfigs = 0;
        my $inconfig = 0;
        my $apptype = '';
        my $dnapptype = '';
        my $dnaptype = 0;
        my $conf = '';
        my $infiles = 0;
        my $infile = 0;
        my $fname = '';
        my $flist = '';
        my $infilt = 0;
        my $projname = '';
        my $fconf = ''; # FileConfiguration
        my $infconf = 0; # in FileConfiguration
        my @vc_c_sources = ();
        my @vc_h_sources = ();
        my $src_ref = \@vc_c_sources;
        my $last_src = '';  # the LAST SOURCE file processed
        my $last_nm  = '';  # and its NAME only
        my $last_dir = '';  # and its DIRECTORY
        my $last_ext = '';  # and its EXTENSION
        my $last_fpos = 0;  # last position in $src_ref array, ie ${$ref_src}[$last_fpos][0] to get FILE NAME
        my $last_intdir = '';   # last intermediate directory - under "-NEW_INTER-" in $dsp_sub_sub
        # which is in $sub_count++; $tmp = sprintf("config-%03d",$sub_count); $tmp .= "-$confname"; ${$rdsp_current_sub}{$tmp} = $dsp_sub_sub;
        my $confname = '';
        my ($curval,$newval);
        my $dn_lt_noo = 0;
        my %per_file_hash = ();
        pre_process_VCPROJ( $fil, \@lines );
        foreach $line (@lines) {
            $lnnum++;
            $xln = $lnmap{$lnnum};
            @attribs = space_split($line);
            %atthash = array_2_hash_on_equals(@attribs);
            $tag = $attribs[0];
            $pname = '';
            if (defined $atthash{'Name'}) {
                $pname = strip_quotes(trim_all($atthash{'Name'}));
                prt( "$lnnum:$xln: tag=$tag, Name=$pname\n" ) if ($dbg_v02);
            }
            if ($invcproj) {
                if ($tag =~ /<\/VisualStudioProject/) {
                    $invcproj = 0;
                    ##pop @tag_stack;
                } else {
                    # in VCPROJ file
                    if ($line =~ /\/>$/) {
                        # begin and end tag line
                    } elsif ($line =~ /^<\//) {
                        if (! @tag_stack) {
                            prtw( "Close WITHOUT stacked tag! [$line]\n" );
                        } else {
                            pop @tag_stack;
                        }
                    } else {
                        push(@tag_stack,$tag);
                    }
                    if ($inconfigs) {
                        if ($tag =~ /<\/Configurations/) {
                            add_config_arrays($rdsp_current_sub) if ($inconfigs);
                            $inconfigs = 0;
                            prt( "$lnnum:$xln: Exit Configurations [$line]\n" ) if ($dbg_v07);
                        } else {
                            # in 'Configurations' section
                            if ($inconfig) {
                                # in a specific 'Confgiuration name="..."...>
                                if ($line =~ /^<\/Configuration/) {
                                    $inconfig = 0;
                                    $sub_count++;
                                    $tmp = sprintf("config-%03d",$sub_count);
                                    $tmp .= "-$confname";
                                    ${$rdsp_current_sub}{$tmp} = $dsp_sub_sub;
                                    prt( "$lnnum:$xln: Exit Configuration [$conf]... [$line] ...\n" ) if ($dbg_v08);
                                } else {
                                    # processing a Configuration in Configurations
                                    prt( "$lnnum:$xln: processing inconfig '$conf' '$pname' [$line]\n" ) if ($dbg_v04);
                                    if ($line =~ /<Tool\s+/ ) {
                                        if ($pname eq 'VCCLCompilerTool') {
                                            $var1 = '-NEW_INCS-';
                                            $var2 = '-NEW_DEFS-';
                                            $var3 = '-NEW_RT-';
                                            prt( "$lnnum:$xln: 'VCCLCompilerTool' [$line]\n" ) if ($dbg_v10);
                                            # <Tool
                                            # Name="VCCLCompilerTool"
                                            # Optimization="0"
                                            # AdditionalIncludeDirectories="../lib,../lib/curl_transport,...
                                            # PreprocessorDefinitions="_DEBUG;WIN32;_LIB;ABYSS_WIN32;CURL_STATICLIB" 
                                            # MinimalRebuild="true" 
                                            # BasicRuntimeChecks="3" 
                                            # RuntimeLibrary="1" 
                                            # PrecompiledHeaderFile=".\Debug\xmlrpccpp/xmlrpccpp.pch" 
                                            # AssemblerListingLocation=".\Debug\xmlrpccpp/" 
                                            # ObjectFile=".\Debug\xmlrpccpp/" 
                                            # ProgramDataBaseFileName=".\Debug\xmlrpccpp/" 
                                            # WarningLevel="3" 
                                            # SuppressStartupBanner="true" 
                                            # DebugInformationFormat="4" />]
                                            # WATCHOUT FOR 
                                            # AdditionalIncludeDirectories="..\..;&quot;..\..\..\zlib-1.2.3&quot;"

                                            $seek = 'AdditionalIncludeDirectories'; # -NEW_INCS_[DBG|REL]-
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                $ppdefs =~ s/&amp;/&/g;     # 20081205 - added
                                                $ppdefs =~ s/&quot;/"/g;
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var1}) {
                                                   $curval = ${$dsp_sub_sub}{$var1};
                                                }
                                                $newval = get_includes_string($ppdefs);
                                                if ($curval ne $newval) {
                                                   ${$dsp_sub_sub}{$var1} = $newval;
                                                   if ($dbg_v25) {
                                                      if (length($curval)) {
                                                         prt( "$lnnum:$xln: VCCLCompilerTool:$seek: RESET [$var1] to [$newval] from [$curval]\n" );
                                                      } else {
                                                         prt( "$lnnum:$xln: VCCLCompilerTool:$seek: set [$var1] to [$newval]\n" );
                                                      }
                                                   }
                                                }
                                            } else { 
                                                ${$dsp_sub_sub}{$var1} = '';
                                                prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(1) '$seek' [$line]\n" ) if ($dbg_v13);
                                            }

                                            $seek = 'PreprocessorDefinitions';
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                prt( "PreprocessorDefinitions = [$ppdefs] [$fil]\n" );
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var1}) {
                                                   $curval = ${$dsp_sub_sub}{$var1};
                                                }
                                                $newval = get_defines_string($ppdefs);
                                                ${$dsp_sub_sub}{$var2} = $newval;
                                            } else {
                                                # 2009/09/22 - downgraded from WARNING, to a simple ADVICE
                                                # prtw( "WARNING:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(2) '$seek' [$line]\n" );
                                                prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(2) '$seek' [$line]\n" );
                                            }

                                            $seek = 'RuntimeLibrary';
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                ${$dsp_sub_sub}{$var3} = fg_get_runtime_val_2_lts($ppdefs);
                                            } else {
                                                # 2009/09/22 - downgraded from WARNING, to a simple ADVICE
                                                # prtw( "WARNING:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(3) '$seek' [$line]\n" );
                                                prt( "ADVICE:$lnnum:$xln: 'VCCLCompilerTool' DOES NOT CONTAIN(3) '$seek' [$line]\n" );
                                            }

											$seek = 'CompileAs';
                                            if ( defined $atthash{$seek} ) {
                                                $ppdefs = strip_quotes(trim_all($atthash{$seek}));
                                                $adddeps = ${$dsp_sub_sub}{$var3};
                                                if (defined $compileas{$ppdefs} ) {
                                                   $tmp = $compileas{$ppdefs};
                                                   $adddeps .= " " if length($adddeps);
                                                   $adddeps .= "/$tmp";
                                                   $curval = '';
                                                   if (defined ${$dsp_sub_sub}{$var3}) {
                                                      $curval = ${$dsp_sub_sub}{$var3};
                                                   }
                                                   $newval = $adddeps;
                                                   if ($curval ne $newval) {
                                                      ${$dsp_sub_sub}{$var3} = $newval;
                                                      prt( "$lnnum:$xln: VCCLCompilerTool:$seek: set [$var3] to ".${$dsp_sub_sub}{$var3}."\n" ); # if ($dbg_v26);
                                                   }
                                                } else {
                                                   prtw( "WARNING:$lnnum:$xln: VCCLCompilerTool:$seek: [$var3] NOT BEING SET! [$ppdefs] NOT IN 'compileas' hash [$fil]\n" );
                                                }
                                             }
                                        } elsif ($pname eq 'VCLinkerTool') {
                                            $var1 = '-NEW_LIBS-';
                                            $var2 = '-NEW_OUT-';
                                            # <Tool
                                            #  Name="VCLinkerTool"
                                            #  LinkLibraryDependencies="false"
                                            #  AdditionalDependencies="wsock32.lib SimGear.lib sg_d.lib ... "
                                            #  OutputFile="..\bin\FlightGearD.exe"
                                            #  LinkIncremental="0"
                                            #  SuppressStartupBanner="true"
                                            #  AdditionalLibraryDirectories="..\SimGear\$(IntDir); ..\PLIB, ..."
                                            #  IgnoreDefaultLibraryNames=""
                                            #  GenerateDebugInformation="true"
                                            #  ProgramDatabaseFile=".\Debug/FlightGear.pdb"
                                            #  SubSystem="1"
                                            #  RandomizedBaseAddress="1"
                                            #  DataExecutionPrevention="0"
                                            #  TargetMachine="1" />
                                            $seek = 'AdditionalDependencies';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $adddeps =~ s/&amp;/&/g;     # 20081205 - added
                                                $adddeps =~ s/&quot;/"/g;    # 20081205 - added
                                                $newval = $adddeps;
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var1}) {
                                                   $curval = ${$dsp_sub_sub}{$var1};
                                                }
                                                if ($newval ne $curval) {
                                                   ${$dsp_sub_sub}{$var1} = $adddeps;
                                                   prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$adddeps]\n" ) if ($dbg_v22);
                                                }
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(4) '$seek' [$line] [$fil]\n" ) if ($dbg_v16);
                                            }

                                            $seek = 'OutputFile';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                # 20090808 - handle substitution
                                                # EG: 39:138-149: seek=OutputFile: Set [-NEW_OUT_REL-] 
                                                # to [.\$(ProjectName).exe]
                                                $adddeps =~ s/\$\(ProjectName\)/$projname/;
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var2}) {
                                                   $curval = ${$dsp_sub_sub}{$var2};
                                                }
                                                $newval = '/out:'.$adddeps;
                                                if ($curval ne $newval) {
                                                   ${$dsp_sub_sub}{$var2} = $newval;
                                                   prt( "$lnnum:$xln: seek=$seek: Set [$var2] to [$newval]\n" ) if ($dbg_v24);
                                                }
                                            } else {
                                               # 20090912 - downgraded to a NOTE only, and ONLY once per file
                                               if (!$dn_lt_noo) {
                                                   # prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]\n" ) if ($dbg_v21);
                                                   prt( "NOTE:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(5) '$seek' [$line]\n" ) if ($dbg_v21);
                                                   $dn_lt_noo = 1;
                                               }
                                            }

                                            $seek = 'AdditionalLibraryDirectories';
                                            if (defined $atthash{$seek} ) {
                                                # must deal with a crazy string like this -
                                                # AdditionalLibraryDirectories=
                                                # "&amp;quot,..\fltk-1.1.7\lib&amp;quot,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3&amp;quot,..\plib,
                                                # ..\pthreads-w32-2-7-0-release&amp;quot,..\gettext\lib"
                                                # after quotes removed, and the first substitution
                                                # &quot,..\fltk-1.1.7\lib&quot,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3&quot,..\plib,
                                                # ..\pthreads-w32-2-7-0-release&quot,..\gettext\lib
                                                # after next pair of subs
                                                # ",..\fltk-1.1.7\lib",..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3",..\plib,
                                                # ..\pthreads-w32-2-7-0-release",..\gettext\lib
                                                # then removing the auotes
                                                # ,..\fltk-1.1.7\lib,..\SimGear.plib\Debug,
                                                # ..\zlib-1.2.3,..\plib,
                                                # ..\pthreads-w32-2-7-0-release,..\gettext\lib
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $adddeps =~ s/&amp;/&/g;    # 20081205 - added
                                                $adddeps =~ s/&quot;/"/g;   # 20081205 - added
                                                $adddeps =~ s/&quot/"/g;    # 20081205 - added
                                                $adddeps =~ s/"//g;         # 20081205 - added
                                                $adddeps =~ s/^,//;         # 20081205 - added
                                                $tmp = get_libpaths_string($adddeps);
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var1}) {
                                                   $curval = ${$dsp_sub_sub}{$var1};
                                                }
                                                ${$dsp_sub_sub}{$var1} .= ' '.$tmp;
                                                prt( "$lnnum:$xln: seek=$seek: Set [$var1] to [$tmp]\n from [$adddeps]\n" ) if ($dbg_v23);
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(6) '$seek' [$line] [$fil]\n" )  if ($dbg_v16);
                                            }

                                            $seek = 'SubSystem';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $apptype = adjust_app_type_per_subsystem( $apptype, $adddeps, $dbg_v05 );
                                                $dnaptype |= 2;  # signal, we have an APP TYPE - VERY IMPORTANT
                                                # subsystem determines different between 'Application' and 'Console Application'
                                                if (length($dnapptype)) {
                                                   if ($dnapptype ne $apptype) {
                                                      prt( "$lnnum:$xln: Project [$projname], APP_TYPE RESET per SubSystem [$apptype] from [$dnapptype]...\n" );
                                                      $dnapptype = $apptype;
                                                   }
                                                } else {
                                                   prt( "$lnnum:$xln: Project [$projname], APP_TYPE per SubSystem [$apptype]...\n" );
                                                   $dnapptype = $apptype;
                                                }
                                            } else {
                                                prtw( "WARNING:$lnnum:$xln: 'VCCLinkerTool' DOES NOT CONTAIN(7) '$seek' [$line] [$fil]\n" ) if ($dbg_v18);
                                            }
                                        } elsif ($pname eq 'VCLibrarianTool' ) {
                                           # <Tool Name="VCLibrarianTool"
                                           # OutputFile="Win32_LIB_Debug\zlibd.lib"
                                           # SuppressStartupBanner="true" />
                                            $var2 = '-NEW_OUT-';
                                            $seek = 'OutputFile';
                                            if (defined $atthash{$seek} ) {
                                                $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                                $curval = '';
                                                if (defined ${$dsp_sub_sub}{$var2}) {
                                                   $curval = ${$dsp_sub_sub}{$var2};
                                                }
                                                $newval = '/out:'.$adddeps;
                                                if ($curval ne $newval) {
                                                   ${$dsp_sub_sub}{$var2} = $newval;
                                                   prt( "$lnnum:$xln: seek=$seek: Set [$var2] to [$newval]\n" ) if ($dbg_v24);
                                                }
                                            } else {
                                               # 20090914 - set as 15, downgraded to a NOTE only, and ONLY once per file
                                               # it seems this will DEFAULT TO '$(OutDir)\$(ProjectName).lib'!!!
                                               if (!$dn_lt_noo) {
                                                    prt( "NOTE:$lnnum:$xln: 'VCLibrarianTool' DOES NOT CONTAIN(15) '$seek' [$line]\n" ) if ($dbg_v21);
                                                    $dn_lt_noo = 1;
                                               }
                                            }
                                        } elsif ($pname eq 'VCPostBuildEventTool') {
                                            $var1 = '-NEW_POST-';
                                            if ( !(($conf =~ /Debug/i)||($conf =~ /Release/i)) ) {
                                                prtw( "WARNING:$lnnum:$xln: pname=[$conf] NOT Debug or Release - def to REL! [$fil]\n" );
                                            }
                                            # <Tool
                                            #  Name="VCPostBuildEventTool"
                                            #  Description="Copy Library to plib directory"
                                            #  CommandLine="copy debug\*.lib ..\..\*.*&#x0D;&#x0A;copy ul.h ..\..\ul.h&#x0D;&#x0A;copy ulRTTI.h ..\..\ulRTTI.h&#x0D;&#x0A;"
                                            #  />
                                            # this will be output to the DSP, under the paticular, config, something like
                                            # # Begin Special Build Tool
                                            # SOURCE="$(InputPath)"
                                            # PostBuild_Desc=Copy to bin
                                            # PostBuild_Cmds=copy Release\*exe bin\.	copy test.h bin\.
                                            # # End Special Build Tool
                                            if (( defined $atthash{'Description'} ) || ( defined $atthash{'CommandLine'} ) ) {
                                                $ppdefs = ""; # to 'PostBuild_Desc=';
                                                if ( defined $atthash{'Description'} ) {
                                                    $ppdefs .= add_quotes(strip_quotes(trim_all($atthash{'Description'})));
                                                }
                                                $adddeps = ""; # to ' PostBuild_Cmds=';
                                                if ( defined $atthash{'CommandLine'} ) {
                                                    $adddeps = strip_quotes(trim_ends($atthash{'CommandLine'}));
                                                    $adddeps =~ s/&quot;/"/g;   # put back the quotes, if any
                                                    $adddeps =~ s/&#x0D;&#x0A;/\t/g;    # new line to TAB for VC6
                                                    $adddeps =~ s/\t$//;    # clear any END tab
                                                }
                                                prt( "$lnnum:$xln: got POST event [$ppdefs]\n" ) if ($dbg_v15);
                                                $tmp = "# Begin Special Build Tool\n";
                                                $tmp .= "SOURCE=\"\$(InputPath)\"\n";
                                                $tmp .= "PostBuild_Desc=$ppdefs\n";
                                                # sometimes need a little 'massaging' of the command ...
                                                $tmp .= "PostBuild_Cmds=".massage_command($adddeps)."\n";
                                                $tmp .= "# End Special Build Tool\n";
                                                ${$dsp_sub_sub}{$var1} = $tmp;
                                            }
                                        }
                                    }
                                }
                            } elsif ($line =~ /^<Configuration\s+/) {
                                # entering a SPECIFIC "Configuration\s+name="..." ...>
                                $conf = $pname;
                                @arr = split(/\|/,$pname);
                                $confname = $arr[0];
                                prt( "$lnnum:$xln: Entering ConfigurationName=[$confname] conf=[$conf] [$line] ...\n" ) if ($dbg_v08);

                                # 28/09/2008 - note, has quotes added
                                # "-NEW_OUTD-" $out_dir
                                # "-NEW_INTER-" $int_dir
                                $var1 = "-NEW_OUTD-";
                                $var2 = "-NEW_INTER-";
                                if ($conf =~ /Debug/i) {
                                    $dsp_sub_sub = get_default_sub3(1);
                                } else {
                                    $dsp_sub_sub = get_default_sub3(0);
                                    if (!($conf =~ /Release/i)) {
                                        prtw( "WARNING:$lnnum:$xln: pname=[$conf] NOT Debug or Release - def to REL! [$fil]\n" );
                                    }
                                }
                                push(@configs,[ $pname, $var1, $conf ]);
                                #  // This is an internal type to Visual Studio, it seems that:
                                #  // 4 == static library
                                #  // 2 == dll
                                #  // 1 == executable - note, subsytem decides if this remains 'Application' or becomes 'Console Application'
                                #  // 10 == utility
                                $seek = 'ConfigurationType';
                                if (defined $atthash{$seek}) {
                                    $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                    $apptype = get_app_conf_type($adddeps);
                                    $dnaptype |= 1;  # signal, we have an APP TYPE - VERY IMPORTANT
                                    if (length($dnapptype)) {
                                       if ($dnaptype & 2) {
                                          $apptype = $dnapptype;
                                       }
                                       if ($dnapptype ne $apptype) {
                                          prt( "$lnnum:$xln: Project [$projname], APP_TYPE RESET per $seek [$apptype] from [$dnapptype]...\n" );
                                          $dnapptype = $apptype;
                                       }
                                    } else {
                                       prt( "$lnnum:$xln: Project [$projname], APP_TYPE per $seek [$apptype]...\n" );
                                       $dnapptype = $apptype;
                                    }
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(8) '$seek' [$line] [$fil]\n" );
                                }
                                # 2009/10/15 - handle better 'InheritedPropertySheets=".\vc9_lame_config.vsprops;.\arch_nasm.vsprops"'
                                # and this PROPS (vsprops) MAY contain the following items
                                $seek = 'InheritedPropertySheets';
                                if (defined $atthash{$seek}) {
                                    $adddeps = strip_quotes(trim_all($atthash{$seek}));
                                    add_props_to_hash( $fil, $adddeps, \%atthash, "OutputDirectory;IntermediateDirectory" );
                                }

                                $seek = 'OutputDirectory';
                                if (defined $atthash{$seek}) {
                                   # 20090808 - improved to handle
                                   # EG: 9:18-24: Changed(1) OutputDirectory from ["Debug"]
                                   # to ["$(SolutionDir)$(ConfigurationName)"]
                                   #$adddeps = add_quotes(strip_dotrel(strip_quotes(trim_all($atthash{$seek}))));
                                    $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                    $adddeps =~ s/\$\(SolutionDir\)//;
                                    $adddeps =~ s/\$\(ConfigurationName\)/$confname/;
                                    if ( ${$dsp_sub_sub}{$var1} ne add_quotes($adddeps)) {
                                        if ($dbg_v19) {
                                           prt( "$lnnum:$xln: Changed(1) [$seek]" );
                                           prt( " from [".${$dsp_sub_sub}{$var1}."]" );
                                           prt( " to [".add_quotes($adddeps)."]\n" );
                                        }
                                    }
                                    ${$dsp_sub_sub}{$var1} = add_quotes($adddeps);
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(9) '$seek' [$line] [$fil]\n" );
                                }
                                $seek = 'IntermediateDirectory';
                                if (defined $atthash{$seek}) {
                                   # 20090808 - improved to handle
                                   # 9:18-24: Changed(2) IntermediateDirectory from ["Debug"] 
                                   # to ["$(ConfigurationName)"]
                                   # $adddeps = add_quotes(strip_dotrel(strip_quotes(trim_all($atthash{$seek}))));
                                   $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                   $adddeps =~ s/\$\(SolutionDir\)//;
                                   $adddeps =~ s/\$\(ConfigurationName\)/$confname/;
                                   if (${$dsp_sub_sub}{$var2} ne add_quotes($adddeps)) {
                                       if ($dbg_v20) {
                                          prt( "$lnnum:$xln: Changed(2) [$seek]" );
                                          prt( " from [".${$dsp_sub_sub}{$var2}."]" );
                                          prt( " to [".add_quotes($adddeps)."]\n" );
                                       }
                                   }
                                   $last_intdir = $adddeps;
                                   ${$dsp_sub_sub}{$var2} = add_quotes($last_intdir);
                                } else {
                                    prtw( "WARNING:$lnnum:$xln: DOES NOT CONTAIN(10) '$seek' [$line] [$fil]\n" );
                                }
                                $inconfig = 1;
                            }
                        }
                    } elsif ($infiles) {
                        if ($tag =~ /\/Files/) {
                            prt( "[dbg_v09] $lnnum:$xln:$tag: Exit Files [$line]\n" ) if ($dbg_v09);
                            $infiles = 0;
                        } else {
                            # processing the <Files> section
                            # ##############################
                            if ($infilt) {
                                if ($line =~ /^<\/Filter/) {
                                    $infilt = 0;
                                    prt( "$lnnum:$xln: EXIT Filter name=[$fname] list=[$flist]\n" ) if ($dbg_v11);
                                    $flist = '';    # 20081205 - kill list on exit
                                } else {
                                    if ($infile) {
                                        if ($line =~ /^<\/File(\s|>)+/) {
                                            prt( "[dbg_v28] $lnnum:$xln:$tag: Exit     Filter::File [$line]\n" ) if ($dbg_v28);
                                            add_any_per_file_items( $rdsp_current_sub, \%per_file_hash, $src_ref,
                                                \@configs, $last_fpos, $projname );
                                            $infile = 0;
                                            %per_file_hash = ();
                                        } else {
                                            # processing a <Files><Filter...><File ... may have
                                            # In <Files ...>
                                            # WATCH FOR THIS
                                            # <File RelativePath="..\..\scripts\pngw32.def">
                                            # <FileConfiguration Name="LIB Release|Win32" ExcludedFromBuild="true">
                                            # <Tool Name="VCCustomBuildTool" />
                                            # </FileConfiguration>
                                            # <FileConfiguration Name="LIB Debug|Win32" ExcludedFromBuild="true">
                                            # <Tool Name="VCCustomBuildTool" />
                                            # </FileConfiguration>
                                            # </File>
                                            # <FileConfiguration Name="Release|Win32" >
                                            # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                            # </FileConfiguration>
                                            # <FileConfiguration Name="Debug|Win32" >
                                            # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                            # </FileConfiguration>
                                            # OR can have
                                            # <FileConfiguration Name="Release|Win32">
                                            # <Tool Name="VCCustomBuildTool" Description="Assembly $(InputPath)"
                                            # CommandLine="yasm -I..\..\common\x86\ -f win32 -O2 -DPREFIX -o &quot;$(IntDir)\$(InputName)&quot;.obj &quot;$(InputPath)&quot;&#x0D;&#x0A;"
                                            # Outputs="$(IntDir)\$(InputName).obj" />
                                            # </FileConfiguration>
                                            # and something similar for each configuration
                                            # </File>
                                            if ($infconf) {
                                                if ($tag =~ /<\/FileConfiguration/) {
                                                    $infconf = 0;
                                                    prt( "[dbg_v12] $lnnum:$xln: Exit     FileConfiguration [$line] conf=[$fconf]\n") if ($dbg_v12);
                                                } else {
                                                    # deal with a FILE CONFIGURATION
                                                    if ($tag =~ /<Tool/) {
                                                        if ($pname eq 'VCCustomBuildTool') {
                                                            if (( defined $atthash{'Description'} ) || ( defined $atthash{'CommandLine'} ) ) {
                                                                $ppdefs = ""; # to 'PostBuild_Desc=';
                                                                $seek = 'Description';
                                                                if ( defined $atthash{$seek} ) {
                                                                    $ppdefs .= strip_quotes(trim_all($atthash{$seek}));
                                                                }
                                                                $seek = 'CommandLine';
                                                                $adddeps = ""; # to ' PostBuild_Cmds=';
                                                                if ( defined $atthash{$seek} ) {
                                                                    $adddeps = strip_quotes(trim_ends($atthash{$seek}));
                                                                    $adddeps =~ s/&quot;/"/g;   # put back the quotes, if any
                                                                    $adddeps =~ s/&#x0D;&#x0A;/\t/g;    # new line to TAB for VC6
                                                                    $adddeps =~ s/\t$//;    # clear any END tab
                                                                }
                                                                $adddefs = '$(IntDir)';
                                                                $seek = 'Outputs';
                                                                if ( defined $atthash{$seek} ) {
                                                                    $adddefs = strip_quotes(trim_all($atthash{$seek}));
                                                                }
                                                                $tmp = "# Begin Custom Build - $ppdefs\n";
                                                                $tmp .= "IntDir=$adddefs\n";
                                                                $tmp .= "Inputpath=$last_src\n";
                                                                $tmp .= "InputName=$last_nm\n\n";
                                                                $tmp .= "\"\$(IntDir)\\\$(InputName).obj\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\n";
                                                                $tmp .= "\t".massage_command($adddeps)."\n\n";
                                                                $tmp .= "# End Custom Build\n";
                                                                prt( "[dbg_v27] $lnnum:$xln: got CUSTOM event [$pname] [$fconf] [$tmp] [$adddefs]\n" ) if ($dbg_v27);
                                                                if (defined $per_file_hash{$fconf}) {
                                                                    prtw("WARNING: Already have [$fconf] in per_file_hash!\n");
                                                                }
                                                                $per_file_hash{$fconf} = $tmp;  # stroe it for later
                                                            } else {
                                                                prtw( "WARNING: Deal with TAG=$tag - [$line] NO Decription or Command line\n" );
                                                            }
                                                        } elsif ($pname eq 'VCCLCompilerTool') {
                                                            # *TBD*
                                                        } elsif ($pname eq 'VCResourceCompilerTool') {
                                                            # *TBD*
                                                        } else {
                                                            prtw( "WARNING: Deal with TAG=$tag - [$line]\n" );
                                                            pgm_exit(1,"TEMP EXIT 1");
                                                        }
                                                    }
                                                }
                                            } elsif ($tag =~ /<FileConfiguration/) {
                                                $infconf = 1;
                                                $fconf = $pname;
                                                $seek = 'ExcludedFromBuild';
                                                $adddefs = '';
                                                if (defined $atthash{$seek} ) {
                                                    $adddefs = strip_quotes(trim_all($atthash{$seek}));
                                                    if (length($adddefs) && ($adddefs =~ /true/)) {
                                                        $$src_ref[-1][3] = 1;
                                                        prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs\n" ) if ($dbg_v14);
                                                    }
                                                }
                                                prt( "[dbg_v12] $lnnum:$xln: Entering FileConfiguration [$line] conf=[$fconf]\n") if ($dbg_v12);
                                            }
                                        }
                                    } elsif ($line =~ /^<File\s+/) {
                                        prt( "[dbg_v28] $lnnum:$xln:$tag: Entering Filter::File [$line]\n" ) if ($dbg_v28);
                                        $seek = 'RelativePath';
                                        if (defined $atthash{$seek}) {
                                            $var1 = $atthash{$seek};
                                            $var1 =~ s/>$//;
                                            $last_src = strip_dotrel(strip_quotes(trim_all($var1)));
                                            ($last_nm,$last_dir,$last_ext) = fileparse( $last_src, qr/\.[^.]*/ );
                                            if (is_c_source_extended($last_src)) {
                                                #push(@vc_c_sources,[$last_src, $fname, $flist, 0]);
                                                $var1 = (length($fname) ? $fname : get_def_src_grp());
                                                $var2 = (length($flist) ? $flist : get_def_src_filt());
                                                ##push(@vc_c_sources,[$last_src, $var1, $var2, 0]);
                                                $src_ref = \@vc_c_sources;
                                                $tmp = 'C';
                                                add_2_source_ref($src_ref, $last_src, $var1, $var2, $tmp, \$last_fpos);
                                            } else {
                                                #push(@vc_h_sources,[$last_src, $fname, $flist, 0]);
                                                $var1 = (length($fname) ? $fname : get_def_hdr_grp());
                                                $var2 = (length($flist) ? $flist : get_def_hdr_filt());
                                                ##push(@vc_h_sources,[$last_src, $var1, $var2, 0]);
                                                $src_ref = \@vc_h_sources;
                                                $tmp = 'H';
                                                add_2_source_ref($src_ref, $last_src, $var1, $var2, $tmp, \$last_fpos);
                                            }
                                            prt( "$lnnum:$xln: [$last_src] $tmp source\n" ) if ($dbg_v03);
                                        } else {
                                            prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(11) '$seek'? [$line] [$fil]\n" );
                                        }
                                        $infile = 1;
                                    }
                                }
                            } elsif ($line =~ /^<Filter\s+/) {
                                $fname = $pname;
                                $seek = 'Filter';
                                if (defined $atthash{$seek} ) {
                                    $flist = strip_quotes(trim_all($atthash{$seek}));
                                    # handle this Filter="&quot;h;hpp;hxx;hm;inl&quot;&gt;"
                                    $flist =~ s/&gt;//g;    # 20081205 - remove this, if exists
                                    $flist =~ s/&quot;/"/g; # 20081205 - put QUOTES back
                                    $flist = strip_quotes($flist);  # now again remove them
                                } else {
                                    # example: alut.vcproj
                                    # <Filter Name="ALUT Header">
                                    # <File RelativePath="..\..\..\include\AL\alut.h">
                                    # </File></Filter>
                                    prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(12) '$seek'? [$line] [$fil]\n" ) if ($dbg_v17);
                                }
                                prt( "$lnnum:$xln: ENTER Filter name=[$fname] list=[$flist]\n" ) if ($dbg_v11);
                                $infilt = 1;
                            } else {
                                # some VCPROJ files have NO <Filter ...><File...>...</File></Filter>
                                if ($infile) {
                                    if ($line =~ /^<\/File/) {
                                        add_any_per_file_items( $rdsp_current_sub, \%per_file_hash, $src_ref,
                                                \@configs, $last_fpos, $projname );
                                        $infile = 0;
                                        prt( "[dbg_v09] $lnnum:$xln:$tag: Exit     Files [$line]\n" ) if ($dbg_v09);
                                    } else {
                                        # processing a <Files><File ... may have
                                        # In <Files ...>
                                        # WATCH FOR THIS
                                        # <File RelativePath="..\..\scripts\pngw32.def">
                                        # <FileConfiguration Name="LIB Release|Win32" ExcludedFromBuild="true">
                                        # <Tool Name="VCCustomBuildTool" />
                                        # </FileConfiguration>
                                        # <FileConfiguration Name="LIB Debug|Win32" ExcludedFromBuild="true">
                                        # <Tool Name="VCCustomBuildTool" />
                                        # </FileConfiguration>
                                        # </File>
                                        # <FileConfiguration Name="Release|Win32" >
                                        # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                        # </FileConfiguration>
                                        # <FileConfiguration Name="Debug|Win32" >
                                        # <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" />
                                        # </FileConfiguration>
                                        if ($tag =~ /<FileConfiguration/) {
                                            $infconf = 1;
                                            $fconf = $pname;
                                            $seek = 'ExcludedFromBuild';
                                            $adddefs = '';
                                            if (defined $atthash{$seek} ) {
                                                $adddefs = strip_quotes(trim_all($atthash{$seek}));
                                                if (length($adddefs) && ($adddefs =~ /true/)) {
                                                    $$src_ref[-1][3] = 1;
                                                    prt( "$lnnum:$xln: last = $last_src [".$$src_ref[-1][0]."] $fconf $seek = $adddefs\n" ) if ($dbg_v14);
                                                }
                                            }
                                            prt( "[dbg_v12] $lnnum:$xln:$tag: Entering FileConfiguration [$line]\n") if ($dbg_v12);
                                        }
                                    }
                                } elsif ($line =~ /^<File\s+/) {
                                    prt( "[dbg_v28] $lnnum:$xln:$tag: Entering File [$line]\n" ) if ($dbg_v28);
                                    %per_file_hash = ();    # clear the PER FILE HASH
                                    $seek = 'RelativePath';
                                    if (defined $atthash{$seek}) {
                                        $last_src = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                                        ($last_nm,$last_dir,$last_ext) = fileparse($last_src, qr/\.[^.]*/ );
                                        if (is_c_source_extended($last_src)) {
                                            #push(@vc_c_sources,[$last_src, $fname, $flist, 0]);
                                            $var1 = (length($fname) ? $fname : get_def_src_grp());
                                            $var2 = (length($flist) ? $flist : get_def_src_filt());
                                            ###push(@vc_c_sources,[$last_src, $var1, $var2, 0]);
                                            $src_ref = \@vc_c_sources;
                                            $tmp = 'C';
                                            add_2_source_ref($src_ref, $last_src, $var1, $var2, $tmp, \$last_fpos);
                                        } else {
                                            #push(@vc_h_sources,[$last_src, $fname, $flist, 0]);
                                            $var1 = (length($fname) ? $fname : get_def_hdr_grp());
                                            $var2 = (length($flist) ? $flist : get_def_hdr_filt());
                                            push(@vc_h_sources,[$last_src, $var1, $var2, 0]);
                                            $src_ref = \@vc_h_sources;
                                            $tmp = 'H';
                                            add_2_source_ref($src_ref, $last_src, $var1, $var2, $tmp, \$last_fpos);
                                        }
                                        prt( "$lnnum:$xln: [$last_src] $tmp source\n" ) if ($dbg_v03);
                                    } else {
                                        prtw( "WARNING: $lnnum:$xln: DOES NOT CONTAIN(13) '$seek'? [$line] [$fil]\n" );
                                    }
                                    $infile = 1;
                                }
                            }
                        }
                    } else {
                        if ($tag =~ /<Configurations/) {
                            $inconfigs = 1; # 2009/10/15 - entered a 'Configurations' block
                            prt( "[dbg_v08] $lnnum:$xln:$tag: Entering Configurations [$line]\n" ) if ($dbg_v08);
                        } elsif ($tag =~ /<Files/) {
                            prt( "[dbg_v09] $lnnum:$xln:$tag: Entering Files [$line]\n" ) if ($dbg_v09);
                            $infiles = 1;
                        }
                    }
                }
                ###if ($infconf && (($tag =~ /<\/FileConfiguration/)||($line eq '</FileConfiguration>'))) {
                if ($infconf && ($tag =~ /<\/FileConfiguration/)) {
                    $infconf = 0;
                    prt( "[dbg_v12] $lnnum:$xln:$tag: Exit FileConfiguration 2 [$line]\n" ) if ($dbg_v12);
                }
            } else {
                if ($tag =~ /<VisualStudioProject/) {
                    $invcproj = 1;
                    ##push(@tag_stack, $tag);
                    # <VisualStudioProject
                    #  ProjectType="Visual C++" 
                    #  Version="9.00" 
                    #  Name="FlightGear"
                    #  ProjectGUID="{5C747AB8-6441-46B3-95D2-9D948C80EC77}"
                    #  TargetFrameworkVersion="131072" >
                    $seek = 'Name';
                    if (!defined $atthash{$seek} ) {
                        mydie( "ERROR: 'VisualStudioProject' DOES NOT CONTAIN(14) a project NAME! NO GO!! ABORTING!!! [$fil]\n" );
                    }
                    $projname = $pname;
                    $adddeps = '';
                    $adddefs = '';
                    $seek = 'ProjectType';
                    if (defined $atthash{$seek}) {
                        $adddefs = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                    }
                    $seek = 'Version';
                    if (defined $atthash{$seek}) {
                        $adddeps = strip_dotrel(strip_quotes(trim_all($atthash{$seek})));
                    }
                    prt( "$lnnum:$xln: Project [$projname], using [$adddefs], version [$adddeps] ...\n" );
                }
            }
            prt( "$lnnum:$xln:".scalar @tag_stack.": $tag [$line]\n" ) if ($dbg_v01);
        }
        prtw( "WARNING: tag_stack NOT empty! ".$tag_stack[0]." [$fil]\n") if (@tag_stack);
        ${$rdsp_current_sub}{'C_SOURCES'} = [@vc_c_sources];
        ${$rdsp_current_sub}{'H_SOURCES'} = [@vc_h_sources];
        ${$rdsp_current_sub}{'APP_TYPE'} = $apptype;
        ${$rdsp_current_sub}{'-NEW_PROJECT_NAME-'} = $projname;
        if (scalar @configs > 2) {
            show_confs_warning( $fil, \@configs );
            ###pgm_exit(1,"TEMP EXIT AFTER MULTIPLE CONFIG SHOW!\n");
        }
    } else {
        mydie( "ERROR: Unable to open $fil ... $! ... check name, location ...\n" );
    }
    return $rdsp_current_sub;
}

