Mercurial > hg > octave-lojdl
changeset 12104:69828adba966 release-3-2-x
print.m: Properly set the default ghostscript_binary under Windows.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 24 Nov 2009 08:04:51 +0100 |
parents | a14e15613509 |
children | 2641c6febd46 |
files | scripts/ChangeLog scripts/plot/print.m |
diffstat | 2 files changed, 27 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,9 @@ +2009-11-22 Michael Goffioul <michael.goffioul@gmail.com> + + * plot/print.m: Properly set the default ghostscript_binary + under Windows. Modify the search for the ghostscript binary + so that it works for Win32, mingw, Cygwin, and Unix systems. + 2009-11-08 Petr Mikulik <mikulik@physics.muni.cz> * plot/gnuplot_drawnow.m: Support gnuplot's dumb terminal.
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -187,14 +187,22 @@ special_flag = "textnormal"; tight_flag = false; resolution = ""; - if (isunix ()) - persistent ghostscript_binary = "gs"; - elseif (ispc ()) - if (~isempty (getenv ("GSC"))) - persistent ghostscript_binary = getenv ("GSC"); + + persistent ghostscript_binary = ""; + if (isempty (ghostscript_binary)) + ghostscript_binary = getenv ("GSC"); + ng = 0; + if (isunix ()) + ## Unix - Includes Mac OSX and Cygwin. + gs_binaries = {"gs", "gs.exe"}; else - persistent ghostscript_binary = "gswin32c"; + ## pc - Includes Win32 and mingw. + gs_binaries = {"gs.exe", "gswin32c.exe"}; endif + while (ng < numel (gs_binaries) && isempty (ghostscript_binary)) + ng = ng + 1; + ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{ng}); + endwhile endif old_fig = get (0, "currentfigure"); @@ -233,6 +241,12 @@ printer = arg; elseif ((length (arg) > 2) && arg(1:2) == "-G") ghostscript_binary = arg(3:end); + if (exist (ghostscript_binary, "file") != 2) + ghostscript_binary = file_in_path (EXEC_PATH, ghostscript_binary); + endif + if (isempty (ghostscript_binary)) + error ("print.m: Ghostscript binary ""%s"" could not be located", arg(3:end)) + endif elseif (length (arg) > 2 && arg(1:2) == "-F") idx = rindex (arg, ":"); if (idx) @@ -257,13 +271,7 @@ endif endfor - if (isunix ()) - [status, output] = system (sprintf ("which %s 2>&1", ghostscript_binary)); - have_ghostscript = (status == 0); - elseif (ispc ()) - [status, output] = system (sprintf ("if exist \"%s\" ( exit /B 1 ) else ( exit /B 0 )", ghostscript_binary)); - have_ghostscript = (status ~= 0); - endif + have_ghostscript = (exist (ghostscript_binary, "file") == 2); doprint = isempty (name); if (doprint)