annotate libinterp/corefcn/load-path.cc @ 20939:b17fda023ca6

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