# HG changeset patch # User Ben Abbott # Date 1259046291 -3600 # Node ID 69828adba9665e5496a3ff747d02feedcce1a026 # Parent a14e1561350950029a878dfb567852eab89bf6d6 print.m: Properly set the default ghostscript_binary under Windows. diff -r a14e15613509 -r 69828adba966 scripts/ChangeLog --- a/scripts/ChangeLog Tue Nov 24 08:02:08 2009 +0100 +++ b/scripts/ChangeLog Tue Nov 24 08:04:51 2009 +0100 @@ -1,3 +1,9 @@ +2009-11-22 Michael Goffioul + + * 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 * plot/gnuplot_drawnow.m: Support gnuplot's dumb terminal. diff -r a14e15613509 -r 69828adba966 scripts/plot/print.m --- a/scripts/plot/print.m Tue Nov 24 08:02:08 2009 +0100 +++ b/scripts/plot/print.m Tue Nov 24 08:04:51 2009 +0100 @@ -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)