Mercurial > hg > octave-lojdl
changeset 9249:470af0f93ca9
ghostscript handling for windows in print.m
author | Benjamin Lindner <lindnerb@users.sourceforge.net> |
---|---|
date | Sun, 24 May 2009 10:09:19 +0200 |
parents | 98034ebda172 |
children | 80c299c84796 |
files | scripts/ChangeLog scripts/plot/gnuplot_drawnow.m scripts/plot/print.m |
diffstat | 3 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2009-05-24 Benjamin Lindner <lindnerb@users.sourceforge.net> + + * plot/gnuplot_drawnow.m: single-quote output name to allow backslash + characters as filesep under windows + * plot/print.m: Support ps->pdf using ghostscript under windows, check + for %GSC% environment variable. + 2009-05-24 Benjamin Lindner <lindnerb@users.sourceforge.net> * plot/__gnuplot_version__.m: quote gnuplot_binary to allow spaces
--- a/scripts/plot/gnuplot_drawnow.m +++ b/scripts/plot/gnuplot_drawnow.m @@ -278,7 +278,7 @@ if (nargin == 5) if (! isempty (file)) - fprintf (plot_stream, "set output \"%s\";\n", file); + fprintf (plot_stream, "set output '%s';\n", file); endif endif
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -186,7 +186,11 @@ if (isunix ()) persistent ghostscript_binary = "gs"; elseif (ispc ()) - persistent ghostscript_binary = "gswin32c"; + if (~isempty (getenv ("GSC"))) + persistent ghostscript_binary = getenv ("GSC"); + else + persistent ghostscript_binary = "gswin32c"; + endif endif old_fig = get (0, "currentfigure"); @@ -253,7 +257,8 @@ [status, output] = system (sprintf ("which %s 2>&1", ghostscript_binary)); have_ghostscript = (status == 0); elseif (ispc ()) - have_ghostscript = true; + [status, output] = system (sprintf ("if exist \"%s\" ( exit /B 1 ) else ( exit /B 0 )", ghostscript_binary)); + have_ghostscript = (status ~= 0); endif doprint = isempty (name); @@ -571,12 +576,12 @@ endif ghostscript_options = sprintf ("%s -sDEVICE=%s", ghostscript_options, ghostscript_device); - command = sprintf ("%s %s -sOutputFile='%s' '%s' 2>&1", ghostscript_binary, + command = sprintf ("\"%s\" %s -sOutputFile=\"%s\" \"%s\" 2>&1", ghostscript_binary, ghostscript_options, ghostscript_output, name); [errcode, output] = system (command); unlink (name); if (errcode) - error ("print: Conversion failed, %s -> %s.", name, ghostscript_output); + error ("print: Conversion failed, %s -> %s.\nError was:\n%s\n", name, ghostscript_output, output); endif elseif (is_eps_file && tight_flag && ! doprint) ## If the saved output file is an eps file, use ghostscript to set a tight bbox. @@ -625,7 +630,7 @@ box_string = "%%BoundingBox:"; ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox"; - cmd = sprintf ("%s %s '%s' 2>&1", ghostscript_binary, ghostscript_options, eps_file_name); + cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", ghostscript_binary, ghostscript_options, eps_file_name); [status, output] = system (cmd); if (status == 0) @@ -672,7 +677,7 @@ end_unwind_protect elseif (warn_on_no_ghostscript) warn_on_no_ghostscript = false; - warning ("print.m: Ghostscript could not be used to adjust bounding box.") + warning ("print.m: Ghostscript could not be used to adjust bounding box.\nError was:\n%s\n", output) endif endfunction