Ignore:
Timestamp:
02/12/15 16:48:40 (10 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 19103

Location:
issm/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/externalpackages/export_fig/ghostscript.m

    r14310 r19105  
    2020%   result - Output from ghostscript.
    2121
    22 % Copyright: Oliver Woodford, 2009-2010
     22% Copyright: Oliver Woodford, 2009-2013
    2323
    2424% Thanks to Jonas Dorn for the fix for the title of the uigetdir window on
     
    3232% 12/12/12 - Add extra executable name on Windows. Thanks to Ratish
    3333% Punnoose for highlighting the issue.
     34% 28/6/13 - Fix error using GS 9.07 in Linux. Many thanks to Jannick
     35% Steinbring for proposing the fix.
     36% 24/10/13 - Fix error using GS 9.07 in Linux. Many thanks to Johannes
     37% for the fix.
     38% 23/01/2014 - Add full path to ghostscript.txt in warning. Thanks to Koen
     39% Vermeer for raising the issue.
    3440
    3541function varargout = ghostscript(cmd)
     42% Initialize any required system calls before calling ghostscript
     43shell_cmd = '';
     44if isunix
     45    shell_cmd = 'export LD_LIBRARY_PATH=""; '; % Avoids an error on Linux with GS 9.07
     46end
     47if ismac
     48    shell_cmd = 'export DYLD_LIBRARY_PATH=""; ';  % Avoids an error on Mac with GS 9.07
     49end
    3650% Call ghostscript
    37 [varargout{1:nargout}] = system(sprintf('"%s" %s', gs_path, cmd));
    38 return
     51[varargout{1:nargout}] = system(sprintf('%s"%s" %s', shell_cmd, gs_path, cmd));
     52end
    3953
    4054function path_ = gs_path
     
    8599    end
    86100else
    87     bin = {'/usr/bin/gs', '/usr/local/bin/gs'};
    88     for a = 1:numel(bin)
    89         path_ = bin{a};
     101    executable = {'/usr/bin/gs', '/usr/local/bin/gs'};
     102    for a = 1:numel(executable)
     103        path_ = executable{a};
    90104        if check_store_gs_path(path_)
    91105            return
     
    119133end
    120134error('Ghostscript not found. Have you installed it from www.ghostscript.com?');
     135end
    121136
    122137function good = check_store_gs_path(path_)
     
    128143% Update the current default path to the path found
    129144if ~user_string('ghostscript', path_)
    130     warning('Path to ghostscript installation could not be saved. Enter it manually in ghostscript.txt.');
     145    warning('Path to ghostscript installation could not be saved. Enter it manually in %s.', fullfile(fileparts(which('user_string.m')), '.ignore', 'ghostscript.txt'));
    131146    return
    132147end
    133 return
     148end
    134149
    135150function good = check_gs_path(path_)
    136151% Check the path is valid
    137 [good, message] = system(sprintf('"%s" -h', path_));
     152shell_cmd = '';
     153if ismac
     154    shell_cmd = 'export DYLD_LIBRARY_PATH=""; ';  % Avoids an error on Mac with GS 9.07
     155end
     156[good, message] = system(sprintf('%s"%s" -h', shell_cmd, path_));
    138157good = good == 0;
    139 return
     158end
Note: See TracChangeset for help on using the changeset viewer.