summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorville <ville@localhost>2009-11-25 19:52:48 +0000
committerville <ville@localhost>2009-11-25 19:52:48 +0000
commit6117bd7e49610c309203c2cf0c6afbac4b9b3f01 (patch)
tree9e776966453afcf1f492f236c27e0353e6f92b92
parentd7787da78a1e1370e95166ac1ab9b35c1c887cca (diff)
downloadmarkup-validator-6117bd7e49610c309203c2cf0c6afbac4b9b3f01.zip
markup-validator-6117bd7e49610c309203c2cf0c6afbac4b9b3f01.tar.gz
markup-validator-6117bd7e49610c309203c2cf0c6afbac4b9b3f01.tar.bz2
Fix some cascading if-elsif chains flagged by perlcritic.
-rwxr-xr-xhttpd/cgi-bin/check61
-rwxr-xr-xhttpd/cgi-bin/sendfeedback.pl4
2 files changed, 31 insertions, 34 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index cc0c4fc..228eb46 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -14,7 +14,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.731 2009-11-25 19:09:39 ville Exp $
+# $Id: check,v 1.732 2009-11-25 19:52:47 ville Exp $
#
# We need Perl 5.8.0+.
@@ -201,7 +201,7 @@ EOF
#
# Strings
- $VERSION = q$Revision: 1.731 $;
+ $VERSION = q$Revision: 1.732 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -909,19 +909,15 @@ if (!$File->{'Is Valid'} && $File->{Opt}->{'Show Tidy'}) {
}
}
-my $template;
-
-if ($File->{Opt}->{Output} eq 'earl') {
- $template = &get_template($File, 'earl_xml.tmpl');
-}
-elsif ($File->{Opt}->{Output} eq 'n3') {
- $template = &get_template($File, 'earl_n3.tmpl');
-}
-elsif ($File->{Opt}->{Output} eq 'json') {
- $template = &get_template($File, 'json_output.tmpl');
-}
-elsif ($File->{Opt}->{Output} eq 'ucn') {
- $template = &get_template($File, 'ucn_output.tmpl');
+my %templates = (
+ earl => 'earl_xml.tmpl',
+ n3 => 'earl_n3.tmpl',
+ json => 'json_output.tmpl',
+ ucn => 'ucn_output.tmpl',
+);
+my $template = $templates{$File->{Opt}->{Output}};
+if ($template) {
+ $template = &get_template($File, $template);
}
elsif ($File->{Opt}->{Output} eq 'soap12') {
if ($CFG->{'Enable SOAP'} != 1) {
@@ -2791,7 +2787,8 @@ sub set_parse_mode
);
return;
}
- elsif ($parseModeFromMimeType ne 'TBD') {
+
+ if ($parseModeFromMimeType ne 'TBD') {
# if The mime type gives clear indication of whether the document is
# XML or not
@@ -2823,7 +2820,8 @@ sub set_parse_mode
}
return;
}
- elsif ($parseModeFromDoctype ne 'TBD') {
+
+ if ($parseModeFromDoctype ne 'TBD') {
# the mime type is ambiguous (hence we didn't stop at the previous test)
# but by now we're sure that the document type is a good indication
@@ -2844,7 +2842,8 @@ sub set_parse_mode
$File->{ModeChoice} = 'Doctype';
return;
}
- elsif ($parseModeFromXMLDecl ne 'TBD') {
+
+ if ($parseModeFromXMLDecl ne 'TBD') {
# the mime type is ambiguous (hence we didn't stop at the previous test)
# and so was the doctype
@@ -2861,22 +2860,20 @@ sub set_parse_mode
$File->{ModeChoice} = 'XMLDecl';
return;
}
- else {
- # this is the last case. We know that all modes are not TBD,
- # yet mime type, doctype AND XML DECL tests have failed => we are saved
- # by the presence of namespaces
- if ($File->{Mode} eq "") {
- $File->{Mode} = "DTD+" . $parseModeFromNamespace;
- }
- elsif ($File->{Mode} =~ /\+/) {
- $File->{Mode} =~ s/\+.*/\+$parseModeFromNamespace/;
- }
- else {
- $File->{Mode} = $File->{Mode} . "+" . $parseModeFromNamespace;
- }
- $File->{ModeChoice} = 'Namespace';
+ # this is the last case. We know that all modes are not TBD,
+ # yet mime type, doctype AND XML DECL tests have failed => we are saved
+ # by the presence of namespaces
+ if ($File->{Mode} eq "") {
+ $File->{Mode} = "DTD+" . $parseModeFromNamespace;
+ }
+ elsif ($File->{Mode} =~ /\+/) {
+ $File->{Mode} =~ s/\+.*/\+$parseModeFromNamespace/;
+ }
+ else {
+ $File->{Mode} = $File->{Mode} . "+" . $parseModeFromNamespace;
}
+ $File->{ModeChoice} = 'Namespace';
}
#
diff --git a/httpd/cgi-bin/sendfeedback.pl b/httpd/cgi-bin/sendfeedback.pl
index eeaa2ab..da309e1 100755
--- a/httpd/cgi-bin/sendfeedback.pl
+++ b/httpd/cgi-bin/sendfeedback.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl -T
##
## feedback generator for W3C Markup Validation Service
-# # $Id: sendfeedback.pl,v 1.16 2009-11-25 19:09:39 ville Exp $
+# # $Id: sendfeedback.pl,v 1.17 2009-11-25 19:52:48 ville Exp $
## Pragmas.
use strict;
@@ -68,7 +68,7 @@ EOF
delete $ENV{PATH};
our $q = CGI->new();
-our $lang = 'en_US'; # @@@ TODO: conneg
+our $lang = 'en_US'; # @@@ TODO: conneg
# Read error message + explanations file
%RSRC = Config::General->new(