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