annotate libinterp/corefcn/load-path.cc @ 22862:e365e87371a3

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