Mercurial > hg > octave-nkf
changeset 4688:eaa2caaa35d6
[project @ 2004-01-07 21:54:56 by jwe]
author | jwe |
---|---|
date | Wed, 07 Jan 2004 21:54:56 +0000 |
parents | e95c86d48732 |
children | a2d3862ed07a |
files | scripts/miscellaneous/path.m |
diffstat | 1 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/path.m +++ b/scripts/miscellaneous/path.m @@ -36,17 +36,9 @@ ## Author: jwe -function p = path (varargin) +function retval = path (varargin) - if (nargin == 0) - if (nargout == 0) - puts ("\nLOADPATH contains the following directories:\n\n "); - puts (strrep (DEFAULT_LOADPATH, ":", "\n ")); - puts ("\n\n"); - else - p = LOADPATH; - endif - else + if (nargin > 0) p = varargin{1}; for i = 2:nargin p = sprintf ("%s:%s", p, varargin{i}); @@ -54,4 +46,26 @@ LOADPATH = p; endif + if (LOADPATH(1) == ":") + p = strcat (DEFAULT_LOADPATH, LOADPATH); + else + t = findstr (LOADPATH, "::"); + if (any (t)) + loc = t(1); + p = strcat (LOADPATH(1:loc), DEFAULT_LOADPATH, LOADPATH(loc+1:end)); + elseif (LOADPATH(end) == ":") + p = strcat (LOADPATH, DEFAULT_LOADPATH); + else + p = LOADPATH; + endif + endif + + if (nargin == 0 && nargout == 0) + puts ("\nOctave's search path contains the following directories:\n\n "); + puts (strrep (p, ":", "\n ")); + puts ("\n\n"); + else + retval = p; + endif + endfunction