cool, and maybe Freudian.
Attached.

(Ah, and i have tested it with my old groff installation, then
copied it onto a current v1.22.3.)

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
diff --git a/src/devices/gropdf/pdfmom.pl b/src/devices/gropdf/pdfmom.pl
index a4f250c6..af48d6d5 100644
--- a/src/devices/gropdf/pdfmom.pl
+++ b/src/devices/gropdf/pdfmom.pl
@@ -123,7 +123,36 @@ if ($readstdin)
 
 if ($dev eq 'pdf')
 {
-    system("groff -Tpdf -dLABEL.REFS=1 -mom -z $preconv $cmdstring 2>&1 | grep '^\. *ds' | groff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -mom -z - $preconv $cmdstring 2>&1 | grep '^\. *ds' | groff -Tpdf -mom $preconv - $cmdstring");
+    my (@strings);
+    my ($tmpfh, $tmpfn) = tempfile('pdfmom-XXXXX', UNLINK => 1);
+    die "pdf: binmode tmpfile: $^E" unless binmode $tmpfh;
+
+    die "pdf: open 1: $^E" unless open ROFF,
+        'groff -Tpdf -dLABEL.REFS=1 -mom -z ' .$preconv. ' ' .$cmdstring.
+        ' 2>&1 |';
+    die "pdf: binmode 1: $^E" unless binmode ROFF;
+    while(<ROFF>){
+        print $tmpfh $_ if /^\.ds/
+    }
+    die "pdf: close 1: $^E" unless close ROFF;
+    $tmpfh->flush;
+
+    die "pdf: open 2: $^E" unless open ROFF,
+        'groff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -mom -z ' .$tmpfn1. ' ' .
+        $preconv. ' ' .$cmdstring. ' 2>&1 |';
+    die "pdf: binmode 2: $^E" unless binmode ROFF;
+    while(<ROFF>){
+        push @strings, $_ if /^\.ds/
+    }
+    die "pdf: close 2: $^E" unless close ROFF;
+
+    die "pdf: open 3: $^E" unless open ROFF,
+        '| groff -Tpdf -mom - ' .$preconv. ' ' .$cmdstring;
+    for my $s (@strings){
+      print ROFF $s
+    }
+    die "pdf: close 3: $^E" unless close ROFF
+
 }
 elsif ($dev eq 'ps')
 {

Reply via email to