--- loncom/build/lpml_parse.pl 2002/02/05 01:28:57 1.40 +++ loncom/build/lpml_parse.pl 2002/04/08 10:56:16 1.43 @@ -1,11 +1,16 @@ #!/usr/bin/perl +# -------------------------------------------------------- Documentation notice +# Run "perldoc ./lpml_parse.pl" in order to best view the software +# documentation internalized in this program. + +# --------------------------------------------------------- License Information # The LearningOnline Network with CAPA # lpml_parse.pl - Linux Packaging Markup Language parser # -# $Id: lpml_parse.pl,v 1.40 2002/02/05 01:28:57 harris41 Exp $ +# $Id: lpml_parse.pl,v 1.43 2002/04/08 10:56:16 harris41 Exp $ # -# Written by Scott Harrison, harris41@msu.edu +# Written by Scott Harrison, codeharrison@yahoo.com # # Copyright Michigan State University Board of Trustees # @@ -37,7 +42,7 @@ # 11/4,11/5,11/6,11/7,11/16,11/17 - Scott Harrison # 12/2,12/3,12/4,12/5,12/6,12/13,12/19,12/29 - Scott Harrison # YEAR=2002 -# 1/8,1/9 - Scott Harrison +# 1/8,1/9,1/29,1/31,2/5,3/21,4/8 - Scott Harrison # ### @@ -58,7 +63,8 @@ # # I am using a multiple pass-through approach to parsing # the lpml file. This saves memory and makes sure the server -# will never be overloaded. +# will never be overloaded. At some point, I expect the +# first two steps will be implemented with my XFML # # This is meant to parse files meeting the lpml document type. # See lpml.dtd. LPML=Linux Packaging Markup Language. @@ -84,7 +90,7 @@ END # ------------------------------------------------- Grab command line arguments -my $mode; +my $mode=''; if (@ARGV==5) { $mode = shift @ARGV; } @@ -95,20 +101,20 @@ else { exit -1; # exit with error status } -my $categorytype; +my $categorytype=''; if (@ARGV) { $categorytype = shift @ARGV; } -my $dist; +my $dist=''; if (@ARGV) { $dist = shift @ARGV; } -my $targetroot; -my $sourceroot; -my $targetrootarg; -my $sourcerootarg; +my $targetroot=''; +my $sourceroot=''; +my $targetrootarg=''; +my $sourcerootarg=''; if (@ARGV) { $sourceroot = shift @ARGV; } @@ -138,7 +144,7 @@ END # ---------------------------------------------------- Start first pass through my @parsecontents = <>; my $parsestring = join('',@parsecontents); -my $outstring; +my $outstring=''; # Need to make a pass through and figure out what defaults are # overrided. Top-down overriding strategy (leaves don't know @@ -152,7 +158,7 @@ $parser = HTML::TokeParser->new(\$parses die('can\'t create TokeParser object'); $parser->xml_mode('1'); my %hash; -my $key; +my $key=''; while ($token = $parser->get_token()) { if ($token->[0] eq 'S') { $hloc++; @@ -173,9 +179,9 @@ while ($token = $parser->get_token()) { } # --------------------------------------------------- Start second pass through -undef $hloc; -undef @hierarchy; -undef $parser; +undef($hloc); +undef(@hierarchy); +undef($parser); $hierarchy[0]=0; $parser = HTML::TokeParser->new(\$parsestring) or die('can\'t create TokeParser object'); @@ -949,7 +955,9 @@ sub format_directory { my ($chmod,$chown)=split(/\s/,$categoryhash{$categoryname}); return $directory="\n". "$categoryname". - " ". + "". + " ". "$chmod
$chown". "$thtml". "". @@ -1128,7 +1136,7 @@ sub format_file { if ($mode eq 'html') { return ($file="\n". "". - " ". @@ -1228,7 +1236,8 @@ END $logcmd.' && echo "'. 'Configuration source file does not exist '. ''.$sourceroot.'/'.$source.'"'. - "$logcmd); } && perl verifymodown.pl ${targetroot}/${target} \"$categoryhash{$categoryname}\"$logcmd;\n\n"; + "$logcmd); } && perl verifymodown.pl ${targetroot}/${target} \"". + "$categoryhash{$categoryname}\"$logcmd;\n\n"; } elsif ($mode eq 'build' && $build) { push @buildall,$sourceroot.'/'.$source; @@ -1337,7 +1346,7 @@ sub format_fileglob { $parser->get_tag('/fileglob'); if ($mode eq 'html') { return $fileglob="\n". - " ". @@ -1453,6 +1462,7 @@ sub format_build { if ($text) { $parser->get_tag('/build'); $build=$sourceroot.'/'.$text.';'.$tokeninfo[2]{'trigger'}; + $build=~s/([^\\])\\\s+/$1/g; # allow for lines split onto new lines } return ''; } @@ -1545,6 +1555,8 @@ sub trim { # ----------------------------------- POD (plain old documentation, CPAN style) +=pod + =head1 NAME lpml_parse.pl - This is meant to parse files meeting the lpml document type. @@ -1612,4 +1624,12 @@ linux Packaging/Administrative +=head1 AUTHOR + + Scott Harrison + codeharrison@yahoo.com + +Please let me know how/if you are finding this script useful and +any/all suggestions. -Scott + =cut