[Po4a-commits] "po4a/lib/Locale/Po4a Sgml.pm,1.124,1.125"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sun Jul 20 16:11:39 UTC 2008


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv12532/lib/Locale/Po4a

Modified Files:
	Sgml.pm 
Log Message:
	* lib/Locale/Po4a/Sgml.pm: Fix failures with big SGML documents
	(SIGPIPE received from nsgmls -p).


Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- Sgml.pm	15 Sep 2007 15:43:46 -0000	1.124
+++ Sgml.pm	20 Jul 2008 16:11:35 -0000	1.125
@@ -368,17 +368,25 @@
         $origfile .= ${$self->{TT}{doc_in}}[$i];
         $i+=2;
     }
+
     unless ($self->{options}{'force'}) {
-    # Detect if we can find the DTD
-    open (VALID, "| nsgmls -p")
-        or die wrap_mod("po4a::sgml",
-                        dgettext("po4a", "Can't run nsgmls -p: %s"), $!);
-    print VALID $origfile;
-    close VALID
-        or die wrap_mod("po4a::sgml",
-                        dgettext("po4a", "Error while running nsgmls -p.  ".
-                                         "Please check if nsgmls and the ".
-                                         "DTD are installed."));
+        # Detect if we can find the DTD
+        my ($tmpfh,$tmpfile)=File::Temp::tempfile("po4a-XXXX",
+                                                  SUFFIX => ".sgml",
+                                                  DIR    => "/tmp",
+                                                  UNLINK => 0);
+        print $tmpfh $origfile;
+        close $tmpfh
+            or die wrap_mod("po4a::sgml",
+                            dgettext("po4a", "Can't close tempfile: %s"), $!);
+        if (system("nsgmls -p < $tmpfile")) {
+            unlink ($tmpfile);
+            die wrap_mod("po4a::sgml",
+                         dgettext("po4a", "Error while running nsgmls -p.  ".
+                                          "Please check if nsgmls and the ".
+                                          "DTD are installed."));
+        }
+        unlink ($tmpfile);
     }
     # Detect the XML pre-prolog
     if ($origfile =~ s/^(\s*<\?xml[^?]*\?>)//) {




More information about the Po4a-commits mailing list