Mercurial > octave
annotate libinterp/corefcn/load-path.cc @ 20817:3d551b2ae928
Use variable name nargin consistently in C++ code.
* debug.cc (do_dbstack): Rename variable len to nargin. Change type to int
from octave_idx_type.
* dirfns.cc (Fcd): Rename variable argc to nargin and update code. Add nargin
checking and print_usage. Replace make_argv call with xstring_value() call.
Use !empty() rather than length > 0 for clarity.
* error.cc (Flasterr, Flastwarn): Rename variable argc to nargin and update code.
* filter.cc (Ffilter): Remove extra space in nargin declaration.
* input.cc (Fecho): Rename variable argc to nargin and update code.
* load-path.cc (Fpath): Rename variable argc to nargin and update code.
Eliminate unnecessary declaration of "octave_value retval;". Add more
calling forms to docstring.
* pager.cc (Fdiary): Rename variable argc to nargin and update code. Replace
make_argv call with xstring_value() call. Eliminate unnecessary declaration of
"octave_value retval;".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 07 Dec 2015 09:32:33 -0800 |
parents | b16bcd7a2a33 |
children | eed8ec05f1c8 |
rev | line source |
---|---|
5832 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19597
diff
changeset
|
3 Copyright (C) 2006-2015 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10446
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
5832 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5832 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5832 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include <algorithm> | |
29 | |
30 #include "dir-ops.h" | |
31 #include "file-ops.h" | |
32 #include "file-stat.h" | |
33 #include "oct-env.h" | |
34 #include "pathsearch.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
35 #include "singleton-cleanup.h" |
5832 | 36 |
37 #include "defaults.h" | |
38 #include "defun.h" | |
39 #include "input.h" | |
40 #include "load-path.h" | |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
41 #include "ov-usr-fcn.h" |
5832 | 42 #include "pager.h" |
43 #include "parse.h" | |
44 #include "toplev.h" | |
45 #include "unwind-prot.h" | |
46 #include "utils.h" | |
47 | |
48 load_path *load_path::instance = 0; | |
7336 | 49 load_path::hook_fcn_ptr load_path::add_hook = execute_pkg_add; |
50 load_path::hook_fcn_ptr load_path::remove_hook = execute_pkg_del; | |
5832 | 51 std::string load_path::command_line_path; |
6630 | 52 std::string load_path::sys_path; |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
53 load_path::abs_dir_cache_type load_path::abs_dir_cache; |
5832 | 54 |
55 void | |
56 load_path::dir_info::update (void) | |
57 { | |
8330
8303f0e912bc
load-path.cc (load_path::dir_info::update): simplify previous change
John W. Eaton <jwe@octave.org>
parents:
8329
diff
changeset
|
58 file_stat fs (dir_name); |
8303f0e912bc
load-path.cc (load_path::dir_info::update): simplify previous change
John W. Eaton <jwe@octave.org>
parents:
8329
diff
changeset
|
59 |
8303f0e912bc
load-path.cc (load_path::dir_info::update): simplify previous change
John W. Eaton <jwe@octave.org>
parents:
8329
diff
changeset
|
60 if (fs) |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
61 { |
8330
8303f0e912bc
load-path.cc (load_path::dir_info::update): simplify previous change
John W. Eaton <jwe@octave.org>
parents:
8329
diff
changeset
|
62 if (is_relative) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
63 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
64 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
65 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
66 std::string abs_name = octave_env::make_absolute (dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
67 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
68 abs_dir_cache_iterator p = abs_dir_cache.find (abs_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
69 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
70 if (p != abs_dir_cache.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
71 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
72 // The directory is in the cache of all directories |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
73 // we have visited (indexed by its absolute name). |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
74 // If it is out of date, initialize it. Otherwise, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
75 // copy the info from the cache. By doing that, we |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
76 // avoid unnecessary calls to stat that can slow |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
77 // things down tremendously for large directories. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
78 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
79 const dir_info& di = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
80 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 if (fs.mtime () + fs.time_resolution () |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
82 > di.dir_time_last_checked) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
83 initialize (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
84 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
85 *this = di; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
86 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
87 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
88 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
89 // We haven't seen this directory before. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
90 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
91 initialize (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
92 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
93 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
94 catch (const octave_execution_exception&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
95 { |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
96 // Skip updating if we don't know where we are but |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
97 // don't treat it as an error. |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
98 |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
99 recover_from_exception (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
100 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
101 } |
9764
7922a24f78c0
fix relative directory caching
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
102 else if (fs.mtime () + fs.time_resolution () > dir_time_last_checked) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
103 initialize (); |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
104 } |
5832 | 105 else |
106 { | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
107 std::string msg = fs.error (); |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
108 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
5832 | 109 } |
110 } | |
111 | |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
112 bool |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
113 load_path::dir_info::is_package (const std::string& name) const |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
114 { |
20100
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
115 size_t pos = name.find ('.'); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
116 |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
117 if (pos == std::string::npos) |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
118 return package_dir_map.find (name) != package_dir_map.end (); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
119 else |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
120 { |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
121 std::string name_head = name.substr (0, pos); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
122 std::string name_tail = name.substr (pos + 1); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
123 |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
124 const_package_dir_map_iterator it = package_dir_map.find (name_head); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
125 |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
126 if (it != package_dir_map.end ()) |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
127 return it->second.is_package (name_tail); |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
128 else |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
129 return false; |
a8769ccb2c4e
Fix nested classdef package lookup (bug #44856)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
20052
diff
changeset
|
130 } |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
131 } |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
132 |
5832 | 133 void |
134 load_path::dir_info::initialize (void) | |
135 { | |
136 is_relative = ! octave_env::absolute_pathname (dir_name); | |
137 | |
9748
d6b2b708b6b0
load-path: compare directory timestamps with tolerance
John W. Eaton <jwe@octave.org>
parents:
9581
diff
changeset
|
138 dir_time_last_checked = octave_time (static_cast<time_t> (0)); |
d6b2b708b6b0
load-path: compare directory timestamps with tolerance
John W. Eaton <jwe@octave.org>
parents:
9581
diff
changeset
|
139 |
5832 | 140 file_stat fs (dir_name); |
141 | |
142 if (fs) | |
143 { | |
10907
6105ed2db9d7
load_path::dir_info::initialize: clear method_file_map before updating file list
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
144 method_file_map.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
145 package_dir_map.clear (); |
10907
6105ed2db9d7
load_path::dir_info::initialize: clear method_file_map before updating file list
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
146 |
5832 | 147 dir_mtime = fs.mtime (); |
9748
d6b2b708b6b0
load-path: compare directory timestamps with tolerance
John W. Eaton <jwe@octave.org>
parents:
9581
diff
changeset
|
148 dir_time_last_checked = octave_time (); |
5832 | 149 |
7336 | 150 get_file_list (dir_name); |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8325
diff
changeset
|
151 |
8704
236ff50db90f
load-path.cc: catch execution exception in getcwd
John W. Eaton <jwe@octave.org>
parents:
8609
diff
changeset
|
152 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
153 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
154 std::string abs_name = octave_env::make_absolute (dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
155 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 // FIXME: nothing is ever removed from this cache of |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
157 // directory information, so there could be some resource |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
158 // problems. Perhaps it should be pruned from time to time. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
159 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
160 abs_dir_cache[abs_name] = *this; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
161 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
162 catch (const octave_execution_exception&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
163 { |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
164 // Skip updating if we don't know where we are but don't treat |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
165 // it as an error. |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
166 |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
167 recover_from_exception (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
168 } |
5832 | 169 } |
170 else | |
171 { | |
172 std::string msg = fs.error (); | |
173 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); | |
174 } | |
175 } | |
176 | |
7336 | 177 void |
5832 | 178 load_path::dir_info::get_file_list (const std::string& d) |
179 { | |
180 dir_entry dir (d); | |
181 | |
182 if (dir) | |
183 { | |
184 string_vector flist = dir.read (); | |
185 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
186 octave_idx_type len = flist.numel (); |
5832 | 187 |
188 all_files.resize (len); | |
189 fcn_files.resize (len); | |
190 | |
191 octave_idx_type all_files_count = 0; | |
192 octave_idx_type fcn_files_count = 0; | |
193 | |
194 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
196 std::string fname = flist[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
197 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
198 std::string full_name = file_ops::concat (d, fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
199 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
200 file_stat fs (full_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
201 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
202 if (fs) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
203 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
204 if (fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
205 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
206 if (fname == "private") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
207 get_private_file_map (full_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
208 else if (fname[0] == '@') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
209 get_method_file_map (full_name, fname.substr (1)); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
210 else if (fname[0] == '+') |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
211 get_package_dir (full_name, fname.substr (1)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
212 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
213 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
214 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
215 all_files[all_files_count++] = fname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
216 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
217 size_t pos = fname.rfind ('.'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
218 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
219 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
220 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
221 std::string ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
222 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
223 if (ext == ".m" || ext == ".oct" || ext == ".mex") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
224 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
225 std::string base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
226 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
227 if (valid_identifier (base)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
228 fcn_files[fcn_files_count++] = fname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
229 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
230 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
231 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
232 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
233 } |
5832 | 234 |
235 all_files.resize (all_files_count); | |
236 fcn_files.resize (fcn_files_count); | |
237 } | |
238 else | |
239 { | |
240 std::string msg = dir.error (); | |
241 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); | |
242 } | |
243 } | |
244 | |
7336 | 245 load_path::dir_info::fcn_file_map_type |
246 get_fcn_files (const std::string& d) | |
5832 | 247 { |
7336 | 248 load_path::dir_info::fcn_file_map_type retval; |
249 | |
5832 | 250 dir_entry dir (d); |
251 | |
252 if (dir) | |
253 { | |
254 string_vector flist = dir.read (); | |
255 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
256 octave_idx_type len = flist.numel (); |
5832 | 257 |
258 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
259 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
260 std::string fname = flist[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
261 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
262 std::string ext; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
263 std::string base = fname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
264 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
265 size_t pos = fname.rfind ('.'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
266 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
267 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
268 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
269 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
270 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
271 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
272 if (valid_identifier (base)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
273 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
274 int t = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
275 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
276 if (ext == ".m") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
277 t = load_path::M_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
278 else if (ext == ".oct") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
279 t = load_path::OCT_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
280 else if (ext == ".mex") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
281 t = load_path::MEX_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
282 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
283 retval[base] |= t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
284 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
285 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
286 } |
5832 | 287 } |
288 else | |
289 { | |
290 std::string msg = dir.error (); | |
291 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); | |
292 } | |
7336 | 293 |
294 return retval; | |
295 } | |
296 | |
297 void | |
298 load_path::dir_info::get_private_file_map (const std::string& d) | |
299 { | |
300 private_file_map = get_fcn_files (d); | |
301 } | |
302 | |
303 void | |
304 load_path::dir_info::get_method_file_map (const std::string& d, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
305 const std::string& class_name) |
7336 | 306 { |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
307 method_file_map[class_name].method_file_map = get_fcn_files (d); |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
308 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
309 std::string pd = file_ops::concat (d, "private"); |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
310 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
311 file_stat fs (pd); |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
312 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
313 if (fs && fs.is_dir ()) |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
314 method_file_map[class_name].private_file_map = get_fcn_files (pd); |
5832 | 315 } |
316 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
317 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
318 load_path::dir_info::get_package_dir (const std::string& d, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
319 const std::string& package_name) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
320 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
321 package_dir_map[package_name] = dir_info (d); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
322 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
323 |
5832 | 324 bool |
325 load_path::instance_ok (void) | |
326 { | |
327 bool retval = true; | |
328 | |
329 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
330 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
331 instance = new load_path (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
332 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
333 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
334 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
335 } |
5832 | 336 |
337 if (! instance) | |
338 { | |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
339 error ("unable to create load path object!"); |
5832 | 340 |
341 retval = false; | |
342 } | |
343 | |
344 return retval; | |
345 } | |
346 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
347 // FIXME: maybe we should also maintain a map to speed up this method of access. |
7336 | 348 |
5832 | 349 load_path::const_dir_info_list_iterator |
5919 | 350 load_path::find_dir_info (const std::string& dir_arg) const |
5832 | 351 { |
5919 | 352 std::string dir = file_ops::tilde_expand (dir_arg); |
353 | |
5832 | 354 const_dir_info_list_iterator retval = dir_info_list.begin (); |
355 | |
356 while (retval != dir_info_list.end ()) | |
357 { | |
358 if (retval->dir_name == dir) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
359 break; |
5832 | 360 |
361 retval++; | |
362 } | |
363 | |
364 return retval; | |
365 } | |
366 | |
367 load_path::dir_info_list_iterator | |
5919 | 368 load_path::find_dir_info (const std::string& dir_arg) |
5832 | 369 { |
5919 | 370 std::string dir = file_ops::tilde_expand (dir_arg); |
371 | |
5832 | 372 dir_info_list_iterator retval = dir_info_list.begin (); |
373 | |
374 while (retval != dir_info_list.end ()) | |
375 { | |
376 if (retval->dir_name == dir) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
377 break; |
5832 | 378 |
379 retval++; | |
380 } | |
381 | |
382 return retval; | |
383 } | |
384 | |
385 bool | |
386 load_path::contains (const std::string& dir) const | |
387 { | |
388 return find_dir_info (dir) != dir_info_list.end (); | |
389 } | |
390 | |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
391 bool |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
392 load_path::do_contains_canonical (const std::string& dir) const |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
393 { |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
394 bool retval = false; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
395 |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
396 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
397 i != dir_info_list.end (); |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
398 i++) |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
399 { |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
400 if (same_file (dir, i->dir_name)) |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
401 { |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
402 retval = true; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
403 break; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
404 } |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
405 } |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
406 |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
407 return retval; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
408 } |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
409 |
5832 | 410 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
411 load_path::loader::move_fcn_map (const std::string& dir_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
412 const string_vector& fcn_files, bool at_end) |
5832 | 413 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
414 octave_idx_type len = fcn_files.numel (); |
7336 | 415 |
416 for (octave_idx_type k = 0; k < len; k++) | |
5832 | 417 { |
7336 | 418 std::string fname = fcn_files[k]; |
5832 | 419 |
7336 | 420 std::string ext; |
421 std::string base = fname; | |
422 | |
423 size_t pos = fname.rfind ('.'); | |
5832 | 424 |
8021 | 425 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
426 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
427 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
428 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
429 } |
5832 | 430 |
7336 | 431 file_info_list_type& file_info_list = fcn_map[base]; |
5832 | 432 |
7336 | 433 if (file_info_list.size () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 continue; |
7336 | 435 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
436 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
437 for (file_info_list_iterator p = file_info_list.begin (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
438 p != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
439 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
440 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
441 if (p->dir_name == dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
442 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
443 file_info fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
444 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
445 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
446 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
447 if (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
448 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
449 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
450 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
451 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
452 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
453 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
454 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
455 } |
7336 | 456 } |
457 } | |
5832 | 458 |
7336 | 459 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
460 load_path::loader::move_method_map (const std::string& dir_name, bool at_end) |
7336 | 461 { |
462 for (method_map_iterator i = method_map.begin (); | |
463 i != method_map.end (); | |
464 i++) | |
465 { | |
466 std::string class_name = i->first; | |
5832 | 467 |
7336 | 468 fcn_map_type& fm = i->second; |
469 | |
470 std::string full_dir_name | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
471 = file_ops::concat (dir_name, "@" + class_name); |
7336 | 472 |
473 for (fcn_map_iterator q = fm.begin (); q != fm.end (); q++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
474 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
475 file_info_list_type& file_info_list = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
476 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
477 if (file_info_list.size () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
478 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
479 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
480 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
481 for (file_info_list_iterator p = file_info_list.begin (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
482 p != file_info_list.end (); p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
483 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
484 if (p->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
485 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
486 file_info fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
487 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
488 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
489 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
490 if (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
491 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
492 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
493 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
494 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
495 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
496 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
497 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
498 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
499 } |
5832 | 500 } |
501 } | |
502 | |
7336 | 503 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
504 load_path::do_move (dir_info_list_iterator i, bool at_end) |
7336 | 505 { |
506 if (dir_info_list.size () > 1) | |
507 { | |
508 dir_info di = *i; | |
509 | |
510 dir_info_list.erase (i); | |
511 | |
512 if (at_end) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
513 dir_info_list.push_back (di); |
7336 | 514 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
515 dir_info_list.push_front (di); |
7336 | 516 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
517 move (di, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
518 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
519 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
520 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
521 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
522 load_path::move (const dir_info& di, bool at_end, const std::string& pname) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
523 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
524 loader& l = get_loader (pname); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
525 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
526 l.move (di, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
527 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
528 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
529 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
530 for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
531 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
532 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
533 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
534 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
535 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
536 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
537 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
538 move (p->second, at_end, full_name); |
7336 | 539 } |
540 } | |
541 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
542 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
543 load_path::loader::move (const dir_info& di, bool at_end) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
544 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
545 std::string dir_name = di.dir_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
546 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19545
diff
changeset
|
547 std::list<std::string>::iterator s = |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
548 std::find (dir_list.begin (), dir_list.end (), dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
549 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
550 if (s != dir_list.end ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
551 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
552 dir_list.erase (s); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
553 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
554 if (at_end) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
555 dir_list.push_back (dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
556 else |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
557 dir_list.push_front (dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
558 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
559 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
560 move_fcn_map (dir_name, di.fcn_files, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
561 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
562 // No need to move elements of private function map. |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
563 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
564 move_method_map (dir_name, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
565 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
566 |
5832 | 567 static void |
568 maybe_add_path_elts (std::string& path, const std::string& dir) | |
569 { | |
570 std::string tpath = genpath (dir); | |
571 | |
572 if (! tpath.empty ()) | |
7374 | 573 { |
574 if (path.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
575 path = tpath; |
7374 | 576 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
577 path += dir_path::path_sep_str () + tpath; |
7374 | 578 } |
5832 | 579 } |
580 | |
581 void | |
6365 | 582 load_path::do_initialize (bool set_initial_path) |
5832 | 583 { |
7374 | 584 sys_path = ""; |
5832 | 585 |
6365 | 586 if (set_initial_path) |
587 { | |
6626 | 588 maybe_add_path_elts (sys_path, Vlocal_ver_oct_file_dir); |
589 maybe_add_path_elts (sys_path, Vlocal_api_oct_file_dir); | |
590 maybe_add_path_elts (sys_path, Vlocal_oct_file_dir); | |
591 maybe_add_path_elts (sys_path, Vlocal_ver_fcn_file_dir); | |
592 maybe_add_path_elts (sys_path, Vlocal_api_fcn_file_dir); | |
593 maybe_add_path_elts (sys_path, Vlocal_fcn_file_dir); | |
594 maybe_add_path_elts (sys_path, Voct_file_dir); | |
595 maybe_add_path_elts (sys_path, Vfcn_file_dir); | |
19032
d902542221c8
new data directory for storing data files we distribute
John W. Eaton <jwe@octave.org>
parents:
18926
diff
changeset
|
596 maybe_add_path_elts (sys_path, Voct_data_dir); |
6365 | 597 } |
5832 | 598 |
599 std::string tpath = load_path::command_line_path; | |
600 | |
601 if (tpath.empty ()) | |
8141
31d7885d9869
load-path.cc (load_path::do_initialize): look for OCTAVE_PATH in the environment, not OCTAVE_LOADPATH
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
602 tpath = octave_env::getenv ("OCTAVE_PATH"); |
5832 | 603 |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
604 std::string xpath; |
5832 | 605 |
606 if (! tpath.empty ()) | |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
607 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
608 xpath = tpath; |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
609 |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
610 if (! sys_path.empty ()) |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
611 xpath += dir_path::path_sep_str () + sys_path; |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
612 } |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
613 else |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
614 xpath = sys_path; |
5832 | 615 |
14376
7dd6ac033e69
Warn when the default path is overwritten
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14360
diff
changeset
|
616 do_set (xpath, false, true); |
5832 | 617 } |
618 | |
619 void | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
620 load_path::do_clear (void) |
5832 | 621 { |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
622 dir_info_list.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
623 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
624 default_loader.clear (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
625 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
626 loader_map.clear (); |
5832 | 627 } |
628 | |
629 static std::list<std::string> | |
630 split_path (const std::string& p) | |
631 { | |
632 std::list<std::string> retval; | |
633 | |
634 size_t beg = 0; | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
635 size_t end = p.find (dir_path::path_sep_char ()); |
5832 | 636 |
637 size_t len = p.length (); | |
638 | |
8021 | 639 while (end != std::string::npos) |
5832 | 640 { |
641 std::string elt = p.substr (beg, end-beg); | |
642 | |
643 if (! elt.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
644 retval.push_back (elt); |
5832 | 645 |
646 beg = end + 1; | |
647 | |
648 if (beg == len) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
649 break; |
5832 | 650 |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
651 end = p.find (dir_path::path_sep_char (), beg); |
5832 | 652 } |
653 | |
654 std::string elt = p.substr (beg); | |
655 | |
656 if (! elt.empty ()) | |
657 retval.push_back (elt); | |
658 | |
659 return retval; | |
660 } | |
661 | |
662 void | |
14376
7dd6ac033e69
Warn when the default path is overwritten
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14360
diff
changeset
|
663 load_path::do_set (const std::string& p, bool warn, bool is_init) |
5832 | 664 { |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
665 // Use a list when we need to preserve order. |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
666 std::list<std::string> elts = split_path (p); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
667 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
668 // Use a set when we need to search and order is not important. |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
669 std::set<std::string> elts_set (elts.begin (), elts.end ()); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
670 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
671 if (is_init) |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
672 init_dirs = elts_set; |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
673 else |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
674 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
675 for (std::set<std::string>::const_iterator it = init_dirs.begin (); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
676 it != init_dirs.end (); it++) |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
677 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
678 if (elts_set.find (*it) == elts_set.end ()) |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
679 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
680 warning_with_id ("Octave:remove-init-dir", |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
681 "default load path altered. Some built-in functions may not be found. Try restoredefaultpath() to recover it."); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
682 break; |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
683 } |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
684 } |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
685 } |
5832 | 686 |
687 // Temporarily disable add hook. | |
688 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
689 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
690 frame.protect_var (add_hook); |
5832 | 691 |
692 add_hook = 0; | |
693 | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
694 do_clear (); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
695 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
696 for (std::list<std::string>::const_iterator i = elts.begin (); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
697 i != elts.end (); i++) |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
698 do_append (*i, warn); |
5832 | 699 |
700 // Restore add hook and execute for all newly added directories. | |
15469
72868cae7624
eliminate some deprecated function warnings
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
701 frame.run_first (); |
5832 | 702 |
703 for (dir_info_list_iterator i = dir_info_list.begin (); | |
704 i != dir_info_list.end (); | |
705 i++) | |
706 { | |
707 if (add_hook) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
708 add_hook (i->dir_name); |
5832 | 709 } |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
710 |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
711 // Always prepend current directory. |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
712 do_prepend (".", warn); |
5832 | 713 } |
714 | |
715 void | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
716 load_path::do_append (const std::string& dir, bool warn) |
5832 | 717 { |
718 if (! dir.empty ()) | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
719 do_add (dir, true, warn); |
5867 | 720 } |
5832 | 721 |
5867 | 722 void |
723 load_path::do_prepend (const std::string& dir, bool warn) | |
724 { | |
725 if (! dir.empty ()) | |
726 do_add (dir, false, warn); | |
5832 | 727 } |
728 | |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
729 // Strip trailing directory separators. |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
730 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
731 static std::string |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
732 strip_trailing_separators (const std::string& dir_arg) |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
733 { |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
734 std::string dir = dir_arg; |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
735 |
12438
ab4c6bbff14a
use correct type for std::string length
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
736 size_t k = dir.length (); |
ab4c6bbff14a
use correct type for std::string length
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
737 |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
738 while (k > 1 && file_ops::is_dir_sep (dir[k-1])) |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
739 k--; |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
740 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
741 if (k < dir.length ()) |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
742 dir.resize (k); |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
743 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
744 return dir; |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
745 } |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
746 |
5832 | 747 void |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
748 load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) |
5832 | 749 { |
5919 | 750 size_t len = dir_arg.length (); |
5911 | 751 |
5919 | 752 if (len > 1 && dir_arg.substr (len-2) == "//") |
5911 | 753 warning_with_id ("Octave:recursive-path-search", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
754 "trailing '//' is no longer special in search path elements"); |
5911 | 755 |
5919 | 756 std::string dir = file_ops::tilde_expand (dir_arg); |
757 | |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
758 dir = strip_trailing_separators (dir); |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
759 |
5867 | 760 dir_info_list_iterator i = find_dir_info (dir); |
761 | |
762 if (i != dir_info_list.end ()) | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
763 do_move (i, at_end); |
5867 | 764 else |
5832 | 765 { |
5867 | 766 file_stat fs (dir); |
5832 | 767 |
5867 | 768 if (fs) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
769 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
770 if (fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
771 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
772 dir_info di (dir); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
773 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
774 if (at_end) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
775 dir_info_list.push_back (di); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
776 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
777 dir_info_list.push_front (di); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
778 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
779 add (di, at_end); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
780 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
781 if (add_hook) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
782 add_hook (dir); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
783 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
784 else if (warn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
785 warning ("addpath: %s: not a directory", dir_arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
786 } |
5867 | 787 else if (warn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
788 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
789 std::string msg = fs.error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
790 warning ("addpath: %s: %s", dir_arg.c_str (), msg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
791 } |
5867 | 792 } |
5832 | 793 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
794 // FIXME: is there a better way to do this? |
5832 | 795 |
5867 | 796 i = find_dir_info ("."); |
5832 | 797 |
5867 | 798 if (i != dir_info_list.end ()) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
799 do_move (i, false); |
5832 | 800 } |
801 | |
7336 | 802 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
803 load_path::loader::remove_fcn_map (const std::string& dir, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
804 const string_vector& fcn_files) |
7336 | 805 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
806 octave_idx_type len = fcn_files.numel (); |
7336 | 807 |
808 for (octave_idx_type k = 0; k < len; k++) | |
809 { | |
810 std::string fname = fcn_files[k]; | |
811 | |
812 std::string ext; | |
813 std::string base = fname; | |
814 | |
815 size_t pos = fname.rfind ('.'); | |
816 | |
8021 | 817 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
818 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
819 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
820 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
821 } |
7336 | 822 |
823 file_info_list_type& file_info_list = fcn_map[base]; | |
824 | |
825 for (file_info_list_iterator p = file_info_list.begin (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
826 p != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
827 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
828 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
829 if (p->dir_name == dir) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
830 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
831 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
832 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
833 if (file_info_list.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
834 fcn_map.erase (fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
835 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
836 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
837 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
838 } |
7336 | 839 } |
840 } | |
841 | |
842 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
843 load_path::loader::remove_private_fcn_map (const std::string& dir) |
7336 | 844 { |
845 private_fcn_map_iterator p = private_fcn_map.find (dir); | |
846 | |
847 if (p != private_fcn_map.end ()) | |
848 private_fcn_map.erase (p); | |
849 } | |
850 | |
851 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
852 load_path::loader::remove_method_map (const std::string& dir) |
7336 | 853 { |
854 for (method_map_iterator i = method_map.begin (); | |
855 i != method_map.end (); | |
856 i++) | |
857 { | |
858 std::string class_name = i->first; | |
859 | |
860 fcn_map_type& fm = i->second; | |
861 | |
862 std::string full_dir_name = file_ops::concat (dir, "@" + class_name); | |
863 | |
864 for (fcn_map_iterator q = fm.begin (); q != fm.end (); q++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
865 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
866 file_info_list_type& file_info_list = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
867 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
868 if (file_info_list.size () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
869 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
870 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
871 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
872 for (file_info_list_iterator p = file_info_list.begin (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
873 p != file_info_list.end (); p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
874 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
875 if (p->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
876 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
877 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
878 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
879 // FIXME: if there are no other elements, we |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
880 // should remove this element of fm but calling |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
881 // erase here would invalidate the iterator q. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
882 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
883 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
884 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
885 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
886 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
887 } |
7336 | 888 } |
889 } | |
890 | |
5832 | 891 bool |
5919 | 892 load_path::do_remove (const std::string& dir_arg) |
5832 | 893 { |
894 bool retval = false; | |
895 | |
5919 | 896 if (! dir_arg.empty ()) |
5832 | 897 { |
5919 | 898 if (dir_arg == ".") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
899 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
900 warning ("rmpath: can't remove \".\" from path"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
901 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
902 // Avoid additional warnings. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
903 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
904 } |
5867 | 905 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
906 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
907 std::string dir = file_ops::tilde_expand (dir_arg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
908 |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
909 dir = strip_trailing_separators (dir); |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
910 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
911 dir_info_list_iterator i = find_dir_info (dir); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
912 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
913 if (i != dir_info_list.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
914 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
915 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
916 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
917 if (remove_hook) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
918 remove_hook (dir); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
919 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
920 dir_info& di = *i; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
921 |
17650
a98902bda11a
Fix invalid memory read in rmpath.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17577
diff
changeset
|
922 remove (di); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
923 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
924 dir_info_list.erase (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
925 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
926 } |
5832 | 927 } |
928 | |
929 return retval; | |
930 } | |
931 | |
932 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
933 load_path::remove (const dir_info& di, const std::string& pname) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
934 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
935 loader& l = get_loader (pname); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
936 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
937 l.remove (di); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
938 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
939 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
940 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
941 for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
942 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
943 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
944 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
945 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
946 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
947 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
948 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
949 remove (p->second, full_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
950 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
951 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
952 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
953 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
954 load_path::loader::remove (const dir_info& di) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
955 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
956 std::string dir = di.dir_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
957 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
958 string_vector fcn_files = di.fcn_files; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
959 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
960 dir_list.remove (dir); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
961 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
962 remove_fcn_map (dir, fcn_files); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
963 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
964 remove_private_fcn_map (dir); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
965 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
966 remove_method_map (dir); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
967 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
968 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
969 void |
5832 | 970 load_path::do_update (void) const |
971 { | |
972 // I don't see a better way to do this because we need to | |
973 // preserve the correct directory ordering for new files that | |
974 // have appeared. | |
975 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
976 default_loader.clear (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
977 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
978 loader_map.clear (); |
7336 | 979 |
5832 | 980 for (dir_info_list_iterator p = dir_info_list.begin (); |
981 p != dir_info_list.end (); | |
982 p++) | |
983 { | |
984 dir_info& di = *p; | |
985 | |
986 di.update (); | |
987 | |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
988 add (di, true, "", true); |
5832 | 989 } |
990 } | |
991 | |
7336 | 992 bool |
993 load_path::check_file_type (std::string& fname, int type, int possible_types, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
994 const std::string& fcn, const char *who) |
7336 | 995 { |
996 bool retval = false; | |
997 | |
998 if (type == load_path::OCT_FILE) | |
999 { | |
1000 if ((type & possible_types) == load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1001 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1002 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1003 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1004 } |
7336 | 1005 } |
1006 else if (type == load_path::M_FILE) | |
1007 { | |
1008 if ((type & possible_types) == load_path::M_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1009 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1010 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1011 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1012 } |
7336 | 1013 } |
1014 else if (type == load_path::MEX_FILE) | |
1015 { | |
1016 if ((type & possible_types) == load_path::MEX_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1017 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1018 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1019 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1020 } |
7336 | 1021 } |
1022 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) | |
1023 { | |
1024 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1025 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1026 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1027 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1028 } |
7336 | 1029 else if (possible_types & load_path::M_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1030 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1031 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1032 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1033 } |
7336 | 1034 } |
1035 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) | |
1036 { | |
1037 if (possible_types & load_path::MEX_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1038 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1039 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1040 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1041 } |
7336 | 1042 else if (possible_types & load_path::M_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1043 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1044 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1045 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1046 } |
7336 | 1047 } |
1048 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) | |
1049 { | |
1050 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1051 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1052 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1053 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1054 } |
7336 | 1055 else if (possible_types & load_path::MEX_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1056 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1057 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1058 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1059 } |
7336 | 1060 } |
1061 else if (type == (load_path::M_FILE | load_path::OCT_FILE | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1062 | load_path::MEX_FILE)) |
7336 | 1063 { |
1064 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1065 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1066 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1067 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1068 } |
7336 | 1069 else if (possible_types & load_path::MEX_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1070 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1071 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1072 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1073 } |
7336 | 1074 else if (possible_types & load_path::M_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1075 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1076 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1077 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1078 } |
7336 | 1079 } |
1080 else | |
1081 error ("%s: %s: invalid type code = %d", who, fcn.c_str (), type); | |
1082 | |
1083 return retval; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1084 } |
7336 | 1085 |
5832 | 1086 std::string |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1087 load_path::loader::find_fcn (const std::string& fcn, std::string& dir_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1088 int type) const |
5832 | 1089 { |
1090 std::string retval; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1091 |
7336 | 1092 // update (); |
5832 | 1093 |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1094 if (fcn.length () > 0 && fcn[0] == '@') |
5832 | 1095 { |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1096 size_t pos = fcn.find ('/'); |
5832 | 1097 |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1098 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1099 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1100 std::string class_name = fcn.substr (1, pos-1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1101 std::string meth = fcn.substr (pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1102 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1103 retval = find_method (class_name, meth, dir_name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1104 } |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1105 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1106 retval = std::string (); |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1107 } |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1108 else |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1109 { |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1110 dir_name = std::string (); |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1111 |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1112 const_fcn_map_iterator p = fcn_map.find (fcn); |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1113 |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1114 if (p != fcn_map.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1115 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1116 const file_info_list_type& file_info_list = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1117 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1118 for (const_file_info_list_iterator i = file_info_list.begin (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1119 i != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1120 i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1121 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1122 const file_info& fi = *i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1123 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1124 retval = file_ops::concat (fi.dir_name, fcn); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1125 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1126 if (check_file_type (retval, type, fi.types, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1127 fcn, "load_path::do_find_fcn")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1128 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1129 dir_name = fi.dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1130 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1131 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1132 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1133 retval = std::string (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1134 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1135 } |
7336 | 1136 } |
1137 | |
1138 return retval; | |
1139 } | |
1140 | |
1141 std::string | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1142 load_path::loader::find_private_fcn (const std::string& dir, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1143 const std::string& fcn, int type) const |
7336 | 1144 { |
1145 std::string retval; | |
1146 | |
1147 // update (); | |
1148 | |
1149 const_private_fcn_map_iterator q = private_fcn_map.find (dir); | |
1150 | |
1151 if (q != private_fcn_map.end ()) | |
1152 { | |
1153 const dir_info::fcn_file_map_type& m = q->second; | |
1154 | |
1155 dir_info::const_fcn_file_map_iterator p = m.find (fcn); | |
1156 | |
1157 if (p != m.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1158 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1159 std::string fname |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1160 = file_ops::concat (file_ops::concat (dir, "private"), fcn); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1161 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1162 if (check_file_type (fname, type, p->second, fcn, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1163 "load_path::find_private_fcn")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1164 retval = fname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1165 } |
7336 | 1166 } |
1167 | |
1168 return retval; | |
1169 } | |
1170 | |
1171 std::string | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1172 load_path::loader::find_method (const std::string& class_name, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1173 const std::string& meth, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1174 std::string& dir_name, int type) const |
7336 | 1175 { |
1176 std::string retval; | |
1177 | |
1178 // update (); | |
1179 | |
1180 dir_name = std::string (); | |
1181 | |
1182 const_method_map_iterator q = method_map.find (class_name); | |
1183 | |
1184 if (q != method_map.end ()) | |
1185 { | |
1186 const fcn_map_type& m = q->second; | |
1187 | |
1188 const_fcn_map_iterator p = m.find (meth); | |
1189 | |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9458
diff
changeset
|
1190 if (p != m.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1191 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1192 const file_info_list_type& file_info_list = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1193 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1194 for (const_file_info_list_iterator i = file_info_list.begin (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1195 i != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1196 i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1197 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1198 const file_info& fi = *i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1199 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1200 retval = file_ops::concat (fi.dir_name, meth); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1201 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1202 bool found = check_file_type (retval, type, fi.types, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1203 meth, "load_path::do_find_method"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1204 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1205 if (found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1206 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1207 dir_name = fi.dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1208 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1209 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1210 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1211 retval = std::string (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1212 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1213 } |
5832 | 1214 } |
1215 | |
1216 return retval; | |
1217 } | |
1218 | |
7336 | 1219 std::list<std::string> |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1220 load_path::loader::methods (const std::string& class_name) const |
7336 | 1221 { |
1222 std::list<std::string> retval; | |
1223 | |
1224 // update (); | |
1225 | |
1226 const_method_map_iterator q = method_map.find (class_name); | |
1227 | |
1228 if (q != method_map.end ()) | |
1229 { | |
1230 const fcn_map_type& m = q->second; | |
1231 | |
1232 for (const_fcn_map_iterator p = m.begin (); p != m.end (); p++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1233 retval.push_back (p->first); |
7336 | 1234 } |
1235 | |
1236 if (! retval.empty ()) | |
1237 retval.sort (); | |
1238 | |
1239 return retval; | |
1240 } | |
1241 | |
20052
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1242 bool |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1243 load_path::is_package (const std::string& name) const |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1244 { |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1245 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1246 p != dir_info_list.end (); |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1247 p++) |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1248 { |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1249 if (p->is_package (name)) |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1250 return true; |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1251 } |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1252 |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1253 return false; |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1254 } |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1255 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1256 std::list<std::string> |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1257 load_path::do_overloads (const std::string& meth) const |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1258 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1259 std::list<std::string> retval; |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1260 |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1261 // update (); |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1262 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1263 default_loader.overloads (meth, retval); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1264 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1265 for (const_loader_map_iterator l = loader_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1266 l != loader_map.end (); ++l) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1267 l->second.overloads (meth, retval); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1268 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1269 return retval; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1270 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1271 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1272 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1273 load_path::loader::overloads (const std::string& meth, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1274 std::list<std::string>& l) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1275 { |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1276 for (const_method_map_iterator q = method_map.begin (); |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1277 q != method_map.end (); q++) |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1278 { |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1279 const fcn_map_type& m = q->second; |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1280 |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1281 if (m.find (meth) != m.end ()) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1282 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1283 std::string class_name = q->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1284 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1285 if (! prefix.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1286 class_name = prefix + "." + class_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1287 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1288 l.push_back (class_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1289 } |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1290 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1291 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1292 |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1293 // Should we cache all files in private directories, or is it OK to just |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1294 // look them up each time as needed? |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1295 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1296 std::string |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1297 find_private_file (const std::string& fname) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1298 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1299 std::string retval; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1300 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1301 // Look in private directory corresponding to current function (if |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1302 // any). |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1303 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1304 octave_user_function *curr_fcn = symbol_table::get_curr_fcn (); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1305 |
18802
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1306 if (curr_fcn) |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1307 { |
18802
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1308 // Even for private functions, dir_name doesn't contain the |
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1309 // "private" directory component so we append it here in all |
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1310 // cases. |
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1311 |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1312 std::string dir_name = curr_fcn->dir_name (); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1313 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1314 if (! dir_name.empty ()) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1315 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1316 std::string pfname = dir_name + file_ops::dir_sep_str () |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1317 + "private" + file_ops::dir_sep_str () + fname; |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1318 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1319 file_stat fs (pfname); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1320 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1321 if (fs.exists () && fs.is_reg ()) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1322 retval = pfname; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1323 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1324 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1325 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1326 return retval; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1327 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1328 |
5832 | 1329 std::string |
1330 load_path::do_find_file (const std::string& file) const | |
1331 { | |
1332 std::string retval; | |
1333 | |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1334 if (octave_env::absolute_pathname (file) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1335 || octave_env::rooted_relative_pathname (file)) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1336 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1337 file_stat fs (file); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1338 |
18926
cc8aaf9c9e33
exist: don't search path for absolute or rooted relative file names
John W. Eaton <jwe@octave.org>
parents:
18802
diff
changeset
|
1339 return fs.exists () ? file : retval; |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1340 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1341 else |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1342 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1343 std::string tfile = find_private_file (file); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1344 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1345 if (! tfile.empty ()) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1346 return tfile; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1347 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1348 |
8021 | 1349 if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) |
5832 | 1350 { |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1351 // Given name has a directory separator, so append it to each |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1352 // element of the load path in turn. |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1353 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1354 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1355 p != dir_info_list.end (); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1356 p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1357 { |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1358 std::string tfile = file_ops::concat (p->dir_name, file); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1359 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1360 file_stat fs (tfile); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1361 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1362 if (fs.exists ()) |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1363 return tfile; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1364 } |
5832 | 1365 } |
6838 | 1366 else |
1367 { | |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1368 // Look in cache. |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1369 |
6838 | 1370 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1371 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1372 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1373 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1374 string_vector all_files = p->all_files; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1375 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1376 octave_idx_type len = all_files.numel (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1377 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1378 for (octave_idx_type i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1379 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1380 if (all_files[i] == file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1381 return file_ops::concat (p->dir_name, file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1382 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1383 } |
6838 | 1384 } |
5832 | 1385 |
1386 return retval; | |
1387 } | |
1388 | |
1389 std::string | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1390 load_path::do_find_dir (const std::string& dir) const |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1391 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1392 std::string retval; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1393 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1394 if (dir.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1395 && (octave_env::absolute_pathname (dir) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1396 || octave_env::rooted_relative_pathname (dir))) |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1397 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1398 file_stat fs (dir); |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1399 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1400 if (fs.exists () && fs.is_dir ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1401 return dir; |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1402 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1403 else |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1404 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1405 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1406 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1407 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1408 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1409 std::string dname = octave_env::make_absolute (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1410 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1411 size_t dname_len = dname.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1412 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1413 if (dname.substr (dname_len - 1) == file_ops::dir_sep_str ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1414 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1415 dname = dname.substr (0, dname_len - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1416 dname_len--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1417 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1418 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1419 size_t dir_len = dir.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1420 |
19542
b9cb664404b9
avoid indexing before beginning of string
John W. Eaton <jwe@octave.org>
parents:
19404
diff
changeset
|
1421 if (dname_len > dir_len |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1422 && file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1423 && dir.compare (dname.substr (dname_len - dir_len)) == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1424 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1425 file_stat fs (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1426 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1427 if (fs.exists () && fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1428 return p->dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1429 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1430 } |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1431 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1432 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1433 return retval; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1434 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1435 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1436 string_vector |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1437 load_path::do_find_matching_dirs (const std::string& dir) const |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1438 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1439 std::list<std::string> retlist; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1440 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1441 if (dir.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1442 && (octave_env::absolute_pathname (dir) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1443 || octave_env::rooted_relative_pathname (dir))) |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1444 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1445 file_stat fs (dir); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1446 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1447 if (fs.exists () && fs.is_dir ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1448 retlist.push_back (dir); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1449 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1450 else |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1451 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1452 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1453 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1454 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1455 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1456 std::string dname = octave_env::make_absolute (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1457 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1458 size_t dname_len = dname.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1459 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1460 if (dname.substr (dname_len - 1) == file_ops::dir_sep_str ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1461 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1462 dname = dname.substr (0, dname_len - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1463 dname_len--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1464 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1465 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1466 size_t dir_len = dir.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1467 |
19545
e2b570e7224b
avoid indexing before beginning of string
John W. Eaton <jwe@octave.org>
parents:
19544
diff
changeset
|
1468 if (dname_len > dir_len |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1469 && file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1470 && dir.compare (dname.substr (dname_len - dir_len)) == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1471 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1472 file_stat fs (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1473 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1474 if (fs.exists () && fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1475 retlist.push_back (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1476 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1477 } |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1478 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1479 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1480 return retlist; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1481 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1482 |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1483 std::string |
5832 | 1484 load_path::do_find_first_of (const string_vector& flist) const |
1485 { | |
1486 std::string retval; | |
1487 | |
1488 std::string dir_name; | |
1489 std::string file_name; | |
1490 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1491 octave_idx_type flen = flist.numel (); |
5832 | 1492 octave_idx_type rel_flen = 0; |
1493 | |
1494 string_vector rel_flist (flen); | |
1495 | |
1496 for (octave_idx_type i = 0; i < flen; i++) | |
1497 { | |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1498 std::string file = flist[i]; |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1499 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1500 if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1501 { |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1502 if (octave_env::absolute_pathname (file) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1503 || octave_env::rooted_relative_pathname (file)) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1504 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1505 file_stat fs (file); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1506 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1507 if (fs.exists ()) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1508 return file; |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1509 } |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1510 else |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1511 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1512 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1513 p != dir_info_list.end (); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1514 p++) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1515 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1516 std::string tfile = file_ops::concat (p->dir_name, file); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1517 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1518 file_stat fs (tfile); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1519 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1520 if (fs.exists ()) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1521 return tfile; |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1522 } |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1523 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1524 } |
5832 | 1525 else |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1526 rel_flist[rel_flen++] = file; |
5832 | 1527 } |
1528 | |
1529 rel_flist.resize (rel_flen); | |
1530 | |
1531 for (const_dir_info_list_iterator p = dir_info_list.begin (); | |
1532 p != dir_info_list.end (); | |
1533 p++) | |
1534 { | |
1535 string_vector all_files = p->all_files; | |
1536 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1537 octave_idx_type len = all_files.numel (); |
5832 | 1538 |
1539 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1540 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1541 for (octave_idx_type j = 0; j < rel_flen; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1542 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1543 if (all_files[i] == rel_flist[j]) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1544 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1545 dir_name = p->dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1546 file_name = rel_flist[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1547 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1548 goto done; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1549 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1550 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1551 } |
5832 | 1552 } |
1553 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1554 done: |
6159 | 1555 |
5832 | 1556 if (! dir_name.empty ()) |
7272 | 1557 retval = file_ops::concat (dir_name, file_name); |
5832 | 1558 |
1559 return retval; | |
1560 } | |
1561 | |
1562 string_vector | |
1563 load_path::do_find_all_first_of (const string_vector& flist) const | |
1564 { | |
1565 std::list<std::string> retlist; | |
1566 | |
1567 std::string dir_name; | |
1568 std::string file_name; | |
1569 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1570 octave_idx_type flen = flist.numel (); |
5832 | 1571 octave_idx_type rel_flen = 0; |
1572 | |
1573 string_vector rel_flist (flen); | |
1574 | |
1575 for (octave_idx_type i = 0; i < flen; i++) | |
1576 { | |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1577 std::string file = flist[i]; |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1578 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1579 if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1580 { |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1581 if (octave_env::absolute_pathname (file) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1582 || octave_env::rooted_relative_pathname (file)) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1583 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1584 file_stat fs (file); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1585 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1586 if (fs.exists ()) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1587 retlist.push_back (file); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1588 } |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1589 else |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1590 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1591 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1592 p != dir_info_list.end (); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1593 p++) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1594 { |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1595 std::string tfile = file_ops::concat (p->dir_name, file); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1596 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1597 file_stat fs (tfile); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1598 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1599 if (fs.exists ()) |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1600 retlist.push_back (tfile); |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1601 } |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1602 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1603 } |
5832 | 1604 else |
11105
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1605 rel_flist[rel_flen++] = file; |
5832 | 1606 } |
1607 | |
1608 rel_flist.resize (rel_flen); | |
1609 | |
1610 for (const_dir_info_list_iterator p = dir_info_list.begin (); | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1611 p != dir_info_list.end (); p++) |
5832 | 1612 { |
1613 string_vector all_files = p->all_files; | |
1614 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1615 octave_idx_type len = all_files.numel (); |
5832 | 1616 |
1617 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1618 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1619 for (octave_idx_type j = 0; j < rel_flen; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1620 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1621 if (all_files[i] == rel_flist[j]) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1622 retlist.push_back (file_ops::concat (p->dir_name, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1623 rel_flist[j])); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1624 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1625 } |
5832 | 1626 } |
1627 | |
9807
645c478aa89d
load-path.cc (load_path::do_find_all_first_of): take advantage of string_vector (std::list<std:string>) constructor
John W. Eaton <jwe@octave.org>
parents:
9806
diff
changeset
|
1628 return retlist; |
5832 | 1629 } |
1630 | |
1631 string_vector | |
1632 load_path::do_dirs (void) const | |
1633 { | |
1634 size_t len = dir_info_list.size (); | |
1635 | |
1636 string_vector retval (len); | |
1637 | |
1638 octave_idx_type k = 0; | |
1639 | |
1640 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1641 i != dir_info_list.end (); | |
1642 i++) | |
1643 retval[k++] = i->dir_name; | |
1644 | |
1645 return retval; | |
1646 } | |
1647 | |
1648 std::list<std::string> | |
1649 load_path::do_dir_list (void) const | |
1650 { | |
1651 std::list<std::string> retval; | |
1652 | |
1653 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1654 i != dir_info_list.end (); | |
1655 i++) | |
1656 retval.push_back (i->dir_name); | |
1657 | |
1658 return retval; | |
1659 } | |
1660 | |
1661 string_vector | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1662 load_path::do_files (const std::string& dir, bool omit_exts) const |
5832 | 1663 { |
1664 string_vector retval; | |
1665 | |
9282
2ed8d2d92507
load_path::do_files: avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents:
9261
diff
changeset
|
1666 const_dir_info_list_iterator p = find_dir_info (dir); |
5832 | 1667 |
9282
2ed8d2d92507
load_path::do_files: avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents:
9261
diff
changeset
|
1668 if (p != dir_info_list.end ()) |
2ed8d2d92507
load_path::do_files: avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents:
9261
diff
changeset
|
1669 retval = p->fcn_files; |
5832 | 1670 |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1671 if (omit_exts) |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1672 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1673 octave_idx_type len = retval.numel (); |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1674 |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1675 for (octave_idx_type i = 0; i < len; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1676 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1677 std::string fname = retval[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1678 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1679 size_t pos = fname.rfind ('.'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1680 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1681 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1682 retval[i] = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1683 } |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1684 } |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1685 |
5832 | 1686 return retval; |
1687 } | |
1688 | |
1689 string_vector | |
1690 load_path::do_fcn_names (void) const | |
1691 { | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1692 return default_loader.fcn_names (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1693 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1694 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1695 string_vector |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1696 load_path::loader::fcn_names (void) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1697 { |
5832 | 1698 size_t len = fcn_map.size (); |
1699 | |
1700 string_vector retval (len); | |
1701 | |
1702 octave_idx_type count = 0; | |
1703 | |
1704 for (const_fcn_map_iterator p = fcn_map.begin (); | |
1705 p != fcn_map.end (); | |
1706 p++) | |
1707 retval[count++] = p->first; | |
1708 | |
1709 return retval; | |
1710 } | |
1711 | |
1712 std::string | |
1713 load_path::do_path (void) const | |
1714 { | |
1715 std::string xpath; | |
1716 | |
1717 string_vector xdirs = load_path::dirs (); | |
1718 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1719 octave_idx_type len = xdirs.numel (); |
5832 | 1720 |
1721 if (len > 0) | |
1722 xpath = xdirs[0]; | |
1723 | |
1724 for (octave_idx_type i = 1; i < len; i++) | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
1725 xpath += dir_path::path_sep_str () + xdirs[i]; |
5832 | 1726 |
1727 return xpath; | |
1728 } | |
1729 | |
1730 void | |
7336 | 1731 print_types (std::ostream& os, int types) |
1732 { | |
1733 bool printed_type = false; | |
1734 | |
1735 if (types & load_path::OCT_FILE) | |
1736 { | |
1737 os << "oct"; | |
1738 printed_type = true; | |
1739 } | |
1740 | |
1741 if (types & load_path::MEX_FILE) | |
1742 { | |
1743 if (printed_type) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1744 os << "|"; |
7336 | 1745 os << "mex"; |
1746 printed_type = true; | |
1747 } | |
1748 | |
1749 if (types & load_path::M_FILE) | |
1750 { | |
1751 if (printed_type) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1752 os << "|"; |
7336 | 1753 os << "m"; |
1754 printed_type = true; | |
1755 } | |
1756 } | |
1757 | |
1758 void | |
1759 print_fcn_list (std::ostream& os, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1760 const load_path::dir_info::fcn_file_map_type& lst) |
7336 | 1761 { |
1762 for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); | |
1763 p != lst.end (); | |
1764 p++) | |
1765 { | |
1766 os << " " << p->first << " ("; | |
1767 | |
1768 print_types (os, p->second); | |
1769 | |
1770 os << ")\n"; | |
1771 } | |
1772 } | |
1773 | |
1774 string_vector | |
1775 get_file_list (const load_path::dir_info::fcn_file_map_type& lst) | |
1776 { | |
1777 octave_idx_type n = lst.size (); | |
1778 | |
1779 string_vector retval (n); | |
1780 | |
1781 octave_idx_type count = 0; | |
1782 | |
1783 for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); | |
1784 p != lst.end (); | |
1785 p++) | |
1786 { | |
1787 std::string nm = p->first; | |
1788 | |
1789 int types = p->second; | |
1790 | |
1791 if (types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1792 nm += ".oct"; |
7336 | 1793 else if (types & load_path::MEX_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1794 nm += ".mex"; |
7336 | 1795 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1796 nm += ".m"; |
7336 | 1797 |
1798 retval[count++] = nm; | |
1799 } | |
1800 | |
1801 return retval; | |
1802 } | |
1803 | |
1804 void | |
5832 | 1805 load_path::do_display (std::ostream& os) const |
1806 { | |
1807 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1808 i != dir_info_list.end (); | |
1809 i++) | |
1810 { | |
1811 string_vector fcn_files = i->fcn_files; | |
1812 | |
1813 if (! fcn_files.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1814 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1815 os << "\n*** function files in " << i->dir_name << ":\n\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1816 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1817 fcn_files.list_in_columns (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1818 } |
5832 | 1819 |
7336 | 1820 const dir_info::method_file_map_type& method_file_map |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1821 = i->method_file_map; |
5832 | 1822 |
7336 | 1823 if (! method_file_map.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1824 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1825 for (dir_info::const_method_file_map_iterator |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1826 p = method_file_map.begin (); p != method_file_map.end (); p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1827 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1828 os << "\n*** methods in " << i->dir_name |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1829 << "/@" << p->first << ":\n\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1830 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1831 const dir_info::class_info& ci = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1832 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1833 string_vector method_files = get_file_list (ci.method_file_map); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1834 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1835 method_files.list_in_columns (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1836 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1837 } |
7336 | 1838 } |
5864 | 1839 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1840 default_loader.display (os); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1841 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1842 for (const_loader_map_iterator l = loader_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1843 l != loader_map.end (); ++l) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1844 l->second.display (os); |
5832 | 1845 } |
1846 | |
10334
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1847 // True if a path is contained in a path list separated by path_sep_char |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1848 static bool |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1849 in_path_list (const std::string& path_list, const std::string& path) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1850 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1851 size_t ps = path.size (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1852 size_t pls = path_list.size (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1853 size_t pos = path_list.find (path); |
10334
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1854 char psc = dir_path::path_sep_char (); |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1855 while (pos != std::string::npos) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1856 { |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1857 if ((pos == 0 || path_list[pos-1] == psc) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1858 && (pos + ps == pls || path_list[pos + ps] == psc)) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1859 return true; |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1860 else |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1861 pos = path_list.find (path, pos + 1); |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1862 } |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1863 |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1864 return false; |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1865 } |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1866 |
5832 | 1867 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1868 load_path::add (const dir_info& di, bool at_end, |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1869 const std::string& pname, bool updating) const |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1870 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1871 loader& l = get_loader (pname); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1872 |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1873 l.add (di, at_end, updating); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1874 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1875 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1876 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1877 for (dir_info::const_package_dir_map_iterator p = package_dir_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1878 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1879 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1880 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1881 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1882 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1883 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1884 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1885 add (p->second, at_end, full_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1886 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1887 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1888 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1889 void |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1890 load_path::loader::add_to_fcn_map (const dir_info& di, bool at_end, |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1891 bool updating) |
5832 | 1892 { |
1893 std::string dir_name = di.dir_name; | |
1894 | |
1895 string_vector fcn_files = di.fcn_files; | |
1896 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1897 octave_idx_type len = fcn_files.numel (); |
5832 | 1898 |
1899 for (octave_idx_type i = 0; i < len; i++) | |
1900 { | |
1901 std::string fname = fcn_files[i]; | |
1902 | |
1903 std::string ext; | |
1904 std::string base = fname; | |
1905 | |
1906 size_t pos = fname.rfind ('.'); | |
1907 | |
8021 | 1908 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1909 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1910 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1911 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1912 } |
5832 | 1913 |
7336 | 1914 file_info_list_type& file_info_list = fcn_map[base]; |
5832 | 1915 |
1916 file_info_list_iterator p = file_info_list.begin (); | |
1917 | |
1918 while (p != file_info_list.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1919 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1920 if (p->dir_name == dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1921 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1922 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1923 p++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1924 } |
5832 | 1925 |
1926 int t = 0; | |
1927 if (ext == ".m") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1928 t = load_path::M_FILE; |
5832 | 1929 else if (ext == ".oct") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1930 t = load_path::OCT_FILE; |
5864 | 1931 else if (ext == ".mex") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1932 t = load_path::MEX_FILE; |
5832 | 1933 |
1934 if (p == file_info_list.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1935 { |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1936 // Warn if a built-in or library function is being shadowed, |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1937 // but not if we are just updating (rehashing) the list. |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1938 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1939 if (! updating) |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1940 { |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1941 if (file_info_list.empty ()) |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1942 { |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1943 if (symbol_table::is_built_in_function_name (base)) |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1944 { |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1945 std::string fcn_path = file_ops::concat (dir_name, fname); |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1946 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1947 warning_with_id ("Octave:shadowed-function", |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1948 "function %s shadows a built-in function", |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1949 fcn_path.c_str ()); |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1950 } |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1951 } |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1952 else if (! at_end) |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1953 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1954 file_info& old = file_info_list.front (); |
10446
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1955 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1956 // FIXME: do we need to be more careful about the |
10446
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1957 // way we look for old.dir_name in sys_path to avoid |
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1958 // partial matches? |
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1959 |
14884
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1960 // Don't warn about Contents.m files since we expect |
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1961 // more than one to exist in the load path. |
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1962 |
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1963 if (fname != "Contents.m" |
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1964 && sys_path.find (old.dir_name) != std::string::npos |
10446
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1965 && in_path_list (sys_path, old.dir_name)) |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1966 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1967 std::string fcn_path = file_ops::concat (dir_name, fname); |
10446
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1968 |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1969 warning_with_id ("Octave:shadowed-function", |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1970 "function %s shadows a core library function", |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1971 fcn_path.c_str ()); |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1972 } |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1973 } |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1974 } |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1975 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1976 file_info fi (dir_name, t); |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1977 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1978 if (at_end) |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1979 file_info_list.push_back (fi); |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1980 else |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1981 file_info_list.push_front (fi); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1982 } |
5832 | 1983 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1984 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1985 file_info& fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1986 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1987 fi.types |= t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1988 } |
5832 | 1989 } |
1990 } | |
1991 | |
7336 | 1992 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1993 load_path::loader::add_to_private_fcn_map (const dir_info& di) |
7336 | 1994 { |
1995 dir_info::fcn_file_map_type private_file_map = di.private_file_map; | |
1996 | |
1997 if (! private_file_map.empty ()) | |
1998 private_fcn_map[di.dir_name] = private_file_map; | |
1999 } | |
2000 | |
2001 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2002 load_path::loader::add_to_method_map (const dir_info& di, bool at_end) |
7336 | 2003 { |
2004 std::string dir_name = di.dir_name; | |
2005 | |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2006 // <CLASS_NAME, CLASS_INFO> |
7336 | 2007 dir_info::method_file_map_type method_file_map = di.method_file_map; |
2008 | |
2009 for (dir_info::const_method_file_map_iterator q = method_file_map.begin (); | |
2010 q != method_file_map.end (); | |
2011 q++) | |
2012 { | |
2013 std::string class_name = q->first; | |
2014 | |
2015 fcn_map_type& fm = method_map[class_name]; | |
2016 | |
2017 std::string full_dir_name | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2018 = file_ops::concat (dir_name, "@" + class_name); |
7336 | 2019 |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2020 const dir_info::class_info& ci = q->second; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2021 |
7336 | 2022 // <FCN_NAME, TYPES> |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2023 const dir_info::fcn_file_map_type& m = ci.method_file_map; |
7336 | 2024 |
2025 for (dir_info::const_fcn_file_map_iterator p = m.begin (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2026 p != m.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2027 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2028 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2029 std::string base = p->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2030 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2031 int types = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2032 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2033 file_info_list_type& file_info_list = fm[base]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2034 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2035 file_info_list_iterator p2 = file_info_list.begin (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2036 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2037 while (p2 != file_info_list.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2038 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2039 if (p2->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2040 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2041 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2042 p2++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2043 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2044 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2045 if (p2 == file_info_list.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2046 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2047 file_info fi (full_dir_name, types); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2048 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2049 if (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2050 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2051 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2052 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2053 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2054 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2055 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2056 // FIXME: is this possible? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2057 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2058 file_info& fi = *p2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2059 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2060 fi.types = types; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2061 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2062 } |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2063 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2064 // <FCN_NAME, TYPES> |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2065 dir_info::fcn_file_map_type private_file_map = ci.private_file_map; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2066 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2067 if (! private_file_map.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2068 private_fcn_map[full_dir_name] = private_file_map; |
7336 | 2069 } |
2070 } | |
2071 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2072 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2073 load_path::loader::display (std::ostream& os) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2074 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2075 os << "*** loader: " << (prefix.empty () ? "<top-level>" : prefix) << "\n\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2076 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2077 for (std::list<std::string>::const_iterator s = dir_list.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2078 s != dir_list.end (); ++s) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2079 os << *s << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2080 os << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2081 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2082 for (const_private_fcn_map_iterator i = private_fcn_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2083 i != private_fcn_map.end (); i++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2084 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2085 os << "\n*** private functions in " |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2086 << file_ops::concat (i->first, "private") << ":\n\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2087 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2088 print_fcn_list (os, i->second); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2089 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2090 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2091 #if defined (DEBUG_LOAD_PATH) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2092 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2093 for (const_fcn_map_iterator i = fcn_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2094 i != fcn_map.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2095 i++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2096 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2097 os << i->first << ":\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2098 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2099 const file_info_list_type& file_info_list = i->second; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2100 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2101 for (const_file_info_list_iterator p = file_info_list.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2102 p != file_info_list.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2103 p++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2104 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2105 os << " " << p->dir_name << " ("; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2106 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2107 print_types (os, p->types); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2108 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2109 os << ")\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2110 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2111 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2112 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2113 for (const_method_map_iterator i = method_map.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2114 i != method_map.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2115 i++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2116 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2117 os << "CLASS " << i->first << ":\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2118 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2119 const fcn_map_type& fm = i->second; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2120 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2121 for (const_fcn_map_iterator q = fm.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2122 q != fm.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2123 q++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2124 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2125 os << " " << q->first << ":\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2126 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2127 const file_info_list_type& file_info_list = q->second; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2128 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2129 for (const_file_info_list_iterator p = file_info_list.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2130 p != file_info_list.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2131 p++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2132 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2133 os << " " << p->dir_name << " ("; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2134 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2135 print_types (os, p->types); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2136 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2137 os << ")\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2138 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2139 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2140 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2141 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2142 os << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2143 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2144 #endif |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2145 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2146 |
5832 | 2147 std::string |
2148 genpath (const std::string& dirname, const string_vector& skip) | |
2149 { | |
2150 std::string retval; | |
2151 | |
5871 | 2152 dir_entry dir (dirname); |
5832 | 2153 |
2154 if (dir) | |
2155 { | |
2156 retval = dirname; | |
2157 | |
18137
181bbce78595
Sort result of genpath() for matlab compatibility (bug #40903).
Rik <rik@octave.org>
parents:
17856
diff
changeset
|
2158 string_vector dirlist = dir.read ().sort (false); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
2159 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
2160 octave_idx_type len = dirlist.numel (); |
5832 | 2161 |
2162 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2163 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2164 std::string elt = dirlist[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2165 |
17414
20d1b911b4e7
* libinterp/corefcn/load-path.cc (genpath): Ignore package dirs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16896
diff
changeset
|
2166 bool skip_p = (elt == "." || elt == ".." || elt[0] == '@' |
20d1b911b4e7
* libinterp/corefcn/load-path.cc (genpath): Ignore package dirs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16896
diff
changeset
|
2167 || elt[0] == '+'); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2168 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2169 if (! skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2170 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
2171 for (octave_idx_type j = 0; j < skip.numel (); j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2172 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2173 skip_p = (elt == skip[j]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2174 if (skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2175 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2176 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2177 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2178 if (! skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2179 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2180 std::string nm = file_ops::concat (dirname, elt); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2181 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2182 file_stat fs (nm); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2183 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2184 if (fs && fs.is_dir ()) |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2185 retval += dir_path::path_sep_str () + genpath (nm, skip); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2186 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2187 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2188 } |
5832 | 2189 } |
2190 | |
2191 return retval; | |
2192 } | |
2193 | |
16690
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2194 std::list<std::string> |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2195 load_path::do_get_all_package_names (bool only_top_level) const |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2196 { |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2197 std::list<std::string> retval; |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2198 |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2199 for (const_loader_map_iterator l = loader_map.begin (); |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2200 l != loader_map.end (); ++l) |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2201 { |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2202 if (! only_top_level || l->first.find ('.') == std::string::npos) |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2203 retval.push_back (l->first); |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2204 } |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2205 |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2206 return retval; |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2207 } |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2208 |
5832 | 2209 static void |
2210 execute_pkg_add_or_del (const std::string& dir, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2211 const std::string& script_file) |
5832 | 2212 { |
2213 if (! octave_interpreter_ready) | |
2214 return; | |
2215 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
2216 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
2217 |
7272 | 2218 std::string file = file_ops::concat (dir, script_file); |
5832 | 2219 |
5978 | 2220 file_stat fs (file); |
5832 | 2221 |
2222 if (fs.exists ()) | |
5975 | 2223 source_file (file, "base"); |
5832 | 2224 } |
2225 | |
2226 void | |
2227 execute_pkg_add (const std::string& dir) | |
2228 { | |
2229 execute_pkg_add_or_del (dir, "PKG_ADD"); | |
2230 } | |
2231 | |
2232 void | |
2233 execute_pkg_del (const std::string& dir) | |
2234 { | |
2235 execute_pkg_add_or_del (dir, "PKG_DEL"); | |
2236 } | |
2237 | |
2238 DEFUN (genpath, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2239 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
2240 @deftypefn {Built-in Function} {} genpath (@var{dir})\n\ |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2241 @deftypefnx {Built-in Function} {} genpath (@var{dir}, @var{skip}, @dots{})\n\ |
8325
b93ac0586e4b
spelling corrections
Brian Gough<bjg@network-theory.co.uk>
parents:
8141
diff
changeset
|
2242 Return a path constructed from @var{dir} and all its subdirectories.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2243 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2244 If additional string parameters are given, the resulting path will exclude\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2245 directories with those names.\n\ |
5832 | 2246 @end deftypefn") |
2247 { | |
2248 octave_value retval; | |
2249 | |
20816
b16bcd7a2a33
Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents:
20812
diff
changeset
|
2250 int nargin = args.length (); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2251 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2252 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2253 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2254 |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2255 if (nargin == 1) |
5832 | 2256 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2257 std::string dirname = args(0).xstring_value ("genpath: DIR must be a string"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2258 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2259 retval = genpath (dirname); |
5832 | 2260 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2261 else |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2262 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2263 std::string dirname = args(0).xstring_value ("genpath: all arguments must be strings"); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2264 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2265 string_vector skip (nargin - 1); |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2266 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2267 for (octave_idx_type i = 1; i < nargin; i++) |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2268 skip[i-1] = args(i).xstring_value ("genpath: all arguments must be strings"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2269 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2270 retval = genpath (dirname, skip); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2271 } |
5832 | 2272 |
2273 return retval; | |
2274 } | |
2275 | |
9105
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2276 static void |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2277 rehash_internal (void) |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2278 { |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2279 load_path::update (); |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2280 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2281 // FIXME: maybe we should rename this variable since it is being |
9105
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2282 // used for more than keeping track of the prompt time. |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2283 |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2284 // This will force updated functions to be found. |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2285 Vlast_prompt_time.stamp (); |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2286 } |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2287 |
5832 | 2288 DEFUN (rehash, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2289 "-*- texinfo -*-\n\ |
5832 | 2290 @deftypefn {Built-in Function} {} rehash ()\n\ |
6644 | 2291 Reinitialize Octave's load path directory cache.\n\ |
5832 | 2292 @end deftypefn") |
2293 { | |
2294 octave_value_list retval; | |
2295 | |
9105
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2296 rehash_internal (); |
5832 | 2297 |
2298 return retval; | |
2299 } | |
2300 | |
8609
fcf762ba66cf
load-path.cc (Fcommand_line_path): rename from Fcommandlinepath
John W. Eaton <jwe@octave.org>
parents:
8593
diff
changeset
|
2301 DEFUN (command_line_path, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2302 "-*- texinfo -*-\n\ |
8609
fcf762ba66cf
load-path.cc (Fcommand_line_path): rename from Fcommandlinepath
John W. Eaton <jwe@octave.org>
parents:
8593
diff
changeset
|
2303 @deftypefn {Built-in Function} {} command_line_path (@dots{})\n\ |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2304 Return the command line path variable.\n\ |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2305 \n\ |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2306 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2307 @end deftypefn") |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2308 { |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2309 return octave_value (load_path::get_command_line_path ()); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2310 } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2311 |
7391 | 2312 DEFUN (restoredefaultpath, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2313 "-*- texinfo -*-\n\ |
7391 | 2314 @deftypefn {Built-in Function} {} restoredefaultpath (@dots{})\n\ |
12601
99babbf683ff
doc: Correct use of it's -> its in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
2315 Restore Octave's path to its initial state at startup.\n\ |
7391 | 2316 \n\ |
2317 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ | |
2318 @end deftypefn") | |
2319 { | |
2320 load_path::initialize (true); | |
2321 | |
2322 return octave_value (load_path::system_path ()); | |
2323 } | |
2324 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2325 // Return Octave's original default list of directories in which to |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2326 // search for function files. This corresponds to the path that |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2327 // exists prior to running the system's octaverc file or the user's |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2328 // ~/.octaverc file |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2329 |
7391 | 2330 DEFUN (__pathorig__, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2331 "-*- texinfo -*-\n\ |
7391 | 2332 @deftypefn {Built-in Function} {@var{val} =} __pathorig__ ()\n\ |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2333 Undocumented internal function.\n\ |
5832 | 2334 @end deftypefn") |
2335 { | |
6630 | 2336 return octave_value (load_path::system_path ()); |
5832 | 2337 } |
2338 | |
2339 DEFUN (path, args, nargout, | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2340 "-*- texinfo -*-\n\ |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2341 @deftypefn {Built-in Function} {} path ()\n\ |
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2342 @deftypefnx {Built-in Function} {@var{str} =} path ()\n\ |
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2343 @deftypefnx {Built-in Function} {@var{str} =} path (@var{path1}, @dots{})\n\ |
6644 | 2344 Modify or display Octave's load path.\n\ |
5832 | 2345 \n\ |
2346 If @var{nargin} and @var{nargout} are zero, display the elements of\n\ | |
6644 | 2347 Octave's load path in an easy to read format.\n\ |
5832 | 2348 \n\ |
2349 If @var{nargin} is zero and nargout is greater than zero, return the\n\ | |
6644 | 2350 current load path.\n\ |
5832 | 2351 \n\ |
2352 If @var{nargin} is greater than zero, concatenate the arguments,\n\ | |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2353 separating them with @code{pathsep}. Set the internal search path\n\ |
5832 | 2354 to the result and return it.\n\ |
2355 \n\ | |
2356 No checks are made for duplicate elements.\n\ | |
2357 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ | |
2358 @end deftypefn") | |
2359 { | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2360 int nargin = args.length (); |
5832 | 2361 |
2362 string_vector argv = args.make_argv ("path"); | |
2363 | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2364 if (nargin > 0) |
5832 | 2365 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2366 std::string path = argv[1]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2367 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2368 for (int i = 2; i <= nargin; i++) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2369 path += dir_path::path_sep_str () + argv[i]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2370 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2371 load_path::set (path, true); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2372 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2373 rehash_internal (); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2374 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2375 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2376 if (nargout > 0) |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2377 return octave_value (load_path::path ()); |
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2378 else if (nargin == 0 && nargout == 0) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2379 { |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2380 octave_stdout << |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2381 "\nOctave's search path contains the following directories:\n\n"; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2382 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2383 string_vector dirs = load_path::dirs (); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2384 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2385 dirs.list_in_columns (octave_stdout); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2386 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2387 octave_stdout << "\n"; |
5832 | 2388 } |
2389 } | |
2390 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8704
diff
changeset
|
2391 DEFUN (addpath, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2392 "-*- texinfo -*-\n\ |
10840 | 2393 @deftypefn {Built-in Function} {} addpath (@var{dir1}, @dots{})\n\ |
6678 | 2394 @deftypefnx {Built-in Function} {} addpath (@var{dir1}, @dots{}, @var{option})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2395 Add named directories to the function search path.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2396 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2397 If @var{option} is @qcode{\"-begin\"} or 0 (the default), prepend the\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
2398 directory name to the current path. If @var{option} is @qcode{\"-end\"}\n\ |
5832 | 2399 or 1, append the directory name to the current path.\n\ |
2400 Directories added to the path must exist.\n\ | |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2401 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2402 In addition to accepting individual directory arguments, lists of\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
2403 directory names separated by @code{pathsep} are also accepted. For example:\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2404 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2405 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
2406 addpath (\"dir1:/dir2:~/dir3\")\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2407 @end example\n\ |
5832 | 2408 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
2409 @end deftypefn") | |
2410 { | |
2411 octave_value retval; | |
2412 | |
2413 // Originally written by Bill Denney and Etienne Grossman. Heavily | |
2414 // modified and translated to C++ by jwe. | |
2415 | |
2416 if (nargout > 0) | |
2417 retval = load_path::path (); | |
2418 | |
2419 int nargin = args.length (); | |
2420 | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2421 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2422 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2423 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2424 bool append = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2425 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2426 octave_value option_arg = args(nargin-1); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2427 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2428 if (option_arg.is_string ()) |
5832 | 2429 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2430 std::string option = option_arg.string_value (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2431 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2432 if (option == "-end") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2433 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2434 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2435 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2436 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2437 else if (option == "-begin") |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2438 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2439 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2440 else if (option_arg.is_numeric_type ()) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2441 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2442 int val = option_arg.xint_value ("addpath: OPTION must be '-begin'/0 or '-end'/1"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2443 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2444 if (val == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2445 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2446 else if (val == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2447 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2448 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2449 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2450 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2451 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2452 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2453 error ("addpath: OPTION must be '-begin'/0 or '-end'/1"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2454 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2455 } |
5832 | 2456 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2457 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2458 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2459 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2460 for (int i = 0; i < nargin; i++) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2461 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2462 std::string arg = args(i).xstring_value ("addpath: all arguments must be strings"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2463 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2464 std::list<std::string> dir_elts = split_path (arg); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2465 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2466 if (! append) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2467 std::reverse (dir_elts.begin (), dir_elts.end ()); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2468 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2469 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2470 p != dir_elts.end (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2471 p++) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2472 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2473 std::string dir = *p; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2474 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2475 //dir = regexprep (dir_elts{j}, '//+', "/"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2476 //dir = regexprep (dir, '/$', ""); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2477 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2478 if (append) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2479 load_path::append (dir, true); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2480 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2481 load_path::prepend (dir, true); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2482 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2483 need_to_update = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2484 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2485 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2486 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2487 if (need_to_update) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2488 rehash_internal (); |
5832 | 2489 |
2490 return retval; | |
2491 } | |
2492 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8704
diff
changeset
|
2493 DEFUN (rmpath, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2494 "-*- texinfo -*-\n\ |
6678 | 2495 @deftypefn {Built-in Function} {} rmpath (@var{dir1}, @dots{})\n\ |
5832 | 2496 Remove @var{dir1}, @dots{} from the current function search path.\n\ |
2497 \n\ | |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2498 In addition to accepting individual directory arguments, lists of\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
2499 directory names separated by @code{pathsep} are also accepted. For example:\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2500 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2501 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
2502 rmpath (\"dir1:/dir2:~/dir3\")\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2503 @end example\n\ |
5832 | 2504 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ |
2505 @end deftypefn") | |
2506 { | |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2507 // Originally written by Etienne Grossmann. Heavily modified and translated |
5832 | 2508 // to C++ by jwe. |
2509 | |
2510 octave_value retval; | |
2511 | |
2512 if (nargout > 0) | |
2513 retval = load_path::path (); | |
2514 | |
2515 int nargin = args.length (); | |
2516 | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2517 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2518 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2519 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2520 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2521 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2522 for (int i = 0; i < nargin; i++) |
5832 | 2523 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2524 std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2525 std::list<std::string> dir_elts = split_path (arg); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2526 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2527 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2528 p != dir_elts.end (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2529 p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2530 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2531 std::string dir = *p; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2532 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2533 //dir = regexprep (dir_elts{j}, '//+', "/"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2534 //dir = regexprep (dir, '/$', ""); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2535 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2536 if (! load_path::remove (dir)) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2537 warning ("rmpath: %s: not found", dir.c_str ()); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2538 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2539 need_to_update = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2540 } |
5832 | 2541 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2542 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2543 if (need_to_update) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2544 rehash_internal (); |
5832 | 2545 |
2546 return retval; | |
2547 } | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2548 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2549 DEFUN (__dump_load_path__, , , "") |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2550 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2551 load_path::display (octave_stdout); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2552 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2553 return octave_value_list (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2554 } |