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

Bug#480725: mptopdf does not work with beginfig(-1)



Package: context
Version: 2008.01.28-1
Severity: important
Tags: patch upstream
thanks 

When using mptopdf on a .mp file containing only one figure and thus
using beginfig(-1) to have no numbering of the resulting file at all,
the PDF is not created. This is because mpost produces a .ps file in
this case, while mptopdf.pl expects a suffix containing one or more
digits or being .mps.

Example input .mp file:
##########################
input metauml;
beginfig(-1);
  Begin.b;
  End.e;
  e.w = b.e + (15,0);
  drawObjects(b,e);
  clink(transition)(b, e);
endfig;
end
##########################

The attached patch fixes this bug. Please note, that now the resulting
file has the same name as the input .mp file with "s/.mp$/.pdf/" - not
including the intermediate suffix as it is done with the figure numbers.
It is now also done like this, if the intermediate output file has the
suffix .mps, while I don't know when and why this may occur.

Best regards,
Martin
diff -Naur old/usr/share/texmf/scripts/context/perl/mptopdf.pl new/usr/share/texmf/scripts/context/perl/mptopdf.pl
--- old/usr/share/texmf/scripts/context/perl/mptopdf.pl	2008-05-11 20:27:25.000000000 +0200
+++ new/usr/share/texmf/scripts/context/perl/mptopdf.pl	2008-05-11 20:27:34.000000000 +0200
@@ -120,7 +120,9 @@
 
 foreach my $file (@files) {
     $_ = $file ;
-    if (s/\.(\d+|mps)$// && -e $file) {
+    if (s/\.(\d+|mps|ps)$// && -e $file) {
+        my $suffix = $1 ;
+        my $pdf = basename($_).".pdf" ;
         if ($miktex) {
             $command = "pdftex -undump=mptopdf" ;
         } else {
@@ -132,15 +134,17 @@
             $command = "$command \\\\relax $file" ;
         }
         system($command) ;
-        my $pdfsrc = basename($_).".pdf";
-        rename ($pdfsrc, "$_-$1.pdf") ;
-        if (-e $pdfsrc) {
-            CopyFile ($pdfsrc, "$_-$1.pdf") ;
+        if ($suffix =~ m/\.\d+$/) {
+            rename ($pdf, "$_-$suffix.pdf") ;
+            if (-e $pdf) {
+                CopyFile ($pdf, "$_-$suffix.pdf") ;
+            }
+            $pdf = "$_-$suffix.pdf" ;
         }
         if ($done) {
             $report .= " +" ;
         }
-        $report .= " $_-$1.pdf" ;
+        $report .= " $pdf" ;
         ++$done  ;
     }
 }

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Reply to: