# HG changeset patch # User jwe # Date 1073512496 0 # Node ID eaa2caaa35d63caf91fceb82bdfc701cc7589be6 # Parent e95c86d48732b7fd967060baed5eead595495a15 [project @ 2004-01-07 21:54:56 by jwe] diff -r e95c86d48732 -r eaa2caaa35d6 scripts/miscellaneous/path.m --- a/scripts/miscellaneous/path.m Tue Jan 06 21:53:34 2004 +0000 +++ b/scripts/miscellaneous/path.m Wed Jan 07 21:54:56 2004 +0000 @@ -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