Mercurial > hg > octave-nkf
annotate scripts/path/pathdef.m @ 19830:884e0c55d92c
Fix complex compare operation for issorted (bug #44071).
* Array-C.cc (nan_ascending_compare, nan_descending_compare): Fix typo where
comparison was made between x and x rather than between x and y.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 26 Jan 2015 15:32:49 -0800 |
parents | bb8d3f17248d |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17338
diff
changeset
|
1 ## Copyright (C) 2005-2013 Bill Denney |
11523 | 2 ## Copyright (C) 2007-2009 Ben Abbott |
7388 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
8 ## the Free Software Foundation; either version 3 of the License, or (at | |
9 ## your option) any later version. | |
10 ## | |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
17 ## along with Octave; see the file COPYING. If not, see | |
18 ## <http://www.gnu.org/licenses/>. | |
19 | |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {@var{val} =} pathdef () | |
22 ## Return the default path for Octave. | |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
23 ## |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
24 ## The path information is extracted from one of four sources. |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
25 ## The possible sources, in order of preference, are: |
7388 | 26 ## |
27 ## @enumerate | |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
28 ## @item @file{.octaverc} |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
29 ## |
7388 | 30 ## @item @file{~/.octaverc} |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
31 ## |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 ## @item @file{<OCTAVE_HOME>/@dots{}/<version>/m/startup/octaverc} |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
33 ## |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
34 ## @item Octave's path prior to changes by any octaverc file. |
7388 | 35 ## @end enumerate |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
36 ## @seealso{path, addpath, rmpath, genpath, savepath} |
7388 | 37 ## @end deftypefn |
38 | |
39 function val = pathdef () | |
40 | |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 if (nargin > 0) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 print_usage (); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 endif |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
45 ## Locate any project-specific .octaverc file. |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
46 proj_octaverc = fullfile (pwd, ".octaverc"); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
47 if (exist (proj_octaverc, "file")) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
48 proj_path = __extractpath__ (proj_octaverc); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 if (! isempty (proj_path)) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 val = proj_path; |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
51 return; |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 endif |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 endif |
7388 | 54 |
14216
b3730ed107a6
Clean up scripts in path/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 ## Locate the user's ~/.octaverc file. |
7392 | 56 user_octaverc = fullfile ("~", ".octaverc"); |
57 if (exist (user_octaverc, "file")) | |
7393 | 58 user_path = __extractpath__ (user_octaverc); |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
59 if (! isempty (user_path)) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
60 val = user_path; |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 return; |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 endif |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
63 endif |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 ## No user octaverc file, locate the site octaverc file. |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 pathdir = octave_config_info ("localstartupfiledir"); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
67 site_octaverc = fullfile (pathdir, "octaverc"); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
68 site_path = __extractpath__ (site_octaverc); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
69 if (! isempty (site_path)) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 val = site_path; |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
71 return; |
7388 | 72 endif |
73 | |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
74 ## No project, user, or site octaverc file. Use Octave's default. |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 val = __pathorig__ (); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
77 endfunction |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
79 ## Extact the path information from the script/function @var{file}, created by |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
80 ## @file{savepath.m}. If successful, @code{__extractpath__} returns the path |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 ## specified in @var{file}. |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
82 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 ## Author: Ben Abbott <bpabbott@mac.com> |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 function path = __extractpath__ (savefile) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 [filelines, startline, endline] = getsavepath (savefile); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
88 if (startline > 0) |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 tmp = regexprep (filelines(startline+1:endline-1), |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
90 "^.*path \\('([^\']+)'.*$", "$1"); |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
91 path = strjoin (tmp, ":"); |
7393 | 92 else |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
93 path = ""; |
7388 | 94 endif |
95 | |
96 endfunction | |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
97 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
98 |
19530
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 ## FIXME: Need some better BIST tests |
bb8d3f17248d
Overhaul savepath.m, pathdef.m, matlabroot.m.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 %!assert (ischar (pathdef ())) |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
101 |