# HG changeset patch # User Ben Abbott # Date 1326068635 18000 # Node ID 447b57ebc27b6b6be2bcaf1f17871a13f438d1e2 # Parent 47a5e29ecc0b0250562629874a2f4ff006fe8637 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. diff -r 47a5e29ecc0b -r 447b57ebc27b scripts/plot/private/__fltk_print__.m --- 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"; diff -r 47a5e29ecc0b -r 447b57ebc27b scripts/plot/private/__gnuplot_print__.m --- 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