difference between path / pathdef
Ben Abbott
bpabbott at mac.com
Mon Jan 14 21:44:00 CST 2008
On Jan 14, 2008, at 7:53 PM, John W. Eaton wrote:
> On 29-Dec-2007, Ben Abbott wrote:
>
> | I'm running 3.0.0 on Mac OS X (intel), built and installed using
> Fink.
> |
> | After installation of 3.0.0, the path for octave is
> |
> | def = path
> | def = .:/sw/share/octave/site/m:/sw/share/octave/site/m/
> startup:/ ...
> |
> | However, when I check the default path I get
> |
> | pathdef
> | ans = ::/sw/share/octave/site/m:/sw/share/octave/site/m/
> startup: ...
> |
> | Shouldn't pathdef begin with a period "." instead of colon ":"?
>
> Hmm, to be like Matlab, I guess it should not have "." (that directory
> is implied), but it should also not start with two colons. Please try
> the following patch. I checked it in to cvs head and the 3.0 branch.
>
> Thanks,
>
> jwe
>
>
> src/ChangeLog:
>
> 2008-01-14 John W. Eaton <jwe at octave.org>
>
> * load-path.cc (load_path::do_initialize): Start with sys_path empty.
> (maybe_add_path_elts): Omit path_sep_str if path is empty.
>
>
> Index: src/load-path.cc
> ===================================================================
> RCS file: /cvs/octave/src/load-path.cc,v
> retrieving revision 1.26
> diff -u -u -r1.26 load-path.cc
> --- src/load-path.cc 28 Dec 2007 20:56:56 -0000 1.26
> +++ src/load-path.cc 15 Jan 2008 00:45:09 -0000
> @@ -408,13 +408,18 @@
> std::string tpath = genpath (dir);
>
> if (! tpath.empty ())
> - path += dir_path::path_sep_str + tpath;
> + {
> + if (path.empty ())
> + path = tpath;
> + else
> + path += dir_path::path_sep_str + tpath;
> + }
> }
>
> void
> load_path::do_initialize (bool set_initial_path)
> {
> - sys_path = dir_path::path_sep_str;
> + sys_path = "";
>
> if (set_initial_path)
> {
> @@ -438,7 +443,7 @@
> if (! tpath.empty ())
> xpath += dir_path::path_sep_str + tpath;
>
> - if (sys_path != dir_path::path_sep_str)
> + if (! sys_path.empty ())
> xpath += sys_path;
>
> do_set (xpath, false);
Iooks ok to me.
octave:1> path
Octave's search path contains the following directories:
.
/sw/share/octave/site/m
/sw/share/octave/site/m/startup
/sw/lib/octave/3.0.0+/oct/i386-apple-darwin9.1.0
/sw/share/octave/3.0.0+/m
/sw/share/octave/3.0.0+/m/audio
/sw/share/octave/3.0.0+/m/control
/sw/share/octave/3.0.0+/m/control/base
/sw/share/octave/3.0.0+/m/control/hinf
/sw/share/octave/3.0.0+/m/control/obsolete
/sw/share/octave/3.0.0+/m/control/system
/sw/share/octave/3.0.0+/m/control/util
/sw/share/octave/3.0.0+/m/deprecated
/sw/share/octave/3.0.0+/m/elfun
/sw/share/octave/3.0.0+/m/finance
/sw/share/octave/3.0.0+/m/general
/sw/share/octave/3.0.0+/m/geometry
/sw/share/octave/3.0.0+/m/image
/sw/share/octave/3.0.0+/m/io
/sw/share/octave/3.0.0+/m/linear-algebra
/sw/share/octave/3.0.0+/m/miscellaneous
/sw/share/octave/3.0.0+/m/optimization
/sw/share/octave/3.0.0+/m/path
/sw/share/octave/3.0.0+/m/pkg
/sw/share/octave/3.0.0+/m/plot
/sw/share/octave/3.0.0+/m/polynomial
/sw/share/octave/3.0.0+/m/quaternion
/sw/share/octave/3.0.0+/m/set
/sw/share/octave/3.0.0+/m/signal
/sw/share/octave/3.0.0+/m/sparse
/sw/share/octave/3.0.0+/m/specfun
/sw/share/octave/3.0.0+/m/special-matrix
/sw/share/octave/3.0.0+/m/startup
/sw/share/octave/3.0.0+/m/statistics
/sw/share/octave/3.0.0+/m/statistics/base
/sw/share/octave/3.0.0+/m/statistics/distributions
/sw/share/octave/3.0.0+/m/statistics/models
/sw/share/octave/3.0.0+/m/statistics/tests
/sw/share/octave/3.0.0+/m/strings
/sw/share/octave/3.0.0+/m/testfun
/sw/share/octave/3.0.0+/m/time
octave:2> pathdef
ans = /sw/share/octave/site/m:/sw/share/octave/site/m/startup:/sw/lib/
octave/3.0.0+/oct/i386-apple-darwin9.1.0:/sw/share/octave/3.0.0+/m:/sw/
share/octave/3.0.0+/m/audio:/sw/share/octave/3.0.0+/m/control:/sw/
share/octave/3.0.0+/m/control/base:/sw/share/octave/3.0.0+/m/control/
hinf:/sw/share/octave/3.0.0+/m/control/obsolete:/sw/share/octave/
3.0.0+/m/control/system:/sw/share/octave/3.0.0+/m/control/util:/sw/
share/octave/3.0.0+/m/deprecated:/sw/share/octave/3.0.0+/m/elfun:/sw/
share/octave/3.0.0+/m/finance:/sw/share/octave/3.0.0+/m/general:/sw/
share/octave/3.0.0+/m/geometry:/sw/share/octave/3.0.0+/m/image:/sw/
share/octave/3.0.0+/m/io:/sw/share/octave/3.0.0+/m/linear-algebra:/sw/
share/octave/3.0.0+/m/miscellaneous:/sw/share/octave/3.0.0+/m/
optimization:/sw/share/octave/3.0.0+/m/path:/sw/share/octave/3.0.0+/m/
pkg:/sw/share/octave/3.0.0+/m/plot:/sw/share/octave/3.0.0+/m/
polynomial:/sw/share/octave/3.0.0+/m/quaternion:/sw/share/octave/
3.0.0+/m/set:/sw/share/octave/3.0.0+/m/signal:/sw/share/octave/3.0.0+/
m/sparse:/sw/share/octave/3.0.0+/m/specfun:/sw/share/octave/3.0.0+/m/
special-matrix:/sw/share/octave/3.0.0+/m/startup:/sw/share/octave/
3.0.0+/m/statistics:/sw/share/octave/3.0.0+/m/statistics/base:/sw/
share/octave/3.0.0+/m/statistics/distributions:/sw/share/octave/3.0.0+/
m/statistics/models:/sw/share/octave/3.0.0+/m/statistics/tests:/sw/
share/octave/3.0.0+/m/strings:/sw/share/octave/3.0.0+/m/testfun:/sw/
share/octave/3.0.0+/m/time
octave:3>
Matlab gives me,
>> p = path
p =
/Applications/MATLAB_R2007b/toolbox/matlab/general:/Applications/
MATLAB_R2007b/toolbox/matlab/ops: [...]
>> p = pathdef
p =
:/Applications/MATLAB_R2007b/toolbox/matlab/general:/Applications/
MATLAB_R2007b/toolbox/matlab/ops: [...]
It appears to me that the patch is correct. While the pathdef is
different. If this is to be fixed, I think it should wait for the
patch where the octave's built-in is renamed and a script by the same
name is introduced.
Ben
Ben
More information about the Bug-octave
mailing list