changeset 19758:abc158e7122e

Use epswrite/eps2write depending on capabilities of ghostscript (bug #44186). * print.m: Test whether ghostscript supports newer eps2write or only older epswrite. Cache value for future print jobs.
author Rik <rik@octave.org>
date Mon, 16 Feb 2015 14:29:43 -0800
parents c9dc27cad3c0
children 5f2c0ca0ef51
files scripts/plot/util/print.m
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/print.m	Sun Feb 15 11:46:16 2015 -0800
+++ b/scripts/plot/util/print.m	Mon Feb 16 14:29:43 2015 -0800
@@ -473,6 +473,17 @@
   ## Unix Shell;
   ##   cat > <filein> ; epstool -bbox -preview-tiff <filein> <fileout> ; rm <filein>
 
+  ## HACK: Keep track of whether ghostscript supports epswrite or eps2write.
+  persistent epsdevice;
+  if (isempty (epsdevice))
+    [status, devlist] = system (sprintf ("%s -h", opts.ghostscript.binary));
+    if (isempty (strfind (devlist, "eps2write")))
+      epsdevice = "epswrite";
+    else
+      epsdevice = "eps2write";
+    endif
+  endif
+  
   dos_shell = (ispc () && ! isunix ());
 
   cleanup = "";
@@ -544,7 +555,7 @@
         if (dos_shell)
           filein(filein=="'") = "\"";
           gs_cmd = __ghostscript__ ("binary", opts.ghostscript.binary,
-                                    "device", "epswrite",
+                                    "device", epsdevice,
                                     "source", "-",
                                     "output", filein);
           cmd = sprintf ("%s %s & %s", gs_cmd, filein, cmd);
@@ -576,7 +587,7 @@
     if (pipein && pipeout)
       if (dos_shell)
         cmd = __ghostscript__ ("binary", opts.ghostscript.binary,
-                               "device", "epswrite",
+                               "device", epsdevice,
                                "source", "-",
                                "output", "-");
       else
@@ -587,7 +598,7 @@
         ## ghostscript expects double, not single, quotes
         fileout(fileout=="'") = "\"";
         cmd = __ghostscript__ ("binary", opts.ghostscript.binary,
-                               "device", "epswrite",
+                               "device", epsdevice,
                                "source", "-",
                                "output", fileout);
       else