# HG changeset patch # User Benjamin Lindner # Date 1243152559 -7200 # Node ID 470af0f93ca9d7947027c42dddac8d1edc220625 # Parent 98034ebda17272ccbad6a86c36e291d64e97f204 ghostscript handling for windows in print.m diff -r 98034ebda172 -r 470af0f93ca9 scripts/ChangeLog --- a/scripts/ChangeLog Sun May 24 10:05:30 2009 +0200 +++ b/scripts/ChangeLog Sun May 24 10:09:19 2009 +0200 @@ -1,3 +1,10 @@ +2009-05-24 Benjamin Lindner + + * 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 * plot/__gnuplot_version__.m: quote gnuplot_binary to allow spaces diff -r 98034ebda172 -r 470af0f93ca9 scripts/plot/gnuplot_drawnow.m --- a/scripts/plot/gnuplot_drawnow.m Sun May 24 10:05:30 2009 +0200 +++ b/scripts/plot/gnuplot_drawnow.m Sun May 24 10:09:19 2009 +0200 @@ -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 diff -r 98034ebda172 -r 470af0f93ca9 scripts/plot/print.m --- a/scripts/plot/print.m Sun May 24 10:05:30 2009 +0200 +++ b/scripts/plot/print.m Sun May 24 10:09:19 2009 +0200 @@ -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