diff options
author | ville <ville@localhost> | 2009-11-23 22:15:19 +0000 |
---|---|---|
committer | ville <ville@localhost> | 2009-11-23 22:15:19 +0000 |
commit | 5b60b407ff2794593e3ccffd7533d5e2449e08c8 (patch) | |
tree | 2eca829ccbc61f847db1be6f4d6cfa934055b073 /misc | |
parent | 675a1c5355fc61459257de958e7090837e36507a (diff) | |
download | markup-validator-5b60b407ff2794593e3ccffd7533d5e2449e08c8.zip markup-validator-5b60b407ff2794593e3ccffd7533d5e2449e08c8.tar.gz markup-validator-5b60b407ff2794593e3ccffd7533d5e2449e08c8.tar.bz2 |
Run perltidy on perl sources.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/bundle/Makefile.PL | 70 | ||||
-rwxr-xr-x | misc/docs_errors.pl | 183 | ||||
-rwxr-xr-x | misc/spmpp.pl | 18 |
3 files changed, 139 insertions, 132 deletions
diff --git a/misc/bundle/Makefile.PL b/misc/bundle/Makefile.PL index 794a36c..5f6fdee 100644 --- a/misc/bundle/Makefile.PL +++ b/misc/bundle/Makefile.PL @@ -8,43 +8,45 @@ WriteMakefile( LICENSE => 'open_source', VERSION_FROM => 'lib/Bundle/W3C/Validator.pm', PREREQ_PM => { - # Hard dependencies: - CGI => 2.81, - CGI::Carp => 0, - Config::General => 2.32, - Encode => 0, - Encode::Alias => 0, - Encode::HanExtra => 0, - File::Spec::Functions => 0, - HTML::Encoding => 0.52, - HTML::Parser => 3.24, - HTML::Template => 2.6, - HTTP::Headers::Auth => 0, - HTTP::Headers::Util => 0, - HTTP::Message => 1.52, - HTTP::Negotiate => 0, - HTTP::Request => 0, - JSON => 2.00, - LWP::UserAgent => 2.032, - Net::hostent => 0, - Net::IP => 0, - SGML::Parser::OpenSP => 0.991, - Socket => 0, - URI => 0, - URI::Escape => 0, - XML::LibXML => 0, - # Optional: - Encode::JIS2K => 0, - HTML::Tidy => 0, - }, - depend => { distdir => 'ChangeLog' }, - dist => { TARFLAGS => '--owner=0 --group=0 -cvf' }, - clean => { FILES => 'ChangeLog.bak' }, + # Hard dependencies: + CGI => 2.81, + CGI::Carp => 0, + Config::General => 2.32, + Encode => 0, + Encode::Alias => 0, + Encode::HanExtra => 0, + File::Spec::Functions => 0, + HTML::Encoding => 0.52, + HTML::Parser => 3.24, + HTML::Template => 2.6, + HTTP::Headers::Auth => 0, + HTTP::Headers::Util => 0, + HTTP::Message => 1.52, + HTTP::Negotiate => 0, + HTTP::Request => 0, + JSON => 2.00, + LWP::UserAgent => 2.032, + Net::hostent => 0, + Net::IP => 0, + SGML::Parser::OpenSP => 0.991, + Socket => 0, + URI => 0, + URI::Escape => 0, + XML::LibXML => 0, + + # Optional: + Encode::JIS2K => 0, + HTML::Tidy => 0, + }, + depend => {distdir => 'ChangeLog'}, + dist => {TARFLAGS => '--owner=0 --group=0 -cvf'}, + clean => {FILES => 'ChangeLog.bak'}, ); -sub MY::postamble { - return <<'MAKE_FRAG'; +sub MY::postamble +{ + return <<'MAKE_FRAG'; ChangeLog: README lib/Bundle/W3C/Validator.pm t/00load.t cvs2cl --FSF --utc --prune \ --ignore ChangeLog --ignore cvsignore --ignore SIGNATURE \ diff --git a/misc/docs_errors.pl b/misc/docs_errors.pl index 28ae8e4..b6774c7 100755 --- a/misc/docs_errors.pl +++ b/misc/docs_errors.pl @@ -2,143 +2,148 @@ ## ## Generates HTML documentation of error messages and explanations ## for W3C Markup Validation Service -## $Id: docs_errors.pl,v 1.11 2009-06-29 14:37:08 ville Exp $ +## $Id: docs_errors.pl,v 1.12 2009-11-23 22:15:18 ville Exp $ ## Pragmas. use strict; use warnings; - ## Modules. See also the BEGIN block further down below. use File::Spec::Functions qw(catfile); -use HTML::Template 2.6 qw(); -use Config::General 2.32 qw(); # Need 2.32 for <msg 0>, rt.cpan.org#17852 +use HTML::Template 2.6 qw(); +use Config::General 2.32 qw(); # Need 2.32 for <msg 0>, rt.cpan.org#17852 use vars qw($DEBUG $CFG $VERSION); + # Define global constants use constant TRUE => 1; use constant FALSE => 0; BEGIN { - # Launder data for -T; -AutoLaunder doesn't catch this one. - if (exists $ENV{W3C_VALIDATOR_HOME}) { - $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/; - $ENV{W3C_VALIDATOR_HOME} = $1; - } - - # - # Read Config Files. - eval { - my %config_opts = ( - -ConfigFile => ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'), - -MergeDuplicateOptions => TRUE, - -MergeDuplicateBlocks => TRUE, - -SplitPolicy => 'equalsign', - -UseApacheInclude => TRUE, - -IncludeRelative => TRUE, - -InterPolateVars => TRUE, - -AutoLaunder => TRUE, - -AutoTrue => TRUE, - -DefaultConfig => { - Paths => { - Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'), - }, - }, - ); - my %cfg = Config::General->new(%config_opts)->getall(); - $CFG = \%cfg; - }; - if ($@) { - die <<".EOF."; + + # Launder data for -T; -AutoLaunder doesn't catch this one. + if (exists $ENV{W3C_VALIDATOR_HOME}) { + $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/; + $ENV{W3C_VALIDATOR_HOME} = $1; + } + + # + # Read Config Files. + eval { + my %config_opts = ( + -ConfigFile => + ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'), + -MergeDuplicateOptions => TRUE, + -MergeDuplicateBlocks => TRUE, + -SplitPolicy => 'equalsign', + -UseApacheInclude => TRUE, + -IncludeRelative => TRUE, + -InterPolateVars => TRUE, + -AutoLaunder => TRUE, + -AutoTrue => TRUE, + -DefaultConfig => { + Paths => { + Base => + ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'), + }, + }, + ); + my %cfg = Config::General->new(%config_opts)->getall(); + $CFG = \%cfg; + }; + if ($@) { + die <<".EOF."; Could not read configuration. Set the W3C_VALIDATOR_CFG environment variable or copy conf/* to /etc/w3c/. Make sure that the configuration file and all included files are readable by the web server user. The error was:\n'$@' .EOF. - } -} # end of BEGIN block. + } +} # end of BEGIN block. # # Get rid of (possibly insecure) $PATH. delete $ENV{PATH}; -our $lang = 'en_US'; # @@@ TODO: conneg +our $lang = 'en_US'; # @@@ TODO: conneg # Read error message + explanations file -our $error_messages_file = catfile($CFG->{Paths}->{Templates}, $lang, 'error_messages.cfg'); -our %config_errs = ( -MergeDuplicateBlocks => 1, - -ConfigFile => $error_messages_file); +our $error_messages_file = + catfile($CFG->{Paths}->{Templates}, $lang, 'error_messages.cfg'); +our %config_errs = ( + -MergeDuplicateBlocks => 1, + -ConfigFile => $error_messages_file +); our %rsrc = Config::General->new(%config_errs)->getall(); - our $T = HTML::Template->new( - filename => catfile($CFG->{Paths}->{Templates}, $lang, 'docs_errors.tmpl'), - die_on_bad_params => FALSE, + filename => catfile($CFG->{Paths}->{Templates}, $lang, 'docs_errors.tmpl'), + die_on_bad_params => FALSE, ); $T->param(list_errors_hasverbose => &list_errors_hasverbose(\%rsrc)); -$T->param(list_errors_noverbose => &list_errors_noverbose(\%rsrc)); +$T->param(list_errors_noverbose => &list_errors_noverbose(\%rsrc)); print $T->output; -sub list_errors_hasverbose{ - my $rsrc = shift; +sub list_errors_hasverbose +{ + my $rsrc = shift; my $errors = []; my $error_id; - my $max_error_id=500; # where to stop - for ($error_id=0;$error_id<$max_error_id;$error_id++) - { - my %single_error; - if ($rsrc->{msg}->{$error_id}) - { - my $verbose = $rsrc->{msg}->{$error_id}->{verbose}; - if ($verbose) - { - my $original = $rsrc->{msg}->{$error_id}->{original}; - $original = &de_template_explanation($original); - $single_error{original} = $original; - $single_error{id} = $error_id; - $single_error{verbose} = $rsrc->{msg}->{$error_id}->{verbose}; - $single_error{verbose} =~ s/<!--CFG_HOME_PAGE-->/$CFG->{'Home Page'}/g; - - push @{$errors}, \%single_error; + my $max_error_id = 500; # where to stop + for ($error_id = 0; $error_id < $max_error_id; $error_id++) { + my %single_error; + if ($rsrc->{msg}->{$error_id}) { + my $verbose = $rsrc->{msg}->{$error_id}->{verbose}; + if ($verbose) { + my $original = $rsrc->{msg}->{$error_id}->{original}; + $original = &de_template_explanation($original); + $single_error{original} = $original; + $single_error{id} = $error_id; + $single_error{verbose} = $rsrc->{msg}->{$error_id}->{verbose}; + $single_error{verbose} =~ + s/<!--CFG_HOME_PAGE-->/$CFG->{'Home Page'}/g; + + push @{$errors}, \%single_error; + # Fix up relative paths (/check vs /docs/errors.html) s/href="docs\//href="/ for $single_error{original}, $single_error{verbose}; - } + } - } + } } - return $errors; + return $errors; } -sub list_errors_noverbose{ - my $rsrc = shift; +sub list_errors_noverbose +{ + my $rsrc = shift; my $errors = []; my $error_id; - my $max_error_id=500; # where to stop - for ($error_id=0;$error_id<$max_error_id;$error_id++) - { - my %single_error; - if ($rsrc->{msg}->{$error_id}) - { - my $verbose = $rsrc->{msg}->{$error_id}->{verbose}; - if (! $verbose) - { - my $original = $rsrc->{msg}->{$error_id}->{original}; - $original = &de_template_explanation($original); - $single_error{original} = $original; - $single_error{id} = $error_id; - $single_error{verbose} = $rsrc->{msg}->{$error_id}->{verbose}; - push @{$errors}, \%single_error; - } - - } + my $max_error_id = 500; # where to stop + for ($error_id = 0; $error_id < $max_error_id; $error_id++) { + my %single_error; + if ($rsrc->{msg}->{$error_id}) { + my $verbose = $rsrc->{msg}->{$error_id}->{verbose}; + if (!$verbose) { + my $original = $rsrc->{msg}->{$error_id}->{original}; + $original = &de_template_explanation($original); + $single_error{original} = $original; + $single_error{id} = $error_id; + $single_error{verbose} = $rsrc->{msg}->{$error_id}->{verbose}; + push @{$errors}, \%single_error; + } + + } } - return $errors; + return $errors; } -sub de_template_explanation { -# takes the error message template, and replace "template keywords" with real life keywords +sub de_template_explanation +{ + + # takes the error message template, and replace "template keywords" with real life keywords my $explanation = shift; if ($explanation) { $explanation =~ s/\%1/X/; diff --git a/misc/spmpp.pl b/misc/spmpp.pl index c6a153c..ff364fc 100755 --- a/misc/spmpp.pl +++ b/misc/spmpp.pl @@ -4,7 +4,7 @@ # for use in the Validator, from an OpenSP ParserMessages.rc. # (spmpp = "SP Message Pre-Processor") # -# $Id: spmpp.pl,v 1.2 2004-05-09 15:56:55 link Exp $ +# $Id: spmpp.pl,v 1.3 2009-11-23 22:15:18 ville Exp $ # # @@ -23,14 +23,14 @@ my @msg; # # Snarf OpenSP's ParserMessages.rc and populate @msg. my $msgfile = $ARGV[0] || "/usr/local/validator/htdocs/config/verbosemsg.rc"; -open FH, $msgfile - or die "Can't open OpenSP ParserMessages file '$msgfile': $!"; +open FH, $msgfile or + die "Can't open OpenSP ParserMessages file '$msgfile': $!"; while (<FH>) { - next if /^\s*$/; - my($id, $s) = split /, /, $_, 2; - $id += 0; # Force numerical (kill leading space)... - chomp $s; # Strip newline from end of message... - push @msg, [$id, $s]; + next if /^\s*$/; + my ($id, $s) = split /, /, $_, 2; + $id += 0; # Force numerical (kill leading space)... + chomp $s; # Strip newline from end of message... + push @msg, [$id, $s]; } close FH; @@ -53,7 +53,7 @@ print <<".EOF."; # the last digit of the "muid" is replaced at runtime). # for (@msg) { - print <<"_.EOF._"; + print <<"_.EOF._"; <msg $_->[0]> original = $_->[1] verbose <<.EOF. |