[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#872169: A solution to the issue



Tags: patch

Hi Laura,

I have analyzed this problem and I believe that the solution is to modify the
«validate» script of the validation system for .html files to use
onsgmls. I attach the «validate-onsgmls» file and the diff file 
(validate.patch).
To make the migration, the opensp package will need to be installed on
the server.

I hope this will solve the issue satisfactorily.

Regards!


I. De Marchi
--- validate	2017-09-04 18:29:47.672459787 +0200
+++ validate-onsgmls	2017-09-04 18:26:29.646745349 +0200
@@ -15,6 +15,12 @@
 # Contributors:
 # * Ville Skytta
 #
+# 04/09/2017 Adapted by I. De Marchi for use with onsgmls
+# due to the replacement of the sp package by opensp 
+# (see bug 846178 at 
+# https://packages.qa.debian.org/j/jade/news/20161206T124612Z.html
+# for more info).
+#
 #####################################################################
 
 #####################################################################
@@ -36,7 +42,7 @@
 #######################
 
 # Version and identifier of this program
-my $VERSION = '1.1.3';
+my $VERSION = '1.1.3.1';
 my $progname = "Offline HTMLHelp.com Validator, Version $VERSION
 by Liam Quinn <liam\@htmlhelp.com>";
 my $usage = "Usage: validate [OPTION] [FILE...]";
@@ -45,13 +51,13 @@
 # SGML directory (catalog, DTDs, SGML declarations)
 my $sgmlDir = '/usr/share/sgml/html/dtd';
 
-# Location of nsgmls executable
-my $nsgmlsLocation = '/usr/bin/nsgmls';
+# Location of onsgmls executable
+my $onsgmlsLocation = '/usr/bin/onsgmls';
 
-# nsgmls command line
+# onsgmls command line
 # The SGML declaration and HTML document's filename will be appended
 # to this string
-my $nsgmls = "$nsgmlsLocation -E0 -s";
+my $onsgmls = "$onsgmlsLocation";
 
 # Catalog files for HTML/SGML and XHTML/XML
 my $htmlCatalog = "/usr/share/sgml/html/entities/catalog";
@@ -221,13 +227,13 @@
     push(@files, '-');
 }
 
-# Check that nsgmls is available before we get too far
-unless (-e $nsgmlsLocation) {
-    &error("$nsgmlsLocation is not installed");
+# Check that onsgmls is available before we get too far
+unless (-e $onsgmlsLocation) {
+    &error("$onsgmlsLocation is not installed");
     exit $errors;
 }
 unless (-x _) {
-    &error("$nsgmlsLocation is not executable");
+    &error("$onsgmlsLocation is not executable");
     exit $errors;
 }
 
@@ -307,7 +313,6 @@
 
     my @errors; # queue of errors
     my @externalErrors; # queue of errors in an external DTD
-    my @warnings ;
     my $lineAdjust = 0; # account for line number changes if we add a DOCTYPE
 
     # Determine the level of HTML
@@ -381,25 +386,20 @@
     }
 
     # Run the validator
-    open(NSGMLS, "$nsgmls $sgmlDecl{$htmlLevel} "
+
+    open(ONSGMLS, "$onsgmls $sgmlDecl{$htmlLevel} "
         . &quoteFilename($fileToValidate) . " 2>&1 |")
-        || die("Unable to execute $nsgmls: $!\n");
+        || die("Unable to execute $onsgmls: $!\n");
 
     # Create a queue of errors
-    while (<NSGMLS>) {
-
+    while (<ONSGMLS>) {
         my @error = split(/:/, $_, 6);
 
         if ($#error < 5) {
 
             next;
 
-	} elsif ($error[4] eq 'W') {
-
-	    push(@warnings, $_);
-
-
-        } elsif ($error[4] eq 'E' || $error[4] eq 'X') {
+        } elsif ($error[4] eq 'E' || $error[4] eq 'X' ) {
 
             push(@errors, $_);
 
@@ -417,7 +417,7 @@
         }
 
     }
-    close(NSGMLS);
+    close(ONSGMLS);
 
     # If we created a tempfile, unlink it
     if (defined $tempname) {
@@ -425,9 +425,10 @@
     }
 
     # Report errors
-    if ($#errors > -1 || $#externalErrors > -1) {
 
-        &startErrors($file);
+    if ($#errors > 0 || $#externalErrors > -1 ) {        
+
+	&startErrors($file);
 
         foreach (@externalErrors) {
             my @error = split(/:/, $_, 7);
@@ -454,17 +455,11 @@
                 $errorMsg .= superChomp($error[5]);
             }
 
-            &htmlError(stripLqNsgmlsGunk($errorMsg));
+            &htmlError(stripLqOnsgmlsGunk($errorMsg));
         }
 
-	foreach (@warnings) {
-
-		my @warning = split(/:/, $_, 6);
-
-		&htmlError(stripLqNsgmlsGunk($warnings[5]));
-	}
-
         foreach (@errors) {
+
             my @error = split(/:/, $_, 6);
 
             # I don't think this should happen, but I'm not sure
@@ -488,8 +483,7 @@
             } else {
                 $errorMsg .= superChomp($error[4]);
             }
-
-            &htmlError(stripLqNsgmlsGunk($errorMsg));
+            &htmlError(stripLqOnsgmlsGunk($errorMsg));
         }
 
     } else {
@@ -538,9 +532,9 @@
     return "\"$filename\"";
 }
 
-# Clean the "{{foo}}" used in nsgmls error messages
+# Clean the "{{foo}}" used in onsgmls error messages
 # The error message must be given as the first argument
-sub stripLqNsgmlsGunk {
+sub stripLqOnsgmlsGunk {
     my $errorMsg = shift;
     while ($errorMsg =~ m#\{\{"?(.+?)"?\}\}#gos) {
         my $linkText = $1;

Attachment: validate-onsgmls
Description: Binary data


Reply to: