Mercurial > octave
annotate libinterp/corefcn/load-path.cc @ 21418:ca8450b9ef5b
Only show Octave executable files in list of @class methods (bug #46416).
* load-path.cc (get_fcn_files): Only add file to function list if it ends in
".m", ".oct", or ".mex".
author | Rik <rik@octave.org> |
---|---|
date | Tue, 08 Mar 2016 13:52:03 -0800 |
parents | 7ce76114b321 |
children | aba2e6293dd8 |
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 | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
25 # include "config.h" |
5832 | 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; | |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21416
diff
changeset
|
49 load_path::hook_fcn_ptr load_path::add_hook = load_path::execute_pkg_add; |
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21416
diff
changeset
|
50 load_path::hook_fcn_ptr load_path::remove_hook = load_path::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 size_t pos = fname.rfind ('.'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
263 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
264 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
265 { |
21418
ca8450b9ef5b
Only show Octave executable files in list of @class methods (bug #46416).
Rik <rik@octave.org>
parents:
21417
diff
changeset
|
266 std::string base = fname.substr (0, pos); |
ca8450b9ef5b
Only show Octave executable files in list of @class methods (bug #46416).
Rik <rik@octave.org>
parents:
21417
diff
changeset
|
267 std::string ext = fname.substr (pos); |
10315
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 if (valid_identifier (base)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
270 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
271 int t = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
272 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
273 if (ext == ".m") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
274 t = load_path::M_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
275 else if (ext == ".oct") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
276 t = load_path::OCT_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
277 else if (ext == ".mex") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
278 t = load_path::MEX_FILE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
279 |
21418
ca8450b9ef5b
Only show Octave executable files in list of @class methods (bug #46416).
Rik <rik@octave.org>
parents:
21417
diff
changeset
|
280 if (t) |
ca8450b9ef5b
Only show Octave executable files in list of @class methods (bug #46416).
Rik <rik@octave.org>
parents:
21417
diff
changeset
|
281 retval[base] = t; |
10315
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
284 } |
5832 | 285 } |
286 else | |
287 { | |
288 std::string msg = dir.error (); | |
289 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); | |
290 } | |
7336 | 291 |
292 return retval; | |
293 } | |
294 | |
295 void | |
296 load_path::dir_info::get_private_file_map (const std::string& d) | |
297 { | |
298 private_file_map = get_fcn_files (d); | |
299 } | |
300 | |
301 void | |
302 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
|
303 const std::string& class_name) |
7336 | 304 { |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
305 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
|
306 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
307 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
|
308 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
309 file_stat fs (pd); |
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 if (fs && fs.is_dir ()) |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
312 method_file_map[class_name].private_file_map = get_fcn_files (pd); |
5832 | 313 } |
314 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
315 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
316 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
|
317 const std::string& package_name) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
318 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
319 package_dir_map[package_name] = dir_info (d); |
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 |
5832 | 322 bool |
323 load_path::instance_ok (void) | |
324 { | |
325 bool retval = true; | |
326 | |
327 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
328 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
329 instance = new load_path (); |
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 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
332 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
|
333 } |
5832 | 334 |
335 if (! instance) | |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20820
diff
changeset
|
336 error ("unable to create load path object!"); |
5832 | 337 |
338 return retval; | |
339 } | |
340 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 // FIXME: maybe we should also maintain a map to speed up this method of access. |
7336 | 342 |
5832 | 343 load_path::const_dir_info_list_iterator |
5919 | 344 load_path::find_dir_info (const std::string& dir_arg) const |
5832 | 345 { |
5919 | 346 std::string dir = file_ops::tilde_expand (dir_arg); |
347 | |
5832 | 348 const_dir_info_list_iterator retval = dir_info_list.begin (); |
349 | |
350 while (retval != dir_info_list.end ()) | |
351 { | |
352 if (retval->dir_name == dir) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
353 break; |
5832 | 354 |
355 retval++; | |
356 } | |
357 | |
358 return retval; | |
359 } | |
360 | |
361 load_path::dir_info_list_iterator | |
5919 | 362 load_path::find_dir_info (const std::string& dir_arg) |
5832 | 363 { |
5919 | 364 std::string dir = file_ops::tilde_expand (dir_arg); |
365 | |
5832 | 366 dir_info_list_iterator retval = dir_info_list.begin (); |
367 | |
368 while (retval != dir_info_list.end ()) | |
369 { | |
370 if (retval->dir_name == dir) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
371 break; |
5832 | 372 |
373 retval++; | |
374 } | |
375 | |
376 return retval; | |
377 } | |
378 | |
379 bool | |
380 load_path::contains (const std::string& dir) const | |
381 { | |
382 return find_dir_info (dir) != dir_info_list.end (); | |
383 } | |
384 | |
16547
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
385 bool |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
386 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
|
387 { |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
388 bool retval = false; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
389 |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
390 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
|
391 i != dir_info_list.end (); |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
392 i++) |
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 if (same_file (dir, i->dir_name)) |
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 retval = true; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
397 break; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
398 } |
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 |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
401 return retval; |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
402 } |
3cd80afc3509
improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
403 |
5832 | 404 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
405 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
|
406 const string_vector& fcn_files, bool at_end) |
5832 | 407 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
408 octave_idx_type len = fcn_files.numel (); |
7336 | 409 |
410 for (octave_idx_type k = 0; k < len; k++) | |
5832 | 411 { |
7336 | 412 std::string fname = fcn_files[k]; |
5832 | 413 |
7336 | 414 std::string ext; |
415 std::string base = fname; | |
416 | |
417 size_t pos = fname.rfind ('.'); | |
5832 | 418 |
8021 | 419 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
420 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
421 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
422 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
423 } |
5832 | 424 |
7336 | 425 file_info_list_type& file_info_list = fcn_map[base]; |
5832 | 426 |
7336 | 427 if (file_info_list.size () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
428 continue; |
7336 | 429 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
430 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
431 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
|
432 p != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
433 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
435 if (p->dir_name == dir_name) |
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 file_info fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
438 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
439 file_info_list.erase (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 (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
442 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
443 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
444 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
445 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
446 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
447 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
448 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
449 } |
7336 | 450 } |
451 } | |
5832 | 452 |
7336 | 453 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
454 load_path::loader::move_method_map (const std::string& dir_name, bool at_end) |
7336 | 455 { |
456 for (method_map_iterator i = method_map.begin (); | |
457 i != method_map.end (); | |
458 i++) | |
459 { | |
460 std::string class_name = i->first; | |
5832 | 461 |
7336 | 462 fcn_map_type& fm = i->second; |
463 | |
464 std::string full_dir_name | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
465 = file_ops::concat (dir_name, "@" + class_name); |
7336 | 466 |
467 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
|
468 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
469 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
|
470 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
471 if (file_info_list.size () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
472 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
473 else |
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 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
|
476 p != file_info_list.end (); p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
477 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
478 if (p->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
479 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
480 file_info fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
481 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
482 file_info_list.erase (p); |
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 (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
485 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
486 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
487 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
488 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
489 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
490 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
491 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
492 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
493 } |
5832 | 494 } |
495 } | |
496 | |
7336 | 497 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
498 load_path::do_move (dir_info_list_iterator i, bool at_end) |
7336 | 499 { |
500 if (dir_info_list.size () > 1) | |
501 { | |
502 dir_info di = *i; | |
503 | |
504 dir_info_list.erase (i); | |
505 | |
506 if (at_end) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
507 dir_info_list.push_back (di); |
7336 | 508 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
509 dir_info_list.push_front (di); |
7336 | 510 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
511 move (di, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
512 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
513 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
514 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
515 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
516 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
|
517 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
518 loader& l = get_loader (pname); |
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 l.move (di, at_end); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
521 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
522 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
|
523 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
524 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
|
525 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
526 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
527 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
528 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
529 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
530 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
531 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
532 move (p->second, at_end, full_name); |
7336 | 533 } |
534 } | |
535 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
536 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
537 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
|
538 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
539 std::string dir_name = di.dir_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
540 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19545
diff
changeset
|
541 std::list<std::string>::iterator s = |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
542 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
|
543 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
544 if (s != dir_list.end ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
545 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
546 dir_list.erase (s); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
547 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
548 if (at_end) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
549 dir_list.push_back (dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
550 else |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
551 dir_list.push_front (dir_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
552 } |
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 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
|
555 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
556 // 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
|
557 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
558 move_method_map (dir_name, at_end); |
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 |
5832 | 561 static void |
562 maybe_add_path_elts (std::string& path, const std::string& dir) | |
563 { | |
564 std::string tpath = genpath (dir); | |
565 | |
566 if (! tpath.empty ()) | |
7374 | 567 { |
568 if (path.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
569 path = tpath; |
7374 | 570 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
571 path += dir_path::path_sep_str () + tpath; |
7374 | 572 } |
5832 | 573 } |
574 | |
575 void | |
6365 | 576 load_path::do_initialize (bool set_initial_path) |
5832 | 577 { |
7374 | 578 sys_path = ""; |
5832 | 579 |
6365 | 580 if (set_initial_path) |
581 { | |
6626 | 582 maybe_add_path_elts (sys_path, Vlocal_ver_oct_file_dir); |
583 maybe_add_path_elts (sys_path, Vlocal_api_oct_file_dir); | |
584 maybe_add_path_elts (sys_path, Vlocal_oct_file_dir); | |
585 maybe_add_path_elts (sys_path, Vlocal_ver_fcn_file_dir); | |
586 maybe_add_path_elts (sys_path, Vlocal_api_fcn_file_dir); | |
587 maybe_add_path_elts (sys_path, Vlocal_fcn_file_dir); | |
588 maybe_add_path_elts (sys_path, Voct_file_dir); | |
589 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
|
590 maybe_add_path_elts (sys_path, Voct_data_dir); |
6365 | 591 } |
5832 | 592 |
593 std::string tpath = load_path::command_line_path; | |
594 | |
595 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
|
596 tpath = octave_env::getenv ("OCTAVE_PATH"); |
5832 | 597 |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
598 std::string xpath; |
5832 | 599 |
600 if (! tpath.empty ()) | |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
601 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
602 xpath = tpath; |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
603 |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
604 if (! sys_path.empty ()) |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
605 xpath += dir_path::path_sep_str () + sys_path; |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
606 } |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
607 else |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
608 xpath = sys_path; |
5832 | 609 |
14376
7dd6ac033e69
Warn when the default path is overwritten
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14360
diff
changeset
|
610 do_set (xpath, false, true); |
5832 | 611 } |
612 | |
613 void | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
614 load_path::do_clear (void) |
5832 | 615 { |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
616 dir_info_list.clear (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
617 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
618 default_loader.clear (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
619 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
620 loader_map.clear (); |
5832 | 621 } |
622 | |
623 static std::list<std::string> | |
624 split_path (const std::string& p) | |
625 { | |
626 std::list<std::string> retval; | |
627 | |
628 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
|
629 size_t end = p.find (dir_path::path_sep_char ()); |
5832 | 630 |
631 size_t len = p.length (); | |
632 | |
8021 | 633 while (end != std::string::npos) |
5832 | 634 { |
635 std::string elt = p.substr (beg, end-beg); | |
636 | |
637 if (! elt.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
638 retval.push_back (elt); |
5832 | 639 |
640 beg = end + 1; | |
641 | |
642 if (beg == len) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
643 break; |
5832 | 644 |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
645 end = p.find (dir_path::path_sep_char (), beg); |
5832 | 646 } |
647 | |
648 std::string elt = p.substr (beg); | |
649 | |
650 if (! elt.empty ()) | |
651 retval.push_back (elt); | |
652 | |
653 return retval; | |
654 } | |
655 | |
656 void | |
14376
7dd6ac033e69
Warn when the default path is overwritten
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14360
diff
changeset
|
657 load_path::do_set (const std::string& p, bool warn, bool is_init) |
5832 | 658 { |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
659 // 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
|
660 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
|
661 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
662 // 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
|
663 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
|
664 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
665 if (is_init) |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
666 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
|
667 else |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
668 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
669 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
|
670 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
|
671 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
672 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
|
673 { |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
674 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
|
675 "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
|
676 break; |
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 } |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
679 } |
5832 | 680 |
681 // Temporarily disable add hook. | |
682 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
683 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
684 frame.protect_var (add_hook); |
5832 | 685 |
686 add_hook = 0; | |
687 | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
688 do_clear (); |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
689 |
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
690 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
|
691 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
|
692 do_append (*i, warn); |
5832 | 693 |
694 // 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
|
695 frame.run_first (); |
5832 | 696 |
697 for (dir_info_list_iterator i = dir_info_list.begin (); | |
698 i != dir_info_list.end (); | |
699 i++) | |
700 { | |
701 if (add_hook) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
702 add_hook (i->dir_name); |
5832 | 703 } |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
704 |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
705 // Always prepend current directory. |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
706 do_prepend (".", warn); |
5832 | 707 } |
708 | |
709 void | |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
710 load_path::do_append (const std::string& dir, bool warn) |
5832 | 711 { |
712 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
|
713 do_add (dir, true, warn); |
5867 | 714 } |
5832 | 715 |
5867 | 716 void |
717 load_path::do_prepend (const std::string& dir, bool warn) | |
718 { | |
719 if (! dir.empty ()) | |
720 do_add (dir, false, warn); | |
5832 | 721 } |
722 | |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
723 // 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
|
724 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
725 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
|
726 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
|
727 { |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
728 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
|
729 |
12438
ab4c6bbff14a
use correct type for std::string length
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
730 size_t k = dir.length (); |
ab4c6bbff14a
use correct type for std::string length
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
731 |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
732 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
|
733 k--; |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
734 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
735 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
|
736 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
|
737 |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
738 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
|
739 } |
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
740 |
5832 | 741 void |
15008
ff9a638a5555
preserve order of path elements when doing "path (new_path)"
John W. Eaton <jwe@octave.org>
parents:
14884
diff
changeset
|
742 load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) |
5832 | 743 { |
5919 | 744 size_t len = dir_arg.length (); |
5911 | 745 |
5919 | 746 if (len > 1 && dir_arg.substr (len-2) == "//") |
5911 | 747 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
|
748 "trailing '//' is no longer special in search path elements"); |
5911 | 749 |
5919 | 750 std::string dir = file_ops::tilde_expand (dir_arg); |
751 | |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
752 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
|
753 |
5867 | 754 dir_info_list_iterator i = find_dir_info (dir); |
755 | |
756 if (i != dir_info_list.end ()) | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
757 do_move (i, at_end); |
5867 | 758 else |
5832 | 759 { |
5867 | 760 file_stat fs (dir); |
5832 | 761 |
5867 | 762 if (fs) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
763 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
764 if (fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
765 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
766 dir_info di (dir); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
767 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
768 if (at_end) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
769 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
|
770 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
771 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
|
772 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
773 add (di, at_end); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
774 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
775 if (add_hook) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
776 add_hook (dir); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
777 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
778 else if (warn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
779 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
|
780 } |
5867 | 781 else if (warn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
782 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
783 std::string msg = fs.error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
784 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
|
785 } |
5867 | 786 } |
5832 | 787 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
788 // FIXME: is there a better way to do this? |
5832 | 789 |
5867 | 790 i = find_dir_info ("."); |
5832 | 791 |
5867 | 792 if (i != dir_info_list.end ()) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
793 do_move (i, false); |
5832 | 794 } |
795 | |
7336 | 796 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
797 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
|
798 const string_vector& fcn_files) |
7336 | 799 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
800 octave_idx_type len = fcn_files.numel (); |
7336 | 801 |
802 for (octave_idx_type k = 0; k < len; k++) | |
803 { | |
804 std::string fname = fcn_files[k]; | |
805 | |
806 std::string ext; | |
807 std::string base = fname; | |
808 | |
809 size_t pos = fname.rfind ('.'); | |
810 | |
8021 | 811 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
812 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
813 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
814 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
815 } |
7336 | 816 |
817 file_info_list_type& file_info_list = fcn_map[base]; | |
818 | |
819 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
|
820 p != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
821 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
822 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
823 if (p->dir_name == dir) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
824 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
825 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
826 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
827 if (file_info_list.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
828 fcn_map.erase (fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
829 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
830 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
831 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
832 } |
7336 | 833 } |
834 } | |
835 | |
836 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
837 load_path::loader::remove_private_fcn_map (const std::string& dir) |
7336 | 838 { |
839 private_fcn_map_iterator p = private_fcn_map.find (dir); | |
840 | |
841 if (p != private_fcn_map.end ()) | |
842 private_fcn_map.erase (p); | |
843 } | |
844 | |
845 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
846 load_path::loader::remove_method_map (const std::string& dir) |
7336 | 847 { |
848 for (method_map_iterator i = method_map.begin (); | |
849 i != method_map.end (); | |
850 i++) | |
851 { | |
852 std::string class_name = i->first; | |
853 | |
854 fcn_map_type& fm = i->second; | |
855 | |
856 std::string full_dir_name = file_ops::concat (dir, "@" + class_name); | |
857 | |
858 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
|
859 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
860 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
|
861 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
862 if (file_info_list.size () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
863 continue; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
864 else |
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 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
|
867 p != file_info_list.end (); p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
868 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
869 if (p->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
870 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
871 file_info_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
872 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
873 // 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
|
874 // should remove this element of fm but calling |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
875 // erase here would invalidate the iterator q. |
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 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
878 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
879 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
880 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
881 } |
7336 | 882 } |
883 } | |
884 | |
5832 | 885 bool |
5919 | 886 load_path::do_remove (const std::string& dir_arg) |
5832 | 887 { |
888 bool retval = false; | |
889 | |
5919 | 890 if (! dir_arg.empty ()) |
5832 | 891 { |
5919 | 892 if (dir_arg == ".") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
893 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
894 warning ("rmpath: can't remove \".\" from path"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
895 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
896 // Avoid additional warnings. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
897 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
898 } |
5867 | 899 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
900 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
901 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
|
902 |
11578
06cfda4c07e5
load_path::do_add, load_path::do_remove: strip trailing directory separators
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
903 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
|
904 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
905 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
|
906 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
907 if (i != dir_info_list.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
908 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
909 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
910 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
911 if (remove_hook) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
912 remove_hook (dir); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
913 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
914 dir_info& di = *i; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
915 |
17650
a98902bda11a
Fix invalid memory read in rmpath.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17577
diff
changeset
|
916 remove (di); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
917 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
918 dir_info_list.erase (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
919 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
920 } |
5832 | 921 } |
922 | |
923 return retval; | |
924 } | |
925 | |
926 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
927 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
|
928 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
929 loader& l = get_loader (pname); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
930 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
931 l.remove (di); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
932 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
933 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
|
934 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
935 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
|
936 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
937 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
938 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
939 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
940 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
941 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
942 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
943 remove (p->second, full_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
944 } |
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 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
947 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
948 load_path::loader::remove (const dir_info& di) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
949 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
950 std::string dir = di.dir_name; |
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 string_vector fcn_files = di.fcn_files; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
953 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
954 dir_list.remove (dir); |
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 remove_fcn_map (dir, fcn_files); |
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 remove_private_fcn_map (dir); |
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 remove_method_map (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 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
963 void |
5832 | 964 load_path::do_update (void) const |
965 { | |
966 // I don't see a better way to do this because we need to | |
967 // preserve the correct directory ordering for new files that | |
968 // have appeared. | |
969 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
970 default_loader.clear (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
971 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
972 loader_map.clear (); |
7336 | 973 |
5832 | 974 for (dir_info_list_iterator p = dir_info_list.begin (); |
975 p != dir_info_list.end (); | |
976 p++) | |
977 { | |
978 dir_info& di = *p; | |
979 | |
980 di.update (); | |
981 | |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
982 add (di, true, "", true); |
5832 | 983 } |
984 } | |
985 | |
7336 | 986 bool |
987 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
|
988 const std::string& fcn, const char *who) |
7336 | 989 { |
990 bool retval = false; | |
991 | |
992 if (type == load_path::OCT_FILE) | |
993 { | |
994 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
|
995 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
996 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
997 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
998 } |
7336 | 999 } |
1000 else if (type == load_path::M_FILE) | |
1001 { | |
1002 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
|
1003 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1004 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1005 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1006 } |
7336 | 1007 } |
1008 else if (type == load_path::MEX_FILE) | |
1009 { | |
1010 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
|
1011 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1012 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1013 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1014 } |
7336 | 1015 } |
1016 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) | |
1017 { | |
1018 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1019 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1020 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1021 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1022 } |
7336 | 1023 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
|
1024 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1025 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1026 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1027 } |
7336 | 1028 } |
1029 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) | |
1030 { | |
1031 if (possible_types & load_path::MEX_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1032 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1033 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1034 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1035 } |
7336 | 1036 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
|
1037 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1038 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1039 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1040 } |
7336 | 1041 } |
1042 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) | |
1043 { | |
1044 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1045 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1046 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1047 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1048 } |
7336 | 1049 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
|
1050 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1051 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1052 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1053 } |
7336 | 1054 } |
1055 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
|
1056 | load_path::MEX_FILE)) |
7336 | 1057 { |
1058 if (possible_types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1059 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1060 fname += ".oct"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1061 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1062 } |
7336 | 1063 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
|
1064 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1065 fname += ".mex"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1066 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1067 } |
7336 | 1068 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
|
1069 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1070 fname += ".m"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1071 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1072 } |
7336 | 1073 } |
1074 else | |
1075 error ("%s: %s: invalid type code = %d", who, fcn.c_str (), type); | |
1076 | |
1077 return retval; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1078 } |
7336 | 1079 |
5832 | 1080 std::string |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1081 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
|
1082 int type) const |
5832 | 1083 { |
1084 std::string retval; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1085 |
7336 | 1086 // update (); |
5832 | 1087 |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1088 if (fcn.length () > 0 && fcn[0] == '@') |
5832 | 1089 { |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1090 size_t pos = fcn.find ('/'); |
5832 | 1091 |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1092 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1093 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1094 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
|
1095 std::string meth = fcn.substr (pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1096 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1097 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
|
1098 } |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1099 else |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1100 retval = ""; |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1101 } |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1102 else |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1103 { |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1104 dir_name = ""; |
8593
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1105 |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1106 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
|
1107 |
4e39b00218d3
load-path.cc (load_path::do_find_fcn): handle @foo/bar
John W. Eaton <jwe@octave.org>
parents:
8586
diff
changeset
|
1108 if (p != fcn_map.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1109 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1110 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
|
1111 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1112 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
|
1113 i != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1114 i++) |
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& fi = *i; |
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 retval = file_ops::concat (fi.dir_name, fcn); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1119 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1120 if (check_file_type (retval, type, fi.types, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1121 fcn, "load_path::do_find_fcn")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1122 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1123 dir_name = fi.dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1124 break; |
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 else |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1127 retval = ""; |
10315
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 } |
7336 | 1130 } |
1131 | |
1132 return retval; | |
1133 } | |
1134 | |
1135 std::string | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1136 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
|
1137 const std::string& fcn, int type) const |
7336 | 1138 { |
1139 std::string retval; | |
1140 | |
1141 // update (); | |
1142 | |
1143 const_private_fcn_map_iterator q = private_fcn_map.find (dir); | |
1144 | |
1145 if (q != private_fcn_map.end ()) | |
1146 { | |
1147 const dir_info::fcn_file_map_type& m = q->second; | |
1148 | |
1149 dir_info::const_fcn_file_map_iterator p = m.find (fcn); | |
1150 | |
1151 if (p != m.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1152 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1153 std::string fname |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1154 = 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
|
1155 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1156 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
|
1157 "load_path::find_private_fcn")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1158 retval = fname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1159 } |
7336 | 1160 } |
1161 | |
1162 return retval; | |
1163 } | |
1164 | |
1165 std::string | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1166 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
|
1167 const std::string& meth, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1168 std::string& dir_name, int type) const |
7336 | 1169 { |
1170 std::string retval; | |
1171 | |
1172 // update (); | |
1173 | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1174 dir_name = ""; |
7336 | 1175 |
1176 const_method_map_iterator q = method_map.find (class_name); | |
1177 | |
1178 if (q != method_map.end ()) | |
1179 { | |
1180 const fcn_map_type& m = q->second; | |
1181 | |
1182 const_fcn_map_iterator p = m.find (meth); | |
1183 | |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9458
diff
changeset
|
1184 if (p != m.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1185 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1186 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
|
1187 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1188 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
|
1189 i != file_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1190 i++) |
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& fi = *i; |
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 retval = file_ops::concat (fi.dir_name, meth); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1195 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1196 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
|
1197 meth, "load_path::do_find_method"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1198 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1199 if (found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1200 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1201 dir_name = fi.dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1202 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1203 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1204 else |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1205 retval = ""; |
10315
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 } |
5832 | 1208 } |
1209 | |
1210 return retval; | |
1211 } | |
1212 | |
7336 | 1213 std::list<std::string> |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1214 load_path::loader::methods (const std::string& class_name) const |
7336 | 1215 { |
1216 std::list<std::string> retval; | |
1217 | |
1218 // update (); | |
1219 | |
1220 const_method_map_iterator q = method_map.find (class_name); | |
1221 | |
1222 if (q != method_map.end ()) | |
1223 { | |
1224 const fcn_map_type& m = q->second; | |
1225 | |
1226 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
|
1227 retval.push_back (p->first); |
7336 | 1228 } |
1229 | |
1230 if (! retval.empty ()) | |
1231 retval.sort (); | |
1232 | |
1233 return retval; | |
1234 } | |
1235 | |
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
|
1236 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
|
1237 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
|
1238 { |
8b501a0db1e9
only insert package names into loader map if package dir exists (bug #43769)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1239 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
|
1240 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
|
1241 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
|
1242 { |
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 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
|
1244 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
|
1245 } |
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 |
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 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
|
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 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1250 std::list<std::string> |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1251 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
|
1252 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1253 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
|
1254 |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1255 // update (); |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1256 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1257 default_loader.overloads (meth, retval); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1258 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1259 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
|
1260 l != loader_map.end (); ++l) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1261 l->second.overloads (meth, retval); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1262 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1263 return 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 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1266 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1267 load_path::loader::overloads (const std::string& meth, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1268 std::list<std::string>& l) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1269 { |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1270 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
|
1271 q != method_map.end (); q++) |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1272 { |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1273 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
|
1274 |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1275 if (m.find (meth) != m.end ()) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1276 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1277 std::string class_name = q->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1278 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1279 if (! prefix.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1280 class_name = prefix + "." + class_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1281 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1282 l.push_back (class_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1283 } |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1284 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1285 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9401
diff
changeset
|
1286 |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1287 // 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
|
1288 // 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
|
1289 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1290 std::string |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1291 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
|
1292 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1293 std::string retval; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1294 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1295 // 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
|
1296 // any). |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1297 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1298 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
|
1299 |
18802
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1300 if (curr_fcn) |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1301 { |
18802
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1302 // 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
|
1303 // "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
|
1304 // cases. |
ebf6a1e5ff59
load files in private directories from private functions (bug #42500)
John W. Eaton <jwe@octave.org>
parents:
18204
diff
changeset
|
1305 |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1306 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
|
1307 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1308 if (! dir_name.empty ()) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1309 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1310 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
|
1311 + "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
|
1312 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1313 file_stat fs (pfname); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1314 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1315 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
|
1316 retval = pfname; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1317 } |
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 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1320 return retval; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1321 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1322 |
5832 | 1323 std::string |
1324 load_path::do_find_file (const std::string& file) const | |
1325 { | |
1326 std::string retval; | |
1327 | |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1328 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
|
1329 || 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
|
1330 { |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1331 file_stat fs (file); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1332 |
18926
cc8aaf9c9e33
exist: don't search path for absolute or rooted relative file names
John W. Eaton <jwe@octave.org>
parents:
18802
diff
changeset
|
1333 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
|
1334 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1335 else |
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 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
|
1338 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1339 if (! tfile.empty ()) |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1340 return tfile; |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1341 } |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1342 |
8021 | 1343 if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) |
5832 | 1344 { |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1345 // 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
|
1346 // 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
|
1347 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1348 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
|
1349 p != dir_info_list.end (); |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1350 p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1351 { |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1352 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
|
1353 |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1354 file_stat fs (tfile); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1355 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1356 if (fs.exists ()) |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1357 return tfile; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1358 } |
5832 | 1359 } |
6838 | 1360 else |
1361 { | |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1362 // Look in cache. |
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
1363 |
6838 | 1364 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
|
1365 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1366 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1367 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1368 string_vector all_files = p->all_files; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1369 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1370 octave_idx_type len = all_files.numel (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1371 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1372 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
|
1373 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1374 if (all_files[i] == file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1375 return file_ops::concat (p->dir_name, file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1376 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1377 } |
6838 | 1378 } |
5832 | 1379 |
1380 return retval; | |
1381 } | |
1382 | |
1383 std::string | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1384 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
|
1385 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1386 std::string retval; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1387 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1388 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
|
1389 && (octave_env::absolute_pathname (dir) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1390 || 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
|
1391 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1392 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
|
1393 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1394 if (fs.exists () && fs.is_dir ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1395 return dir; |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1396 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1397 else |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1398 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1399 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
|
1400 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1401 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1402 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1403 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
|
1404 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1405 size_t dname_len = dname.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1406 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1407 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
|
1408 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1409 dname = dname.substr (0, dname_len - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1410 dname_len--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1411 } |
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 size_t dir_len = dir.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1414 |
19542
b9cb664404b9
avoid indexing before beginning of string
John W. Eaton <jwe@octave.org>
parents:
19404
diff
changeset
|
1415 if (dname_len > dir_len |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1416 && file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
21021
a5b99b09f8fd
maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1417 && dir == dname.substr (dname_len - dir_len)) |
10315
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 file_stat fs (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1420 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1421 if (fs.exists () && fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1422 return p->dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1423 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1424 } |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1425 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1426 |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1427 return retval; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1428 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1429 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1430 string_vector |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1431 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
|
1432 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1433 std::list<std::string> retlist; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1434 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1435 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
|
1436 && (octave_env::absolute_pathname (dir) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1437 || octave_env::rooted_relative_pathname (dir))) |
9806
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 file_stat fs (dir); |
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 (fs.exists () && fs.is_dir ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1442 retlist.push_back (dir); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1443 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1444 else |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1445 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1446 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
|
1447 p != dir_info_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1448 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1449 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1450 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
|
1451 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1452 size_t dname_len = dname.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1453 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1454 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
|
1455 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1456 dname = dname.substr (0, dname_len - 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1457 dname_len--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1458 } |
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 size_t dir_len = dir.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1461 |
19545
e2b570e7224b
avoid indexing before beginning of string
John W. Eaton <jwe@octave.org>
parents:
19544
diff
changeset
|
1462 if (dname_len > dir_len |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1463 && file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
21021
a5b99b09f8fd
maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1464 && dir == dname.substr (dname_len - dir_len)) |
10315
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 file_stat fs (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1467 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1468 if (fs.exists () && fs.is_dir ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1469 retlist.push_back (p->dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1470 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1471 } |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1472 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1473 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1474 return retlist; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1475 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9764
diff
changeset
|
1476 |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1477 std::string |
5832 | 1478 load_path::do_find_first_of (const string_vector& flist) const |
1479 { | |
1480 std::string retval; | |
1481 | |
1482 std::string dir_name; | |
1483 std::string file_name; | |
1484 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1485 octave_idx_type flen = flist.numel (); |
5832 | 1486 octave_idx_type rel_flen = 0; |
1487 | |
1488 string_vector rel_flist (flen); | |
1489 | |
1490 for (octave_idx_type i = 0; i < flen; i++) | |
1491 { | |
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
|
1492 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
|
1493 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1494 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
|
1495 { |
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
|
1496 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
|
1497 || 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
|
1498 { |
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 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
|
1500 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1501 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
|
1502 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
|
1503 } |
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 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
|
1505 { |
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 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
|
1507 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
|
1508 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
|
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 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
|
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 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
|
1513 |
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 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
|
1515 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
|
1516 } |
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 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1518 } |
5832 | 1519 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
|
1520 rel_flist[rel_flen++] = file; |
5832 | 1521 } |
1522 | |
1523 rel_flist.resize (rel_flen); | |
1524 | |
1525 for (const_dir_info_list_iterator p = dir_info_list.begin (); | |
1526 p != dir_info_list.end (); | |
1527 p++) | |
1528 { | |
1529 string_vector all_files = p->all_files; | |
1530 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1531 octave_idx_type len = all_files.numel (); |
5832 | 1532 |
1533 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
|
1534 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1535 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
|
1536 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1537 if (all_files[i] == rel_flist[j]) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1538 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1539 dir_name = p->dir_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1540 file_name = rel_flist[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1541 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1542 goto done; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1543 } |
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 } |
5832 | 1546 } |
1547 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1548 done: |
6159 | 1549 |
5832 | 1550 if (! dir_name.empty ()) |
7272 | 1551 retval = file_ops::concat (dir_name, file_name); |
5832 | 1552 |
1553 return retval; | |
1554 } | |
1555 | |
1556 string_vector | |
1557 load_path::do_find_all_first_of (const string_vector& flist) const | |
1558 { | |
1559 std::list<std::string> retlist; | |
1560 | |
1561 std::string dir_name; | |
1562 std::string file_name; | |
1563 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1564 octave_idx_type flen = flist.numel (); |
5832 | 1565 octave_idx_type rel_flen = 0; |
1566 | |
1567 string_vector rel_flist (flen); | |
1568 | |
1569 for (octave_idx_type i = 0; i < flen; i++) | |
1570 { | |
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
|
1571 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
|
1572 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1573 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
|
1574 { |
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
|
1575 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
|
1576 || 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
|
1577 { |
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 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
|
1579 |
a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
John W. Eaton <jwe@octave.org>
parents:
11032
diff
changeset
|
1580 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
|
1581 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
|
1582 } |
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 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
|
1584 { |
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 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
|
1586 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
|
1587 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
|
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 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
|
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 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
|
1592 |
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 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
|
1594 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
|
1595 } |
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 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1597 } |
5832 | 1598 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
|
1599 rel_flist[rel_flen++] = file; |
5832 | 1600 } |
1601 | |
1602 rel_flist.resize (rel_flen); | |
1603 | |
1604 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
|
1605 p != dir_info_list.end (); p++) |
5832 | 1606 { |
1607 string_vector all_files = p->all_files; | |
1608 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1609 octave_idx_type len = all_files.numel (); |
5832 | 1610 |
1611 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
|
1612 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1613 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
|
1614 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1615 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
|
1616 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
|
1617 rel_flist[j])); |
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 } |
5832 | 1620 } |
1621 | |
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
|
1622 return retlist; |
5832 | 1623 } |
1624 | |
1625 string_vector | |
1626 load_path::do_dirs (void) const | |
1627 { | |
1628 size_t len = dir_info_list.size (); | |
1629 | |
1630 string_vector retval (len); | |
1631 | |
1632 octave_idx_type k = 0; | |
1633 | |
1634 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1635 i != dir_info_list.end (); | |
1636 i++) | |
1637 retval[k++] = i->dir_name; | |
1638 | |
1639 return retval; | |
1640 } | |
1641 | |
1642 std::list<std::string> | |
1643 load_path::do_dir_list (void) const | |
1644 { | |
1645 std::list<std::string> retval; | |
1646 | |
1647 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1648 i != dir_info_list.end (); | |
1649 i++) | |
1650 retval.push_back (i->dir_name); | |
1651 | |
1652 return retval; | |
1653 } | |
1654 | |
1655 string_vector | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1656 load_path::do_files (const std::string& dir, bool omit_exts) const |
5832 | 1657 { |
1658 string_vector retval; | |
1659 | |
9282
2ed8d2d92507
load_path::do_files: avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents:
9261
diff
changeset
|
1660 const_dir_info_list_iterator p = find_dir_info (dir); |
5832 | 1661 |
9282
2ed8d2d92507
load_path::do_files: avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents:
9261
diff
changeset
|
1662 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
|
1663 retval = p->fcn_files; |
5832 | 1664 |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1665 if (omit_exts) |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1666 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1667 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
|
1668 |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1669 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
|
1670 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1671 std::string fname = retval[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1672 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1673 size_t pos = fname.rfind ('.'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1674 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1675 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1676 retval[i] = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1677 } |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1678 } |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9105
diff
changeset
|
1679 |
5832 | 1680 return retval; |
1681 } | |
1682 | |
1683 string_vector | |
1684 load_path::do_fcn_names (void) const | |
1685 { | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1686 return default_loader.fcn_names (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1687 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1688 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1689 string_vector |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1690 load_path::loader::fcn_names (void) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1691 { |
5832 | 1692 size_t len = fcn_map.size (); |
1693 | |
1694 string_vector retval (len); | |
1695 | |
1696 octave_idx_type count = 0; | |
1697 | |
1698 for (const_fcn_map_iterator p = fcn_map.begin (); | |
1699 p != fcn_map.end (); | |
1700 p++) | |
1701 retval[count++] = p->first; | |
1702 | |
1703 return retval; | |
1704 } | |
1705 | |
1706 std::string | |
1707 load_path::do_path (void) const | |
1708 { | |
1709 std::string xpath; | |
1710 | |
1711 string_vector xdirs = load_path::dirs (); | |
1712 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1713 octave_idx_type len = xdirs.numel (); |
5832 | 1714 |
1715 if (len > 0) | |
1716 xpath = xdirs[0]; | |
1717 | |
1718 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
|
1719 xpath += dir_path::path_sep_str () + xdirs[i]; |
5832 | 1720 |
1721 return xpath; | |
1722 } | |
1723 | |
1724 void | |
7336 | 1725 print_types (std::ostream& os, int types) |
1726 { | |
1727 bool printed_type = false; | |
1728 | |
1729 if (types & load_path::OCT_FILE) | |
1730 { | |
1731 os << "oct"; | |
1732 printed_type = true; | |
1733 } | |
1734 | |
1735 if (types & load_path::MEX_FILE) | |
1736 { | |
1737 if (printed_type) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1738 os << "|"; |
7336 | 1739 os << "mex"; |
1740 printed_type = true; | |
1741 } | |
1742 | |
1743 if (types & load_path::M_FILE) | |
1744 { | |
1745 if (printed_type) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1746 os << "|"; |
7336 | 1747 os << "m"; |
1748 printed_type = true; | |
1749 } | |
1750 } | |
1751 | |
1752 void | |
1753 print_fcn_list (std::ostream& os, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1754 const load_path::dir_info::fcn_file_map_type& lst) |
7336 | 1755 { |
1756 for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); | |
1757 p != lst.end (); | |
1758 p++) | |
1759 { | |
1760 os << " " << p->first << " ("; | |
1761 | |
1762 print_types (os, p->second); | |
1763 | |
1764 os << ")\n"; | |
1765 } | |
1766 } | |
1767 | |
1768 string_vector | |
1769 get_file_list (const load_path::dir_info::fcn_file_map_type& lst) | |
1770 { | |
1771 octave_idx_type n = lst.size (); | |
1772 | |
1773 string_vector retval (n); | |
1774 | |
1775 octave_idx_type count = 0; | |
1776 | |
1777 for (load_path::dir_info::const_fcn_file_map_iterator p = lst.begin (); | |
1778 p != lst.end (); | |
1779 p++) | |
1780 { | |
1781 std::string nm = p->first; | |
1782 | |
1783 int types = p->second; | |
1784 | |
1785 if (types & load_path::OCT_FILE) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1786 nm += ".oct"; |
7336 | 1787 else if (types & load_path::MEX_FILE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1788 nm += ".mex"; |
7336 | 1789 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1790 nm += ".m"; |
7336 | 1791 |
1792 retval[count++] = nm; | |
1793 } | |
1794 | |
1795 return retval; | |
1796 } | |
1797 | |
1798 void | |
5832 | 1799 load_path::do_display (std::ostream& os) const |
1800 { | |
1801 for (const_dir_info_list_iterator i = dir_info_list.begin (); | |
1802 i != dir_info_list.end (); | |
1803 i++) | |
1804 { | |
1805 string_vector fcn_files = i->fcn_files; | |
1806 | |
1807 if (! fcn_files.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1808 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1809 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
|
1810 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1811 fcn_files.list_in_columns (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1812 } |
5832 | 1813 |
7336 | 1814 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
|
1815 = i->method_file_map; |
5832 | 1816 |
7336 | 1817 if (! method_file_map.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1818 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1819 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
|
1820 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
|
1821 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1822 os << "\n*** methods in " << i->dir_name |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1823 << "/@" << p->first << ":\n\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1824 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1825 const dir_info::class_info& ci = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1826 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1827 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
|
1828 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1829 method_files.list_in_columns (os); |
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 } |
7336 | 1832 } |
5864 | 1833 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1834 default_loader.display (os); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1835 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1836 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
|
1837 l != loader_map.end (); ++l) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1838 l->second.display (os); |
5832 | 1839 } |
1840 | |
10334
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1841 // 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
|
1842 static bool |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1843 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
|
1844 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1845 size_t ps = path.size (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1846 size_t pls = path_list.size (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1847 size_t pos = path_list.find (path); |
10334
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1848 char psc = dir_path::path_sep_char (); |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1849 while (pos != std::string::npos) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1850 { |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1851 if ((pos == 0 || path_list[pos-1] == psc) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1852 && (pos + ps == pls || path_list[pos + ps] == psc)) |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1853 return true; |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1854 else |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1855 pos = path_list.find (path, pos + 1); |
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 |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1858 return false; |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1859 } |
db540cb0e959
improve shadowed function checking
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
1860 |
5832 | 1861 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1862 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
|
1863 const std::string& pname, bool updating) const |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1864 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1865 loader& l = get_loader (pname); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1866 |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1867 l.add (di, at_end, updating); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1868 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1869 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
|
1870 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1871 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
|
1872 p != package_dir_map.end (); ++p) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1873 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1874 std::string full_name = p->first; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1875 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1876 if (! pname.empty ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1877 full_name = pname + "." + full_name; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1878 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1879 add (p->second, at_end, full_name); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1880 } |
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 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1883 void |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1884 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
|
1885 bool updating) |
5832 | 1886 { |
1887 std::string dir_name = di.dir_name; | |
1888 | |
1889 string_vector fcn_files = di.fcn_files; | |
1890 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
1891 octave_idx_type len = fcn_files.numel (); |
5832 | 1892 |
1893 for (octave_idx_type i = 0; i < len; i++) | |
1894 { | |
1895 std::string fname = fcn_files[i]; | |
1896 | |
1897 std::string ext; | |
1898 std::string base = fname; | |
1899 | |
1900 size_t pos = fname.rfind ('.'); | |
1901 | |
8021 | 1902 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1903 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1904 base = fname.substr (0, pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1905 ext = fname.substr (pos); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1906 } |
5832 | 1907 |
7336 | 1908 file_info_list_type& file_info_list = fcn_map[base]; |
5832 | 1909 |
1910 file_info_list_iterator p = file_info_list.begin (); | |
1911 | |
1912 while (p != file_info_list.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1913 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1914 if (p->dir_name == dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1915 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1916 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1917 p++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1918 } |
5832 | 1919 |
1920 int t = 0; | |
1921 if (ext == ".m") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1922 t = load_path::M_FILE; |
5832 | 1923 else if (ext == ".oct") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1924 t = load_path::OCT_FILE; |
5864 | 1925 else if (ext == ".mex") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1926 t = load_path::MEX_FILE; |
5832 | 1927 |
1928 if (p == file_info_list.end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1929 { |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1930 // 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
|
1931 // 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
|
1932 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1933 if (! updating) |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1934 { |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1935 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
|
1936 { |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1937 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
|
1938 { |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1939 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
|
1940 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1941 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
|
1942 "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
|
1943 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
|
1944 } |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1945 } |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1946 else if (! at_end) |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1947 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1948 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
|
1949 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1950 // 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
|
1951 // 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
|
1952 // partial matches? |
ba932ad87a04
load_path::add_to_fcn_map: style fixes
John W. Eaton <jwe@octave.org>
parents:
10334
diff
changeset
|
1953 |
14884
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1954 // 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
|
1955 // 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
|
1956 |
f10cddda37c5
omit warning for multiple Contents.m files in the load path
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
1957 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
|
1958 && 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
|
1959 && 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
|
1960 { |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1961 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
|
1962 |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1963 warning_with_id ("Octave:shadowed-function", |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11578
diff
changeset
|
1964 "function %s shadows a core library function", |
10242
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1965 fcn_path.c_str ()); |
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 } |
4acae5e46738
warn when core functions are shadowed
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1968 } |
20770
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1969 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1970 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
|
1971 |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1972 if (at_end) |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1973 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
|
1974 else |
826a4771718b
warn about shadowed built ins with addpath -end (bug #46553)
John W. Eaton <jwe@octave.org>
parents:
20756
diff
changeset
|
1975 file_info_list.push_front (fi); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1976 } |
5832 | 1977 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1978 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1979 file_info& fi = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1980 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1981 fi.types |= t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1982 } |
5832 | 1983 } |
1984 } | |
1985 | |
7336 | 1986 void |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1987 load_path::loader::add_to_private_fcn_map (const dir_info& di) |
7336 | 1988 { |
1989 dir_info::fcn_file_map_type private_file_map = di.private_file_map; | |
1990 | |
1991 if (! private_file_map.empty ()) | |
1992 private_fcn_map[di.dir_name] = private_file_map; | |
1993 } | |
1994 | |
1995 void | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1996 load_path::loader::add_to_method_map (const dir_info& di, bool at_end) |
7336 | 1997 { |
1998 std::string dir_name = di.dir_name; | |
1999 | |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2000 // <CLASS_NAME, CLASS_INFO> |
7336 | 2001 dir_info::method_file_map_type method_file_map = di.method_file_map; |
2002 | |
2003 for (dir_info::const_method_file_map_iterator q = method_file_map.begin (); | |
2004 q != method_file_map.end (); | |
2005 q++) | |
2006 { | |
2007 std::string class_name = q->first; | |
2008 | |
2009 fcn_map_type& fm = method_map[class_name]; | |
2010 | |
2011 std::string full_dir_name | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2012 = file_ops::concat (dir_name, "@" + class_name); |
7336 | 2013 |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2014 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
|
2015 |
7336 | 2016 // <FCN_NAME, TYPES> |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2017 const dir_info::fcn_file_map_type& m = ci.method_file_map; |
7336 | 2018 |
2019 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
|
2020 p != m.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2021 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2022 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2023 std::string base = p->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2024 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2025 int types = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2026 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2027 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
|
2028 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2029 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
|
2030 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2031 while (p2 != file_info_list.end ()) |
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 if (p2->dir_name == full_dir_name) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2034 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2035 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2036 p2++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2037 } |
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 == file_info_list.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2040 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2041 file_info fi (full_dir_name, types); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2042 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2043 if (at_end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2044 file_info_list.push_back (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2045 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2046 file_info_list.push_front (fi); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2047 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2048 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2049 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2050 // FIXME: is this possible? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2051 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2052 file_info& fi = *p2; |
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 fi.types = types; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2055 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2056 } |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2057 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2058 // <FCN_NAME, TYPES> |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2059 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
|
2060 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7786
diff
changeset
|
2061 if (! private_file_map.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2062 private_fcn_map[full_dir_name] = private_file_map; |
7336 | 2063 } |
2064 } | |
2065 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2066 void |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2067 load_path::loader::display (std::ostream& os) const |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2068 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2069 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
|
2070 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2071 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
|
2072 s != dir_list.end (); ++s) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2073 os << *s << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2074 os << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2075 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2076 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
|
2077 i != private_fcn_map.end (); i++) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2078 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2079 os << "\n*** private functions in " |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2080 << file_ops::concat (i->first, "private") << ":\n\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 print_fcn_list (os, i->second); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2083 } |
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 #if defined (DEBUG_LOAD_PATH) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2086 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2087 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
|
2088 i != fcn_map.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2089 i++) |
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 os << i->first << ":\n"; |
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 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
|
2094 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2095 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
|
2096 p != file_info_list.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2097 p++) |
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 os << " " << p->dir_name << " ("; |
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 print_types (os, p->types); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2102 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2103 os << ")\n"; |
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 } |
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 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
|
2108 i != method_map.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2109 i++) |
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 os << "CLASS " << i->first << ":\n"; |
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 const fcn_map_type& fm = i->second; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2114 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2115 for (const_fcn_map_iterator q = fm.begin (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2116 q != fm.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2117 q++) |
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 os << " " << q->first << ":\n"; |
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 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
|
2122 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2123 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
|
2124 p != file_info_list.end (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2125 p++) |
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 os << " " << p->dir_name << " ("; |
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 print_types (os, p->types); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2130 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2131 os << ")\n"; |
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 } |
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 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2136 os << "\n"; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2137 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2138 #endif |
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 |
5832 | 2141 std::string |
2142 genpath (const std::string& dirname, const string_vector& skip) | |
2143 { | |
2144 std::string retval; | |
2145 | |
5871 | 2146 dir_entry dir (dirname); |
5832 | 2147 |
2148 if (dir) | |
2149 { | |
2150 retval = dirname; | |
2151 | |
18137
181bbce78595
Sort result of genpath() for matlab compatibility (bug #40903).
Rik <rik@octave.org>
parents:
17856
diff
changeset
|
2152 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
|
2153 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
2154 octave_idx_type len = dirlist.numel (); |
5832 | 2155 |
2156 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
|
2157 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2158 std::string elt = dirlist[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2159 |
17414
20d1b911b4e7
* libinterp/corefcn/load-path.cc (genpath): Ignore package dirs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16896
diff
changeset
|
2160 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
|
2161 || elt[0] == '+'); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2162 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2163 if (! skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2164 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
2165 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
|
2166 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2167 skip_p = (elt == skip[j]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2168 if (skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2169 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2170 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2171 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2172 if (! skip_p) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2173 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2174 std::string nm = file_ops::concat (dirname, elt); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2175 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2176 file_stat fs (nm); |
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 (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
|
2179 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
|
2180 } |
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 } |
5832 | 2183 } |
2184 | |
2185 return retval; | |
2186 } | |
2187 | |
16690
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2188 std::list<std::string> |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2189 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
|
2190 { |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2191 std::list<std::string> retval; |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2192 |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2193 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
|
2194 l != loader_map.end (); ++l) |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2195 { |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2196 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
|
2197 retval.push_back (l->first); |
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 |
1c45e22fc444
Implement meta.package.getAllPackages() method.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
2200 return retval; |
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 |
5832 | 2203 static void |
2204 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
|
2205 const std::string& script_file) |
5832 | 2206 { |
2207 if (! octave_interpreter_ready) | |
2208 return; | |
2209 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
2210 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9807
diff
changeset
|
2211 |
7272 | 2212 std::string file = file_ops::concat (dir, script_file); |
5832 | 2213 |
5978 | 2214 file_stat fs (file); |
5832 | 2215 |
2216 if (fs.exists ()) | |
21416
fdeb0d731512
Backed out changeset 74a676d5ce09
John W. Eaton <jwe@octave.org>
parents:
21415
diff
changeset
|
2217 source_file (file, "base"); |
5832 | 2218 } |
2219 | |
2220 void | |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21416
diff
changeset
|
2221 load_path::execute_pkg_add (const std::string& dir) |
5832 | 2222 { |
2223 execute_pkg_add_or_del (dir, "PKG_ADD"); | |
2224 } | |
2225 | |
2226 void | |
21417
7ce76114b321
catch exceptions in PKG_ADD files at startup (bug #47346)
John W. Eaton <jwe@octave.org>
parents:
21416
diff
changeset
|
2227 load_path::execute_pkg_del (const std::string& dir) |
5832 | 2228 { |
2229 execute_pkg_add_or_del (dir, "PKG_DEL"); | |
2230 } | |
2231 | |
2232 DEFUN (genpath, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2233 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2234 @deftypefn {} {} genpath (@var{dir})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2235 @deftypefnx {} {} genpath (@var{dir}, @var{skip}, @dots{})\n\ |
8325
b93ac0586e4b
spelling corrections
Brian Gough<bjg@network-theory.co.uk>
parents:
8141
diff
changeset
|
2236 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
|
2237 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2238 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
|
2239 directories with those names.\n\ |
5832 | 2240 @end deftypefn") |
2241 { | |
20816
b16bcd7a2a33
Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents:
20812
diff
changeset
|
2242 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
|
2243 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2244 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2245 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2246 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2247 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2248 |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2249 if (nargin == 1) |
5832 | 2250 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2251 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
|
2252 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2253 retval = genpath (dirname); |
5832 | 2254 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2255 else |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
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: 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
|
2258 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2259 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
|
2260 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2261 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
|
2262 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
|
2263 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2264 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
|
2265 } |
5832 | 2266 |
2267 return retval; | |
2268 } | |
2269 | |
9105
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2270 static void |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2271 rehash_internal (void) |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2272 { |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2273 load_path::update (); |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2274 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2275 // 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
|
2276 // 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
|
2277 |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2278 // 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
|
2279 Vlast_prompt_time.stamp (); |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2280 } |
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2281 |
5832 | 2282 DEFUN (rehash, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2283 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2284 @deftypefn {} {} rehash ()\n\ |
6644 | 2285 Reinitialize Octave's load path directory cache.\n\ |
5832 | 2286 @end deftypefn") |
2287 { | |
9105
9b12ed1fbbbd
force rehash if path, addpath, or rmpath modify path
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
2288 rehash_internal (); |
5832 | 2289 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21021
diff
changeset
|
2290 return ovl (); |
5832 | 2291 } |
2292 | |
8609
fcf762ba66cf
load-path.cc (Fcommand_line_path): rename from Fcommandlinepath
John W. Eaton <jwe@octave.org>
parents:
8593
diff
changeset
|
2293 DEFUN (command_line_path, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2294 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2295 @deftypefn {} {} command_line_path (@dots{})\n\ |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2296 Return the command line path variable.\n\ |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2297 \n\ |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2298 @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
|
2299 @end deftypefn") |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2300 { |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21125
diff
changeset
|
2301 return ovl (load_path::get_command_line_path ()); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2302 } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2303 |
7391 | 2304 DEFUN (restoredefaultpath, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2305 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2306 @deftypefn {} {} restoredefaultpath (@dots{})\n\ |
12601
99babbf683ff
doc: Correct use of it's -> its in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
2307 Restore Octave's path to its initial state at startup.\n\ |
7391 | 2308 \n\ |
2309 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ | |
2310 @end deftypefn") | |
2311 { | |
2312 load_path::initialize (true); | |
2313 | |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21125
diff
changeset
|
2314 return ovl (load_path::system_path ()); |
7391 | 2315 } |
2316 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2317 // 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
|
2318 // 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
|
2319 // 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
|
2320 // ~/.octaverc file |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2321 |
7391 | 2322 DEFUN (__pathorig__, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2323 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2324 @deftypefn {} {@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
|
2325 Undocumented internal function.\n\ |
5832 | 2326 @end deftypefn") |
2327 { | |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21125
diff
changeset
|
2328 return ovl (load_path::system_path ()); |
5832 | 2329 } |
2330 | |
2331 DEFUN (path, args, nargout, | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2332 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2333 @deftypefn {} {} path ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2334 @deftypefnx {} {@var{str} =} path ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2335 @deftypefnx {} {@var{str} =} path (@var{path1}, @dots{})\n\ |
6644 | 2336 Modify or display Octave's load path.\n\ |
5832 | 2337 \n\ |
2338 If @var{nargin} and @var{nargout} are zero, display the elements of\n\ | |
6644 | 2339 Octave's load path in an easy to read format.\n\ |
5832 | 2340 \n\ |
2341 If @var{nargin} is zero and nargout is greater than zero, return the\n\ | |
6644 | 2342 current load path.\n\ |
5832 | 2343 \n\ |
2344 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
|
2345 separating them with @code{pathsep}. Set the internal search path\n\ |
5832 | 2346 to the result and return it.\n\ |
2347 \n\ | |
2348 No checks are made for duplicate elements.\n\ | |
2349 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ | |
2350 @end deftypefn") | |
2351 { | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2352 int nargin = args.length (); |
5832 | 2353 |
2354 string_vector argv = args.make_argv ("path"); | |
2355 | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2356 if (nargin > 0) |
5832 | 2357 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2358 std::string path = argv[1]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2359 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2360 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
|
2361 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
|
2362 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2363 load_path::set (path, true); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2364 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2365 rehash_internal (); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2366 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2367 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2368 if (nargout > 0) |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21125
diff
changeset
|
2369 return ovl (load_path::path ()); |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2370 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
|
2371 { |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2372 octave_stdout << |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2373 "\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
|
2374 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2375 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
|
2376 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2377 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
|
2378 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2379 octave_stdout << "\n"; |
5832 | 2380 } |
20820
eed8ec05f1c8
always return value from DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
2381 |
21125
8f76684324b5
maint: change "return octave_value ()" to "return ovl ()".
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
2382 return ovl (); |
5832 | 2383 } |
2384 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8704
diff
changeset
|
2385 DEFUN (addpath, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2386 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2387 @deftypefn {} {} addpath (@var{dir1}, @dots{})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2388 @deftypefnx {} {} 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
|
2389 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
|
2390 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20100
diff
changeset
|
2391 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
|
2392 directory name to the current path. If @var{option} is @qcode{\"-end\"}\n\ |
5832 | 2393 or 1, append the directory name to the current path.\n\ |
2394 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
|
2395 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2396 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
|
2397 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
|
2398 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2399 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
2400 addpath (\"dir1:/dir2:~/dir3\")\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2401 @end example\n\ |
5832 | 2402 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
2403 @end deftypefn") | |
2404 { | |
2405 // Originally written by Bill Denney and Etienne Grossman. Heavily | |
2406 // modified and translated to C++ by jwe. | |
2407 | |
2408 int nargin = args.length (); | |
2409 | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2410 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2411 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2412 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2413 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2414 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2415 if (nargout > 0) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2416 retval = load_path::path (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2417 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2418 bool append = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2419 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2420 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
|
2421 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2422 if (option_arg.is_string ()) |
5832 | 2423 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2424 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
|
2425 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2426 if (option == "-end") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2427 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2428 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2429 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2430 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2431 else if (option == "-begin") |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2432 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2433 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2434 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
|
2435 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2436 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
|
2437 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2438 if (val == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2439 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2440 else if (val == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2441 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2442 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2443 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2444 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2445 else |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20820
diff
changeset
|
2446 error ("addpath: OPTION must be '-begin'/0 or '-end'/1"); |
5832 | 2447 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2448 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2449 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2450 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2451 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
|
2452 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2453 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
|
2454 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2455 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
|
2456 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2457 if (! append) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2458 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
|
2459 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2460 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
|
2461 p != dir_elts.end (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2462 p++) |
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::string dir = *p; |
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 //dir = regexprep (dir_elts{j}, '//+', "/"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2467 //dir = regexprep (dir, '/$', ""); |
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 if (append) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2470 load_path::append (dir, true); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2471 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2472 load_path::prepend (dir, true); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2473 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2474 need_to_update = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2475 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2476 } |
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 (need_to_update) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2479 rehash_internal (); |
5832 | 2480 |
2481 return retval; | |
2482 } | |
2483 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8704
diff
changeset
|
2484 DEFUN (rmpath, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2485 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2486 @deftypefn {} {} rmpath (@var{dir1}, @dots{})\n\ |
5832 | 2487 Remove @var{dir1}, @dots{} from the current function search path.\n\ |
2488 \n\ | |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2489 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
|
2490 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
|
2491 \n\ |
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2492 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
2493 rmpath (\"dir1:/dir2:~/dir3\")\n\ |
10980
1cbfb15892c9
addpath, rmpath: document path arguments
John W. Eaton <jwe@octave.org>
parents:
10971
diff
changeset
|
2494 @end example\n\ |
5832 | 2495 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ |
2496 @end deftypefn") | |
2497 { | |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2498 // Originally written by Etienne Grossmann. Heavily modified and translated |
5832 | 2499 // to C++ by jwe. |
2500 | |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2501 int nargin = args.length (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2502 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2503 if (nargin == 0) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2504 print_usage (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2505 |
5832 | 2506 octave_value retval; |
2507 | |
2508 if (nargout > 0) | |
2509 retval = load_path::path (); | |
2510 | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2511 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2512 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2513 for (int i = 0; i < nargin; i++) |
5832 | 2514 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2515 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
|
2516 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
|
2517 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2518 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
|
2519 p != dir_elts.end (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2520 p++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2521 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2522 std::string dir = *p; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2523 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2524 //dir = regexprep (dir_elts{j}, '//+', "/"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2525 //dir = regexprep (dir, '/$', ""); |
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 if (! load_path::remove (dir)) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2528 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
|
2529 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2530 need_to_update = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2531 } |
5832 | 2532 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2533 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2534 if (need_to_update) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2535 rehash_internal (); |
5832 | 2536 |
2537 return retval; | |
2538 } | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2539 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2540 DEFUN (__dump_load_path__, , , "") |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2541 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2542 load_path::display (octave_stdout); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2543 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
2544 return ovl (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2545 } |