markup-validator commit: Avoid error log trashing for docs with no root namespace but some other ones.

changeset:   3192:d51bf903b549
user:        Ville Skyttä <ville.skytta@iki.fi>
date:        Tue Dec 14 23:17:16 2010 +0200
files:       httpd/cgi-bin/check
description:
Avoid error log trashing for docs with no root namespace but some other ones.


diff -r 45a1d08f64b4 -r d51bf903b549 httpd/cgi-bin/check
--- a/httpd/cgi-bin/check	Tue Dec 14 22:21:57 2010 +0200
+++ b/httpd/cgi-bin/check	Tue Dec 14 23:17:16 2010 +0200
@@ -1496,16 +1496,12 @@
 
     # Namespaces...
     $T->param(file_namespace => $File->{Namespace});
+
+    # Non-root ones; unique, preserving occurrence order
     my %seen_ns = ();
-    my @bulk_ns = @{$File->{Namespaces}};
-    $File->{Namespaces} = [];    # reinitialize the list of non-root namespaces
-                                 # ... and then get a uniq version of it
-    foreach my $single_namespace (@bulk_ns) {
-        push(@{$File->{Namespaces}}, $single_namespace)
-            unless (($single_namespace eq $File->{Namespace}) or
-            $seen_ns{$single_namespace}++);
-    }
-    my @nss = map({uri => $_}, @{$File->{Namespaces}});
+    $seen_ns{$File->{Namespace}}++ if defined($File->{Namespace});
+    my @nss =
+        map { $seen_ns{$_}++ == 0 ? {uri => $_} : () } @{$File->{Namespaces}};
     $T->param(file_namespaces => \@nss) if @nss;
 
     if ($File->{Opt}->{DOCTYPE}) {

Received on Tuesday, 14 December 2010 22:15:59 UTC