From 574e44df2863b6838fbd26c759259960b27d2fcc Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Wed, 10 Jul 2013 16:55:03 +0200 Subject: [PATCH] possible unstable changes due to massive variable renaming in cgistest.pl --- xml_spielwiese/Common.pm | 15 ++ xml_spielwiese/cgitest.pl | 142 +++++++++--------- xml_spielwiese/ini2xml.pl | 15 -- xml_spielwiese/{xml2ini.pl => xml2ini_old.pl} | 0 4 files changed, 86 insertions(+), 86 deletions(-) rename xml_spielwiese/{xml2ini.pl => xml2ini_old.pl} (100%) diff --git a/xml_spielwiese/Common.pm b/xml_spielwiese/Common.pm index b3be41d..ad2115f 100644 --- a/xml_spielwiese/Common.pm +++ b/xml_spielwiese/Common.pm @@ -89,6 +89,21 @@ sub binStr2hexStr { } +sub getFieldVal { + + my $regStr = $_[0]; # pointer! + my $start = $_[1]; + my $end = $_[2]; + + my $regStrLen = length($$regStr); + + my $substrStart = $regStrLen-1-$end; + my $substrLength = $end-$start+1; + + return substr $$regStr,$substrStart,$substrLength; + + +} diff --git a/xml_spielwiese/cgitest.pl b/xml_spielwiese/cgitest.pl index 5f03d7c..e2d78a2 100755 --- a/xml_spielwiese/cgitest.pl +++ b/xml_spielwiese/cgitest.pl @@ -71,13 +71,13 @@ if ( !keys %cgiHash ) } my $parser = XML::LibXML->new(); -my $specfile = ""; -my $setfile = ""; -my $specfileName = ""; -my $setfileName = ""; -my $spectree; -my $settree; -my $setMapsType; +my $specFile = ""; +my $configFile = ""; +my $specFileName = ""; +my $configFileName = ""; +my $specTree; +my $configTree; +my $configMapsType; my %fileLevelHash; @@ -99,11 +99,11 @@ if ( $cgiHash{'print'} eq 'spectree' ) { print "

config file does not exist

"; exit; } - parseSetAndSpec( $cgiHash{'configFile'} ); + parseConfigAndSpec( $cgiHash{'configFile'} ); print -"
specifications loaded from $specfileName
"; +"
specifications loaded from $specFileName
"; - print_registers($specfile); + print_registers($specFile); } if ( $cgiHash{'print'} eq 'settree' ) { @@ -112,16 +112,16 @@ if ( $cgiHash{'print'} eq 'settree' ) { print "

config file does not exist

"; exit; } - parseSetAndSpec( $cgiHash{'configFile'} ); - buildAncestry( $setfileName, "" ) + parseConfigAndSpec( $cgiHash{'configFile'} ); + buildAncestry( $configFileName, "" ) ; #arg1: target file, # arg2: recursion parent target file # assignFieldColors();#obsolete - $settree = $ancestryTree; # not so elegant + $configTree = $ancestryTree; # not so elegant print_ancestorInfo(); - print_registers($setfile); + print_registers($configFile); } if ( defined $cgiHash{'debuginput'} ) { @@ -132,15 +132,15 @@ if ( defined $cgiHash{'action'} ) { printHash( \%cgiHash ); if ( $cgiHash{'action'} eq 'save' ) { - parseSet( $cgiHash{'configFile'} ); + parseConfig( $cgiHash{'configFile'} ); save( $cgiHash{'register'}, $cgiHash{'field'}, $cgiHash{'value'} ); } if ( $cgiHash{'action'} eq 'delete' ) { - parseSet( $cgiHash{'configFile'} ); + parseConfig( $cgiHash{'configFile'} ); del( $cgiHash{'register'}, $cgiHash{'field'} ); } if ( $cgiHash{'action'} eq 'copyDefaultRegister' ) { - parseSetAndSpec( $cgiHash{'configFile'} ); + parseConfigAndSpec( $cgiHash{'configFile'} ); del( $cgiHash{'register'}, "" ); # delete existing register from setfile copyDefaultRegister( $cgiHash{'register'} ); } @@ -153,7 +153,7 @@ if ( defined $cgiHash{'action'} ) { } if ( $cgiHash{'action'} eq 'changeAncestor' ) { - parseSet( $cgiHash{'configFile'} ); + parseConfig( $cgiHash{'configFile'} ); changeAncestor( $cgiHash{'newAncestor'} ); } @@ -241,7 +241,7 @@ EOF #print ""; print ""; - print "$setfileName"; + print "$configFileName"; print ""; print ""; } @@ -256,23 +256,23 @@ sub prepare_text { return $t; } -sub parseSetAndSpec { - parseSet( $_[0] ); - $specfileName = $settree->findvalue("/MAPS/\@specDbFile"); - $specfile = $specDir . "/" . $specfileName; - unless ( -e $specfile ) { +sub parseConfigAndSpec { + parseConfig( $_[0] ); + $specFileName = $configTree->findvalue("/MAPS/\@specDbFile"); + $specFile = $specDir . "/" . $specFileName; + unless ( -e $specFile ) { print -"

specification file \"$specfileName\" could not be found in the specification directory \"$specDir\"

"; +"

specification file \"$specFileName\" could not be found in the specification directory \"$specDir\"

"; exit; } - $spectree = $parser->parse_file($specfile); + $specTree = $parser->parse_file($specFile); } -sub parseSet { - $setfileName = $_[0]; - $setfile = $confDir . "/" . $_[0]; - $settree = $parser->parse_file($setfile); - $setMapsType = $settree->findvalue("/MAPS/\@type"); +sub parseConfig { + $configFileName = $_[0]; + $configFile = $confDir . "/" . $_[0]; + $configTree = $parser->parse_file($configFile); + $configMapsType = $configTree->findvalue("/MAPS/\@type"); } sub buildAncestry { # recursive @@ -299,7 +299,7 @@ sub buildAncestry { # recursive print "

"; print $parentXmlFileName. "->" . join( "->", @ancestryList ) . "->" - . $setfileName; + . $configFileName; print "

"; print "

The faulty include directive was removed.

"; print @@ -323,7 +323,7 @@ sub buildAncestry { # recursive . $xmlfileName . "" . "->" . join( "->", @ancestryList ) . "->" - . $setfileName; + . $configFileName; print "

"; print "

The faulty include directive was removed.

"; print "

"; @@ -333,8 +333,8 @@ sub buildAncestry { # recursive } my $xmltree; - if ( $xmlfile eq $setfile ) { - $xmltree = $settree; + if ( $xmlfile eq $configFile ) { + $xmltree = $configTree; } else { @@ -354,7 +354,7 @@ sub buildAncestry { # recursive my $currentSpecFileName = $xmltree->findvalue("/MAPS/\@specDbFile"); # compliance checking MAPS type - unless ( $currentMapsType eq $setMapsType ) { + unless ( $currentMapsType eq $configMapsType ) { print "

the included config file does not comply with the MAPS type of the current config file

"; print "

The faulty include directive was removed.

"; @@ -364,7 +364,7 @@ sub buildAncestry { # recursive } # compliance checking specDbFile - unless ( $currentSpecFileName eq $specfileName ) { + unless ( $currentSpecFileName eq $specFileName ) { print "

the included config file is not based on the same specification file as current config file

"; print "

The faulty include directive was removed.

"; @@ -449,8 +449,8 @@ sub del { my $registerName = $_[0]; my $fieldName = $_[1]; - my $xmlfile = $setfile; - my $xmltree = $settree; + my $xmlfile = $configFile; + my $xmltree = $configTree; my $maps = $xmltree->findnodes("/MAPS")->shift(); my $register = $xmltree->findnodes( "/MAPS/register[\@name='" . $registerName . "']" ) @@ -630,8 +630,8 @@ sub print_fileSelection { sub changeAncestor { my $ancestorFileName = $_[0]; - my $xmltree = $settree; - my $xmlfile = $setfile; + my $xmltree = $configTree; + my $xmlfile = $configFile; my $maps = $xmltree->findnodes("/MAPS")->shift(); $maps->setAttribute( "inheritSettingsFrom", $ancestorFileName ); @@ -645,7 +645,7 @@ sub changeAncestor { } sub getAncestor { - my $xmltree = $settree; + my $xmltree = $configTree; return ( $xmltree->findvalue("/MAPS/\@inheritSettingsFrom") || "" ); } @@ -653,10 +653,10 @@ sub save { my $registerName = $_[0]; my $fieldName = $_[1]; - my $xmlfile = $setfile; + my $xmlfile = $configFile; my $newValue = $_[2]; - my $xmltree = $settree; + my $xmltree = $configTree; my $maps = $xmltree->findnodes("/MAPS")->shift(); #my @fields = $xmltree->findnodes("/MAPS/register[\@name='".$registerName."']/field[\@name='".$fieldName."']"); @@ -695,32 +695,32 @@ sub save { sub copyDefaultRegister { my $registerName = $_[0]; - my $settree = $parser->parse_file($setfile); - my $spectree = $parser->parse_file($specfile); - my $setmaps = $settree->findnodes("/MAPS")->shift(); - my $specmaps = $spectree->findnodes("/MAPS")->shift(); + my $configTree = $parser->parse_file($configFile); + my $specTree = $parser->parse_file($specFile); + my $configmaps = $configTree->findnodes("/MAPS")->shift(); + my $specmaps = $specTree->findnodes("/MAPS")->shift(); my $specRegister = - $spectree->findnodes( "/MAPS/register[\@name='" . $registerName . "']" ) + $specTree->findnodes( "/MAPS/register[\@name='" . $registerName . "']" ) ->shift(); - my $setRegister = $setmaps->addNewChild( "", "register" ); - $setRegister->setAttribute( "name", $registerName ); + my $configRegister = $configmaps->addNewChild( "", "register" ); + $configRegister->setAttribute( "name", $registerName ); my @specFields = $specRegister->findnodes("./field"); for my $specField (@specFields) { my $fieldName = $specField->findvalue("./\@name"); my $fieldValue = $specField->findvalue("./\@defaultValue"); - my $setField = $setRegister->addNewChild( "", "field" ); - $setField->setAttribute( "name", $fieldName ); - $setField->setAttribute( "value", $fieldValue ); - print $setField->findvalue("./\@value"); + my $configField = $configRegister->addNewChild( "", "field" ); + $configField->setAttribute( "name", $fieldName ); + $configField->setAttribute( "value", $fieldValue ); + print $configField->findvalue("./\@value"); } - open( SCHREIBEN, "> $setfile" ) - or print "could not open file $setfile for writing: $!\n"; + open( SCHREIBEN, "> $configFile" ) + or print "could not open file $configFile for writing: $!\n"; - print SCHREIBEN $settree->toString(); + print SCHREIBEN $configTree->toString(); close SCHREIBEN; } @@ -748,7 +748,7 @@ sub printHash { # # my @ancestryWithChild; # push(@ancestryWithChild,@ancestryList); -# push(@ancestryWithChild,$setfileName); +# push(@ancestryWithChild,$configFileName); # # my $index=0; # for my $fileName (reverse(@ancestryWithChild)){ @@ -763,18 +763,18 @@ sub printHash { sub print_registers { my $xmlfile = $_[0]; my $xmltree; - if ( $xmlfile eq $setfile ) { - $xmltree = $settree; + if ( $xmlfile eq $configFile ) { + $xmltree = $configTree; } - elsif ( $xmlfile eq $specfile ) { - $xmltree = $spectree; + elsif ( $xmlfile eq $specFile ) { + $xmltree = $specTree; } else { die "xmlfile given to sub print_registers is unknown"; } my @registers = sort by_name $xmltree->findnodes("/MAPS/register"); print ""; @@ -784,7 +784,7 @@ sub print_registers { my $registerId = $register->findvalue("./\@id"); my $registerSize = $register->findvalue("./\@size"); my $registerDescr = prepare_text( - $spectree->findvalue( + $specTree->findvalue( "/MAPS/register[\@name='" . $registerName . "']/description" ) || "n/a" @@ -801,12 +801,12 @@ EOF #print ""; - if ( $xmlfile eq $setfile ) { # we are printing the Specifications Tree + if ( $xmlfile eq $configFile ) { # we are printing the Specifications Tree print < X  EOF } - if ( $xmlfile eq $specfile ) { # we are printing the Settings Tree + if ( $xmlfile eq $specFile ) { # we are printing the Settings Tree print < →  @@ -840,14 +840,14 @@ sub print_fields { my $readOnlyFlag = 0; my $fieldValue = $field->findvalue("./\@value"); my $fieldSize = - $spectree->findvalue( "/MAPS/register[\@name='" + $specTree->findvalue( "/MAPS/register[\@name='" . $registerName . "']/field[\@name='" . $fieldName . "']/\@size" ) || "n/a"; my $fieldDescr = prepare_text( - $spectree->findvalue( + $specTree->findvalue( "/MAPS/register[\@name='" . $registerName . "']/field[\@name='" @@ -895,12 +895,12 @@ EOF } print ''; - if ( $xmlfile eq $specfile ) { # we are printing the Specifications tree + if ( $xmlfile eq $specFile ) { # we are printing the Specifications tree print < →  EOF } - if ( $xmlfile eq $setfile ) { # we are printing the Settings Tree + if ( $xmlfile eq $configFile ) { # we are printing the Settings Tree if ( $isHeritageFrom eq "" ) { # these are actual settings, not inherited! diff --git a/xml_spielwiese/ini2xml.pl b/xml_spielwiese/ini2xml.pl index 6da51f2..0d7176c 100755 --- a/xml_spielwiese/ini2xml.pl +++ b/xml_spielwiese/ini2xml.pl @@ -215,21 +215,6 @@ while (defined(my $line = )) { -sub getFieldVal { - - my $regStr = $_[0]; # pointer! - my $start = $_[1]; - my $end = $_[2]; - - my $regStrLen = length($$regStr); - - my $substrStart = $regStrLen-1-$end; - my $substrLength = $end-$start+1; - - return substr $$regStr,$substrStart,$substrLength; - - -} # sub register2hex { diff --git a/xml_spielwiese/xml2ini.pl b/xml_spielwiese/xml2ini_old.pl similarity index 100% rename from xml_spielwiese/xml2ini.pl rename to xml_spielwiese/xml2ini_old.pl -- 2.43.0
$registerId