changeset 14174:447b57ebc27b stable

Validate suffix when printing to {eps,ps,pdf}latex devices. * __fltk_print__.m: gl2ps is not agnostic to file suffix. * __gnuplot_print__.m: gnuplot is not agnostic to file suffix.
author Ben Abbott <bpabbott@mac.com>
date Sun, 08 Jan 2012 19:23:55 -0500
parents 47a5e29ecc0b
children 3972c4caa60a
files scripts/plot/private/__fltk_print__.m scripts/plot/private/__gnuplot_print__.m
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/private/__fltk_print__.m	Sun Jan 08 18:59:03 2012 -0800
+++ b/scripts/plot/private/__fltk_print__.m	Sun Jan 08 19:23:55 2012 -0500
@@ -52,15 +52,17 @@
     dot = find (opts.name == ".", 1, "last");
     if ((! isempty (dot))
         && any (strcmpi (opts.name(dot:end), ...
-                {".eps", ".ps", ".pdf", ".tex", "."})))
+                {strcat(".", suffix), ".tex", "."})))
       name = opts.name(1:dot-1);
       if (dot < numel (opts.name)
           && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"})))
         ## If user provides eps/ps/pdf suffix, use it.
         suffix = opts.name(dot+1:end);
       endif
-    elseif (dot == numel (opts.name))
-      name = opts.name;
+    else
+      error ("print:invalid-suffix", 
+             "invalid suffix `%s' for device `%s'.",
+             opts.name(dot:end), lower (opts.devopt));
     endif
     gl2ps_device = {sprintf("%snotxt", lower (suffix))};
     gl2ps_device{2} = "tex";
--- a/scripts/plot/private/__gnuplot_print__.m	Sun Jan 08 18:59:03 2012 -0800
+++ b/scripts/plot/private/__gnuplot_print__.m	Sun Jan 08 19:23:55 2012 -0500
@@ -69,11 +69,14 @@
     endif
   case {"epslatex", "pslatex", "pstex", "epslatexstandalone"}
     dot = find (opts.name == ".", 1, "last");
+    n = find (opts.devopt == "l", 1);
+    suffix = opts.devopt(1:n-1);
     if (! isempty (dot))
-      if (any (strcmpi (opts.name(dot:end), {".eps", ".ps", ".pdf", ".tex", "."})))
+      if (any (strcmpi (opts.name(dot:end), {strcat(".", suffix), ".tex", "."})))
         name = opts.name(1:dot-1);
       else
-        error ("print:invalid-suffix", "unrecognized file name suffix `%s' for %s output type",
+        error ("print:invalid-suffix", 
+               "invalid suffix `%s' for device `%s'.",
                opts.name(dot:end), lower (opts.devopt));
       endif
     endif