annotate libinterp/corefcn/load-path.cc @ 32090:7d663f770c5a

load-path: Avoid using file_stat on Windows (bug #59711). * liboctave/system/oct-time.h, oct-time.cc (octave::sys::file_time): New class to handle an efficient native file time type per platform. * libinterp/corefcn/load-path.h (load_path::dir_info::dir_mtime, load_path::dir_info::dir_time_last_checked): Change type to new class. * libinterp/corefcn/load-path.cc (subdirs_modified, load_path::dir_info::update, load_path::dir_info::initialize): Avoid using file_stat on Windows.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 13 May 2023 13:33:57 +0200
parents 3c608abd55f5
children fbadf4ce94c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31607
diff changeset
3 // Copyright (C) 2006-2023 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21418
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
28 #endif
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 <algorithm>
28953
dff830c84726 Add function "dir_encoding" to set a file encoding per directory (bug #49685).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28857
diff changeset
31 #include <cctype>
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
32
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
33 #include "dir-ops.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
34 #include "file-ops.h"
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
35 #include "lo-sysdep.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
36 #include "oct-env.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
37 #include "pathsearch.h"
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
38 #if ! defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
39 # include "file-stat.h"
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
40 #endif
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
41
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
42 #include "defaults.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
43 #include "defun.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
44 #include "input.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
45 #include "interpreter-private.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21992
diff changeset
46 #include "interpreter.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
47 #include "load-path.h"
18204
adbbacce8aaf find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents: 18137
diff changeset
48 #include "ov-usr-fcn.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
49 #include "pager.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
50 #include "parse.h"
25516
8945a6a6c0eb Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25460
diff changeset
51 #include "sysdep.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
52 #include "unwind-prot.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
53 #include "utils.h"
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
54
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31593
diff changeset
55 OCTAVE_BEGIN_NAMESPACE(octave)
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
56
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
57 // Canonicalize file name (keeping the path relative) if it exists.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
58 // Return it unmodified otherwise.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
59
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
60 static std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
61 maybe_canonicalize (const std::string& dir_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
62 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
63 bool is_absolute_path = sys::env::absolute_pathname (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
64
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
65 std::string canonical_dir = sys::canonicalize_file_name (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
66 std::string dir;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
67 if (canonical_dir.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
68 dir = dir_arg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
69 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
70 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
71 dir = canonical_dir;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
72
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
73 if (! is_absolute_path)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
74 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
75 // Remove current path from absolute path generated by
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
76 // canonicalize_file_name.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
77 std::string cwd = sys::canonicalize_file_name (".");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
78 if (dir.compare (0, cwd.length (), cwd) == 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
79 dir.erase (0, cwd.length ()+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
80 if (dir.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
81 dir = ".";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
82 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
83 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
84
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
85 return dir;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
86 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
87
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
88 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
89 maybe_add_path_elts (std::string& path, const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
90 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
91 std::string tpath = genpath (maybe_canonicalize (dir));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
92
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
93 if (! tpath.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
94 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
95 if (path.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
96 path = tpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
97 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
98 path += directory_path::path_sep_str () + tpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
99 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
100 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
101
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
102 static std::list<std::string>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
103 split_path (const std::string& p)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
104 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
105 std::list<std::string> retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
106
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
107 std::size_t beg = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
108 std::size_t end = p.find (directory_path::path_sep_char ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
109
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
110 std::size_t len = p.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
111
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
112 while (end != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
113 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
114 std::string elt = p.substr (beg, end-beg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
115
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
116 if (! elt.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
117 retval.push_back (elt);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
118
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
119 beg = end + 1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
120
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
121 if (beg == len)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
122 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
123
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
124 end = p.find (directory_path::path_sep_char (), beg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
125 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
126
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
127 std::string elt = p.substr (beg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
128
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
129 if (! elt.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
130 retval.push_back (elt);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
131
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
132 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
133 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
134
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
135 // Strip trailing directory separators.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
136
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
137 static std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
138 strip_trailing_separators (const std::string& dir_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
139 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
140 std::string dir = dir_arg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
141
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
142 std::size_t k = dir.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
143
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
144 while (k > 1 && sys::file_ops::is_dir_sep (dir[k-1]))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
145 k--;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
146
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
147 if (k < dir.length ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
148 dir.resize (k);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
149
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
150 return dir;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
151 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
152
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
153 // True if a path is contained in a path list separated by path_sep_char
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
154
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
155 static bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
156 in_path_list (const std::string& path_list, const std::string& path)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
157 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
158 std::size_t ps = path.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
159 std::size_t pls = path_list.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
160 std::size_t pos = path_list.find (path);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
161 char psc = directory_path::path_sep_char ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
162 while (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
163 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
164 if ((pos == 0 || path_list[pos-1] == psc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
165 && (pos + ps == pls || path_list[pos + ps] == psc))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
166 return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
167 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
168 pos = path_list.find (path, pos + 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
169 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
170
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
171 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
172 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
173
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
174 //! Check if directory contains modified subdirectories.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
175 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
176 //! @param d directory to check
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
177 //! @param last_checked time of last check
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
178 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
179 //! Path patterns that need to be checked for modifications:
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
180 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
181 //! private/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
182 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
183 //! @class/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
184 //! @class/private/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
185 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
186 //! +namespace/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
187 //! +namespace/private/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
188 //! +namespace/@class/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
189 //! +namespace/@class/private/
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
190 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
191 //! Recursion into sub-namespaces:
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
192 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
193 //! +namespace/+subnamespace/<like above>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
194 //!
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
195 //! @return true if directory contains modified subdirectories
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
196
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
197 static bool
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
198 subdirs_modified (const std::string& d, const sys::file_time& last_checked)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
199 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
200 sys::dir_entry dir (d);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
201
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
202 if (dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
203 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
204 string_vector flist = dir.read ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
205
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
206 octave_idx_type len = flist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
207
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
208 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
209 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
210 std::string fname = flist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
211
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
212 std::string full_name = sys::file_ops::concat (d, fname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
213
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
214 // Check if directory AND if relevant (@,+,private)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
215 // AND (if modified OR recursion into (@,+) sub-directories)
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
216 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
217 if (sys::dir_exists (full_name)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
218 #else
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
219 sys::file_stat fs (full_name);
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
220
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
221 if (fs && fs.is_dir ()
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
222 #endif
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
223 && (fname[0] == '@' || fname[0] == '+' || fname == "private")
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
224 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
225 && ((sys::file_time (full_name)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
226 #else
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
227 && ((sys::file_time (fs.mtime ().unix_time ())
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
228 #endif
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
229 + sys::file_time::time_resolution () > last_checked)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
230 || ((fname[0] == '@' || fname[0] == '+')
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
231 && subdirs_modified (full_name, last_checked))))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
232 return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
233 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
234 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
235 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
236 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
237 std::string msg = dir.error ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
238 warning ("load_path: %s: %s", d.c_str (), msg.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
239 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
240
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
241 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
242 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
243
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
244 std::string load_path::s_sys_path;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
245 load_path::abs_dir_cache_type load_path::s_abs_dir_cache;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
246
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
247 load_path::load_path (interpreter& interp)
31838
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
248 : m_add_hook ([=] (const std::string& dir) { this->execute_pkg_add (dir); }),
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
249 m_remove_hook ([=] (const std::string& dir) { this->execute_pkg_del (dir); }),
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
250 m_interpreter (interp), m_package_map (), m_top_level_package (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
251 m_dir_info_list (), m_init_dirs (), m_command_line_path ()
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
252 { }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
253
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
254 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
255 load_path::initialize (bool set_initial_path)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
256 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
257 s_sys_path = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
258
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
259 if (set_initial_path)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
260 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
261 maybe_add_path_elts (s_sys_path, config::local_ver_oct_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
262 maybe_add_path_elts (s_sys_path, config::local_api_oct_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
263 maybe_add_path_elts (s_sys_path, config::local_oct_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
264 maybe_add_path_elts (s_sys_path, config::local_ver_fcn_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
265 maybe_add_path_elts (s_sys_path, config::local_api_fcn_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
266 maybe_add_path_elts (s_sys_path, config::local_fcn_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
267 maybe_add_path_elts (s_sys_path, config::oct_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
268 maybe_add_path_elts (s_sys_path, config::fcn_file_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
269 maybe_add_path_elts (s_sys_path, config::oct_data_dir ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
271
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
272 std::string tpath = load_path::m_command_line_path;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
273
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
274 if (tpath.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
275 tpath = sys::env::getenv ("OCTAVE_PATH");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
276
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
277 std::string xpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
278
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
279 if (! tpath.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
280 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
281 xpath = tpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
282
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
283 if (! s_sys_path.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
284 xpath += directory_path::path_sep_str () + s_sys_path;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
285 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
286 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
287 xpath = s_sys_path;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
288
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
289 set (xpath, false, true);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
290 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
291
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
292 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
293 load_path::clear ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
294 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
295 m_dir_info_list.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
296
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
297 m_top_level_package.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
298
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
299 m_package_map.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
300 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
301
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
302 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
303 load_path::set (const std::string& p, bool warn, bool is_init)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
304 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
305 // Use a list when we need to preserve order.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
306 std::list<std::string> elts = split_path (p);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
307
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
308 for (auto& elt : elts)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
309 elt = maybe_canonicalize (elt);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
310
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
311 // Use a set when we need to search and order is not important.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
312 std::set<std::string> elts_set (elts.begin (), elts.end ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
313
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
314 if (is_init)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
315 m_init_dirs = elts_set;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
316 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
317 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
318 for (const auto& init_dir : m_init_dirs)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
319 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
320 if (elts_set.find (init_dir) == elts_set.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
321 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
322 warning_with_id ("Octave:remove-init-dir",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
323 "default load path altered. Some built-in functions may not be found. Try restoredefaultpath() to recover it.");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
324 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
325 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
326 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
327 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
328
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
329 // Temporarily disable add hook.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
330
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
331 unwind_protect frame;
31838
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
332 frame.protect_var (m_add_hook);
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
333
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
334 m_add_hook = nullptr;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
335
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
336 clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
337
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
338 for (const auto& elt : elts)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
339 append (elt, warn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
340
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
341 // Restore add hook and execute for all newly added directories.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
342 frame.run_first ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
343
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
344 // FIXME: Shouldn't the test for add_hook be outside the for loop?
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
345 // Why not use const here? Does add_hook change dir_info_list?
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
346 for (auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
347 {
31838
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
348 if (m_add_hook)
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
349 m_add_hook (di.dir_name);
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
350 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
351
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
352 // Always prepend current directory.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
353 prepend (".", warn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
354 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
355
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
356 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
357 load_path::append (const std::string& dir, bool warn)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
358 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
359 if (! dir.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
360 add (dir, true, warn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
361 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
362
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
363 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
364 load_path::prepend (const std::string& dir, bool warn)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
365 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
366 if (! dir.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
367 add (dir, false, warn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
368 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
369
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
370 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
371 load_path::remove (const std::string& dir_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
372 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
373 bool retval = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
374
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
375 if (! dir_arg.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
376 {
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
377 if (sys::same_file (dir_arg, "."))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
378 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
379 warning (R"(rmpath: can't remove "." from path)");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
380
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
381 // Avoid additional warnings.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
382 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
383 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
384 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
385 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
386 std::string dir = sys::file_ops::tilde_expand (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
387
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
388 dir = strip_trailing_separators (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
389
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
390 auto i = find_dir_info (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
391
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
392 if (i != m_dir_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
393 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
394 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
395
31838
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
396 if (m_remove_hook)
45f8b601c992 maint: Use "m_" prefix on all private member variables in classes.
Rik <rik@octave.org>
parents: 31771
diff changeset
397 m_remove_hook (dir);
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
398
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
399 dir_info& di = *i;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
400
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
401 remove (di);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
402
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
403 m_dir_info_list.erase (i);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
404 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
405 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
406 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
407
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
408 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
409 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
410
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
411 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
412 load_path::update ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
413 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
414 // I don't see a better way to do this because we need to
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
415 // preserve the correct directory ordering for new files that
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
416 // have appeared.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
417
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
418 m_top_level_package.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
419
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
420 m_package_map.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
421
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
422 for (auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
423 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
424 bool ok = di.update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
425
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
426 if (! ok)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
427 warning_with_id
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
428 ("Octave:load-path:update-failed",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
429 "load-path: update failed for '%s', removing from path",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
430 di.dir_name.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
431 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
432 add (di, true, "", true);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
433 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
434 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
435
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
436 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
437 load_path::contains_canonical (const std::string& dir) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
438 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
439 bool retval = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
440
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
441 for (const auto& d : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
442 {
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
443 if (sys::same_file (dir, d.dir_name))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
444 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
445 retval = true;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26970
diff changeset
446 break;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
447 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
448 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
449
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
450 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
451 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
452
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
453 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
454 load_path::contains_file_in_dir (const std::string& file,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
455 const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
456 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
457 bool ok = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
458 bool addpath_option = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
459
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
460 std::string curr_dir = sys::env::get_current_directory ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
461
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
462 if (sys::same_file (curr_dir, dir))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
463 ok = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
464 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
465 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
466 bool dir_in_load_path = contains_canonical (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
467
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
468 // get base name, allowing "@class/method.m" (bug #41514)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
469 std::string base_file = (file.length () > dir.length ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
470 ? file.substr (dir.length () + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
471 : sys::env::base_pathname (file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
472
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
473 std::string lp_file = find_file (base_file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
474
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
475 if (dir_in_load_path)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
476 {
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
477 if (sys::same_file (lp_file, file))
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27394
diff changeset
478 ok = true;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
479 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
480 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
481 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
482 // File directory is not in path. Is the file in the path in
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
483 // the current directory? If so, then changing the current
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
484 // directory will be needed. Adding directory to path is
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
485 // not enough because the file in the current directory would
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
486 // still be found.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
487
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
488 if (sys::same_file (lp_file, base_file))
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27394
diff changeset
489 {
32086
3c608abd55f5 Move "same_file" from liboctinterp to liboctave (bug #63803).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32080
diff changeset
490 if (sys::same_file (curr_dir, dir))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
491 ok = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
492 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
493 addpath_option = false;
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27394
diff changeset
494 }
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
495 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
496 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
497
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
498 if (! ok)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
499 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
500 event_manager& evmgr = m_interpreter.get_event_manager ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
501
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
502 int action
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
503 = evmgr.debug_cd_or_addpath_error (file, dir, addpath_option);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
504
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
505 switch (action)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
506 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
507 case 1:
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
508 m_interpreter.chdir (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
509 ok = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
510 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
511
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
512 case 2:
23445
8e310ef0fa97 move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents: 23438
diff changeset
513 {
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
514 prepend (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
515 ok = true;
23445
8e310ef0fa97 move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents: 23438
diff changeset
516 }
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
517 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
518
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
519 default:
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
520 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
521 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
522 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
523
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
524 return ok;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
525 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
526
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
527 std::list<std::string>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
528 load_path::overloads (const std::string& meth) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
529 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
530 std::list<std::string> retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
531
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
532 // update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
533
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
534 m_top_level_package.overloads (meth, retval);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
535
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
536 for (const auto& nm_ldr : m_package_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
537 nm_ldr.second.overloads (meth, retval);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
538
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
539 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
540 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
541
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
542 std::list<std::string>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
543 load_path::get_all_package_names (bool only_top_level) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
544 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
545 std::list<std::string> retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
546
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
547 for (const auto& dir_ldr : m_package_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
548 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
549 if (! only_top_level || dir_ldr.first.find ('.') == std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
550 retval.push_back (dir_ldr.first);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
551 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
552
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
553 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
554 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
555
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
556 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
557 load_path::find_file (const std::string& file) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
558 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
559 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
560
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
561 if (sys::env::absolute_pathname (file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
562 || sys::env::rooted_relative_pathname (file))
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
563 return sys::file_exists (file) ? file : retval;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
564 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
565 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
566 std::string tfile = find_private_file (file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
567
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
568 if (! tfile.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
569 return tfile;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
570 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
571
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
572 if (file.find_first_of (sys::file_ops::dir_sep_chars ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
573 != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
574 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
575 // Given name has a directory separator, so append it to each
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
576 // element of the load path in turn.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
577 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
578 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
579 std::string tfile = sys::file_ops::concat (di.abs_dir_name, file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
580
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
581 if (sys::file_exists (tfile))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
582 return tfile;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
583 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
584 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
585 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
586 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
587 // Look in cache.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
588 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
589 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
590 string_vector all_files = di.all_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
591
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
592 octave_idx_type len = all_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
593
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
594 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
595 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
596 if (all_files[i] == file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
597 return sys::file_ops::concat (di.abs_dir_name, file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
598 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
599 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
600 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
601
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
602 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
603 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
604
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
605 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
606 load_path::find_dir (const std::string& dir) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
607 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
608 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
609
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
610 if (dir.find_first_of (sys::file_ops::dir_sep_chars ()) != std::string::npos
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
611 && (sys::env::absolute_pathname (dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
612 || sys::env::rooted_relative_pathname (dir)))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
613 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
614 if (sys::dir_exists (dir))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
615 return dir;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
616 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
617 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
618 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
619 std::string canon_dir = maybe_canonicalize (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
620 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
621 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
622 std::string dname = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
623
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
624 std::size_t dname_len = dname.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
625
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
626 if (dname.substr (dname_len - 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
627 == sys::file_ops::dir_sep_str ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
628 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
629 dname = dname.substr (0, dname_len - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
630 dname_len--;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
631 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
632
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
633 std::size_t dir_len = canon_dir.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
634
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
635 if (dname_len > dir_len
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
636 && sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1])
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
637 && canon_dir == dname.substr (dname_len - dir_len)
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
638 && sys::dir_exists (di.dir_name))
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
639 return di.abs_dir_name;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
640 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
641 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
642
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
643 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
644 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
645
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
646 string_vector
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
647 load_path::find_matching_dirs (const std::string& dir) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
648 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
649 std::list<std::string> retlist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
650
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
651 if (dir.find_first_of (sys::file_ops::dir_sep_chars ()) != std::string::npos
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
652 && (sys::env::absolute_pathname (dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
653 || sys::env::rooted_relative_pathname (dir)))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
654 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
655 if (sys::dir_exists (dir))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
656 retlist.push_back (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
657 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
658 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
659 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
660 std::string canon_dir = maybe_canonicalize (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
661 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
662 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
663 std::string dname = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
664
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
665 std::size_t dname_len = dname.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
666
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
667 if (dname.substr (dname_len - 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
668 == sys::file_ops::dir_sep_str ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
669 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
670 dname = dname.substr (0, dname_len - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
671 dname_len--;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
672 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
673
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
674 std::size_t dir_len = canon_dir.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
675
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
676 if (dname_len > dir_len
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
677 && sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1])
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
678 && canon_dir == dname.substr (dname_len - dir_len)
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
679 && sys::dir_exists (di.dir_name))
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
680 retlist.push_back (di.abs_dir_name);
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
681 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
682 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
683
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
684 return retlist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
685 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
686
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
687 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
688 load_path::find_first_of (const string_vector& flist) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
689 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
690 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
691
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
692 std::string dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
693 std::string file_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
694
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
695 octave_idx_type flen = flist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
696 octave_idx_type rel_flen = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
697
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
698 string_vector rel_flist (flen);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
699
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
700 for (octave_idx_type i = 0; i < flen; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
701 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
702 std::string file = flist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
703
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
704 if (file.find_first_of (sys::file_ops::dir_sep_chars ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
705 != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
706 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
707 if (sys::env::absolute_pathname (file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
708 || sys::env::rooted_relative_pathname (file))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
709 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
710 if (sys::file_exists (file))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
711 return file;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
712 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
713 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
714 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
715 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
716 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
717 std::string tfile;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
718 tfile = sys::file_ops::concat (di.abs_dir_name, file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
719
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
720 if (sys::file_exists (tfile))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
721 return tfile;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
722 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
723 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
724 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
725 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
726 rel_flist[rel_flen++] = file;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
727 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
728
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
729 rel_flist.resize (rel_flen);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
730
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
731 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
732 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
733 string_vector all_files = di.all_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
734
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
735 octave_idx_type len = all_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
736
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
737 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
738 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
739 for (octave_idx_type j = 0; j < rel_flen; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
740 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
741 if (all_files[i] == rel_flist[j])
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
742 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
743 dir_name = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
744 file_name = rel_flist[j];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
745
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
746 goto done;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
747 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
748 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
749 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
750 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
751
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
752 done:
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
753
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
754 if (! dir_name.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
755 retval = sys::file_ops::concat (dir_name, file_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
756
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
757 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
758 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
759
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
760 string_vector
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
761 load_path::find_all_first_of (const string_vector& flist) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
762 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
763 std::list<std::string> retlist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
764
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
765 std::string dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
766 std::string file_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
767
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
768 octave_idx_type flen = flist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
769 octave_idx_type rel_flen = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
770
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
771 string_vector rel_flist (flen);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
772
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
773 for (octave_idx_type i = 0; i < flen; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
774 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
775 std::string file = flist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
776
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
777 if (file.find_first_of (sys::file_ops::dir_sep_chars ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
778 != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
779 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
780 if (sys::env::absolute_pathname (file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
781 || sys::env::rooted_relative_pathname (file))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
782 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
783 if (sys::file_exists (file))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
784 retlist.push_back (file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
785 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
786 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
787 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
788 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
789 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
790 std::string tfile;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
791 tfile = sys::file_ops::concat (di.abs_dir_name, file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
792
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
793 if (sys::file_exists (tfile))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
794 retlist.push_back (tfile);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
795 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
796 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
797 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
798 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
799 rel_flist[rel_flen++] = file;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
800 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
801
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
802 rel_flist.resize (rel_flen);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
803
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
804 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
805 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
806 string_vector all_files = di.all_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
807
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
808 octave_idx_type len = all_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
809
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
810 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
811 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
812 for (octave_idx_type j = 0; j < rel_flen; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
813 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
814 if (all_files[i] == rel_flist[j])
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
815 retlist.push_back (sys::file_ops::concat (di.abs_dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
816 rel_flist[j]));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
817 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
818 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
819 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
820
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
821 return retlist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
822 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
823
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
824 string_vector
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
825 load_path::dirs () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
826 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
827 std::size_t len = m_dir_info_list.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
828
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
829 string_vector retval (len);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
830
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
831 octave_idx_type k = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
832
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
833 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
834 retval[k++] = di.dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
835
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
836 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
837 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
838
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
839 std::list<std::string>
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
840 load_path::dir_list () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
841 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
842 std::list<std::string> retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
843
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
844 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
845 retval.push_back (di.dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
846
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
847 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
848 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
849
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
850 string_vector
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
851 load_path::files (const std::string& dir, bool omit_exts) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
852 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
853 string_vector retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
854
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
855 const_dir_info_list_iterator p = find_dir_info (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
856
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
857 if (p != m_dir_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
858 retval = p->fcn_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
859
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
860 if (omit_exts)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
861 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
862 octave_idx_type len = retval.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
863
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
864 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
865 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
866 std::string fname = retval[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
867
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
868 std::size_t pos = fname.rfind ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
869
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
870 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
871 retval[i] = fname.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
872 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
873 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
874
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
875 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
876 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
877
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
878 string_vector
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
879 load_path::fcn_names () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
880 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
881 return m_top_level_package.fcn_names ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
882 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
883
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
884 std::string
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
885 load_path::path () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
886 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
887 std::string xpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
888
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
889 string_vector xdirs = load_path::dirs ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
890
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
891 octave_idx_type len = xdirs.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
892
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
893 if (len > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
894 xpath = xdirs[0];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
895
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
896 for (octave_idx_type i = 1; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
897 xpath += directory_path::path_sep_str () + xdirs[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
898
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
899 return xpath;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
900 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
901
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
902 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
903 load_path::display (std::ostream& os) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
904 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
905 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
906 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
907 string_vector fcn_files = di.fcn_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
908
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
909 if (! fcn_files.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
910 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
911 os << "\n*** function files in " << di.dir_name << ":\n\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
912
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
913 fcn_files.list_in_columns (os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
914 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
915
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
916 const dir_info::method_file_map_type& method_file_map
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
917 = di.method_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
918
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
919 if (! method_file_map.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
920 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
921 for (const auto& cls_ci : method_file_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
922 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
923 os << "\n*** methods in " << di.dir_name
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
924 << "/@" << cls_ci.first << ":\n\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
925
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
926 const dir_info::class_info& ci = cls_ci.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
927
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
928 string_vector method_files = get_file_list (ci.method_file_map);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
929
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
930 method_files.list_in_columns (os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
931 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
932 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
933 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
934
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
935 m_top_level_package.display (os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
936
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
937 for (const auto& nm_ldr : m_package_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
938 nm_ldr.second.display (os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
939 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
940
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
941 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
942 load_path::execute_pkg_add (const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
943 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
944 execute_pkg_add_or_del (dir, "PKG_ADD");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
945 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
946
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
947 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
948 load_path::execute_pkg_del (const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
949 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
950 execute_pkg_add_or_del (dir, "PKG_DEL");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
951 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
952
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
953 void load_path::rehash ()
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
954 {
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
955 update ();
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
956
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
957 // Signal the GUI allowing updating the load path dialog
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
958
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
959 event_manager& evmgr = m_interpreter.get_event_manager ();
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
960
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
961 evmgr.update_path_dialog ();
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
962
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
963 // FIXME: maybe we should rename this variable since it is being
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
964 // used for more than keeping track of the prompt time.
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
965
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
966 // This will force updated functions to be found.
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
967 Vlast_prompt_time.stamp ();
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
968 }
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
969
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
970 void load_path::execute_pkg_add_or_del (const std::string& dir,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
971 const std::string& script_file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
972 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
973 if (! octave_interpreter_ready)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
974 return;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
975
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
976 std::string file = sys::file_ops::concat (dir, script_file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
977
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
978 if (sys::file_exists (file))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
979 source_file (file, "base");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
980 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
981
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
982 // FIXME: maybe we should also maintain a map to speed up this method of
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
983 // access.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
984
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
985 load_path::const_dir_info_list_iterator
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
986 load_path::find_dir_info (const std::string& dir_arg) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
987 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
988 std::string dir = sys::file_ops::tilde_expand (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
989
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
990 dir = maybe_canonicalize (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
991
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
992 auto retval = m_dir_info_list.cbegin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
993
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
994 while (retval != m_dir_info_list.cend ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
995 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
996 if (retval->dir_name == dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
997 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
998
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
999 retval++;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1000 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1001
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1002 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1003 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1004
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1005 load_path::dir_info_list_iterator
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1006 load_path::find_dir_info (const std::string& dir_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1007 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1008 std::string dir = sys::file_ops::tilde_expand (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1009
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1010 dir = maybe_canonicalize (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1011
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1012 auto retval = m_dir_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1013
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1014 while (retval != m_dir_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1015 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1016 if (retval->dir_name == dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1017 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1018
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1019 retval++;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1020 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1021
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1022 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1023 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1024
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1025 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1026 load_path::contains (const std::string& dir) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1027 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1028 return find_dir_info (dir) != m_dir_info_list.end ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1029 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1030
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1031 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1032 load_path::move (dir_info_list_iterator i, bool at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1033 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1034 if (m_dir_info_list.size () > 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1035 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1036 dir_info di = *i;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1037
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1038 m_dir_info_list.erase (i);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1039
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1040 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1041 m_dir_info_list.push_back (di);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1042 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1043 m_dir_info_list.push_front (di);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1044
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1045 move (di, at_end);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1046 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1047 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1048
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1049 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1050 load_path::move (const dir_info& di, bool at_end, const std::string& pname)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1051 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1052 package_info& l = get_package (pname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1053
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1054 l.move (di, at_end);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1055
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1056 dir_info::package_dir_map_type package_dir_map = di.package_dir_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1057
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1058 for (const auto& pkg_di : package_dir_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1059 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1060 std::string full_name = pkg_di.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1061
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1062 if (! pname.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1063 full_name = pname + '.' + full_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1064
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1065 move (pkg_di.second, at_end, full_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1066 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1067 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1068
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1069 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1070 load_path::add (const std::string& dir_arg, bool at_end, bool warn)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1071 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1072 std::size_t len = dir_arg.length ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1073
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1074 if (len > 1 && dir_arg.substr (len-2) == "//")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1075 warning_with_id ("Octave:recursive-path-search",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1076 "trailing '//' is no longer special in search path elements");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1077
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1078 std::string dir = sys::file_ops::tilde_expand (dir_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1079
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1080 dir = strip_trailing_separators (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1081
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1082 dir = maybe_canonicalize (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1083
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1084 auto i = find_dir_info (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1085
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1086 if (i != m_dir_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1087 move (i, at_end);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1088 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1089 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1090 std::string msg;
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1091
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1092 if (sys::dir_exists (dir, msg))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1093 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1094 read_dir_config (dir);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1095
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1096 dir_info di (dir);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1097
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1098 if (at_end)
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1099 m_dir_info_list.push_back (di);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1100 else
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1101 m_dir_info_list.push_front (di);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1102
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1103 add (di, at_end);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1104
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1105 if (m_add_hook)
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1106 m_add_hook (dir);
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1107 }
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1108
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1109 if (warn && ! msg.empty ())
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1110 warning ("addpath: %s: %s", dir_arg.c_str (), msg.c_str ());
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1111 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1112
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1113 // FIXME: is there a better way to do this?
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1114
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1115 i = find_dir_info (".");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1116
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1117 if (i != m_dir_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1118 move (i, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1119 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1120
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1121 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1122 load_path::remove (const dir_info& di, const std::string& pname)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1123 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1124 package_info& l = get_package (pname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1125
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1126 l.remove (di);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1127
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1128 dir_info::package_dir_map_type package_dir_map = di.package_dir_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1129
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1130 for (const auto& pkg_di : package_dir_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1131 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1132 std::string full_name = pkg_di.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1133
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1134 if (! pname.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1135 full_name = pname + '.' + full_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1136
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1137 remove (pkg_di.second, full_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1138 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1139 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1140
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1141 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1142 load_path::read_dir_config (const std::string& dir) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1143 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1144 // use canonicalized path as key
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1145 const std::string key = sys::canonicalize_file_name (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1146
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1147 // read file with directory configuration
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1148 const std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1149 conf_file = key + sys::file_ops::dir_sep_str () + ".oct-config";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1150
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1151 FILE *cfile = sys::fopen (conf_file, "rb");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1152
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1153 if (! cfile)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1154 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1155 // reset directory encoding
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1156 input_system& input_sys = __get_input_system__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1157
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1158 std::string enc_val = "delete";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1159 input_sys.set_dir_encoding (key, enc_val);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1160 return;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1161 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1162
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
1163 unwind_action close_file ([cfile] () { fclose (cfile); });
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1164
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1165 // find line with character encoding and read it
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1166 bool eof = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1167 const std::string enc_prop = "encoding";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1168 while (! eof)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1169 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1170 std::string conf_str = fgets (cfile, eof);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1171
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1172 // delete any preceeding whitespace
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1173 auto it = std::find_if_not (conf_str.begin (), conf_str.end (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1174 [] (unsigned char c)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1175 { return std::isblank (c); });
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1176 conf_str.erase (conf_str.begin (), it);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1177
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1178 // match identifier
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1179 if (conf_str.compare (0, enc_prop.size (), enc_prop) == 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1180 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1181 // skip delimiter characters
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1182 std::size_t pos = conf_str.find_first_not_of (" \t=:",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1183 enc_prop.size ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1184 if (pos == std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1185 continue;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1186
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1187 std::string enc_val = conf_str.substr (pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1188
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1189 // take alphanumeric and '-' characters
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1190 it = std::find_if_not (enc_val.begin (), enc_val.end (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1191 [] (unsigned char c)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1192 { return std::isalnum (c) || c == '-'; });
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1193 enc_val.erase(it, enc_val.end ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1194
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1195 if (enc_val.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1196 continue;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1197
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1198 // set encoding for this directory in input system
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1199 input_system& input_sys = __get_input_system__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1200 input_sys.set_dir_encoding (key, enc_val);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1201 return;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1202 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1203 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1204
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1205 // reset directory encoding
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1206 input_system& input_sys = __get_input_system__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1207
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1208 std::string enc_val = "delete";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1209 input_sys.set_dir_encoding (dir, enc_val);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1210
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1211 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1212
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1213 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1214 load_path::is_package (const std::string& name) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1215 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1216 for (const auto& di : m_dir_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1217 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1218 if (di.is_package (name))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1219 return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1220 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1221
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1222 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1223 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1224
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1225 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1226 load_path::add (const dir_info& di, bool at_end,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1227 const std::string& pname, bool updating)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1228 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1229 package_info& l = get_package (pname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1230
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1231 l.add (di, at_end, updating);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1232
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1233 dir_info::package_dir_map_type package_dir_map = di.package_dir_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1234
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1235 for (const auto& pkg_di : package_dir_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1236 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1237 std::string full_name = pkg_di.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1238
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1239 if (! pname.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1240 full_name = pname + '.' + full_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1241
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1242 add (pkg_di.second, at_end, full_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1243 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1244 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1245
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1246 string_vector
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1247 load_path::get_file_list (const load_path::dir_info::fcn_file_map_type& lst) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1248 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1249 octave_idx_type n = lst.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1250
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1251 string_vector retval (n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1252
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1253 octave_idx_type count = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1254
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1255 for (const auto& nm_typ : lst)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1256 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1257 std::string nm = nm_typ.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1258
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1259 int types = nm_typ.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1260
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1261 if (types & load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1262 nm += ".oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1263 else if (types & load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1264 nm += ".mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1265 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1266 nm += ".m";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1267
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1268 retval[count++] = nm;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1269 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1270
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1271 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1272 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1273
31740
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1274 // Should we cache all files in private directories, or is it OK to just
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1275 // look them up each time as needed?
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1276
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1277 std::string
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1278 load_path::find_private_file (const std::string& fname) const
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1279 {
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1280 std::string retval;
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1281
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1282 // Look in private directory corresponding to current function (if
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1283 // any).
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1284
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1285 symbol_scope scope = m_interpreter.get_current_scope ();
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1286
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1287 octave_user_code *curr_code = scope ? scope.user_code () : nullptr;
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1288
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1289 if (curr_code)
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1290 {
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1291 // Even for private functions, dir_name doesn't contain the
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1292 // "private" directory component so we append it here in all
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1293 // cases.
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1294
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1295 std::string dir_name = curr_code->dir_name ();
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1296
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1297 if (! dir_name.empty ())
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1298 {
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1299 std::string pfname = dir_name + sys::file_ops::dir_sep_str ()
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1300 + "private" + sys::file_ops::dir_sep_str ()
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1301 + fname;
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1302
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1303 if (sys::file_exists (pfname, false))
31740
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1304 retval = pfname;
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1305 }
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1306 }
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1307
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1308 return retval;
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1309 }
00931c611342 make find_private_file a private load_path member function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
1310
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1311 load_path::dir_info::fcn_file_map_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1312 get_fcn_files (const std::string& d)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1313 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1314 load_path::dir_info::fcn_file_map_type retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1315
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1316 string_vector flist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1317 std::string msg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1318
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1319 if (! sys::get_dirlist (d, flist, msg))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1320 warning ("load_path: %s: %s", d.c_str (), msg.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1321 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1322 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1323 octave_idx_type len = flist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1324
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1325 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1326 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1327 std::string fname = flist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1328
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1329 std::size_t pos = fname.rfind ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1330
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1331 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1332 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1333 std::string base = fname.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1334 std::string ext = fname.substr (pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1335
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1336 if (valid_identifier (base))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1337 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1338 int t = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1339
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1340 if (ext == ".m")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1341 t = load_path::M_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1342 else if (ext == ".oct")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1343 t = load_path::OCT_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1344 else if (ext == ".mex")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1345 t = load_path::MEX_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1346
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1347 if (t)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1348 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1349 load_path::dir_info::fcn_file_map_iterator p
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1350 = retval.find (base);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1351
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1352 if (p == retval.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1353 retval[base] = t;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1354 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1355 p->second |= t;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1356 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1357 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1358 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1359 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1360 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1361
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1362 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1363 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1364
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1365 bool
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
1366 load_path::dir_info::update ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1367 {
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1368 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1369 std::string msg;
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1370
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1371 if (! sys::dir_exists (dir_name, msg))
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1372 {
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1373 #else
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1374 sys::file_stat fs (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1375
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1376 if (! fs)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1377 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1378 std::string msg = fs.error ();
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1379 #endif
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1380 warning_with_id ("Octave:load-path:dir-info:update-failed",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1381 "load_path: %s: %s", dir_name.c_str (), msg.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1382
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1383 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1384 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1385
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1386 if (is_relative)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1387 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1388 try
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1389 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1390 std::string abs_name = sys::canonicalize_file_name (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1391
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1392 const_abs_dir_cache_iterator p = s_abs_dir_cache.find (abs_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1393
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1394 if (p != s_abs_dir_cache.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1395 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1396 // The directory is in the cache of all directories we have
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1397 // visited (indexed by absolute name). If it is out of date,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1398 // initialize it. Otherwise, copy the info from the cache.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1399 // By doing that, we avoid unnecessary calls to stat that can
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1400 // slow things down tremendously for large directories.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1401 const dir_info& di = p->second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1402
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1403 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1404 if ((sys::file_time (dir_name)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1405 #else
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1406 if ((sys::file_time (fs.mtime ().unix_time ())
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1407 #endif
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1408 + sys::file_time::time_resolution ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1409 > di.dir_time_last_checked)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1410 || subdirs_modified (dir_name, dir_time_last_checked))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1411 initialize ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1412 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1413 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1414 // Copy over info from cache, but leave dir_name and
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1415 // is_relative unmodified.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1416 abs_dir_name = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1417 dir_mtime = di.dir_mtime;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1418 dir_time_last_checked = di.dir_time_last_checked;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1419 all_files = di.all_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1420 fcn_files = di.fcn_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1421 private_file_map = di.private_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1422 method_file_map = di.method_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1423 package_dir_map = di.package_dir_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1424 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1425 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1426 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1427 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1428 // We haven't seen this directory before.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1429 initialize ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1430 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1431 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1432 catch (const execution_exception& ee)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1433 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1434 // Skip updating if we don't know where we are, but don't
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1435 // treat it as an error.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1436
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1437 interpreter& interp = __get_interpreter__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1438
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1439 interp.recover_from_exception ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1440 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1441 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1442 // Absolute path, check timestamp to see whether it requires re-caching
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1443 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1444 else if (sys::file_time (dir_name)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1445 #else
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1446 else if (sys::file_time (fs.mtime ().unix_time ())
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1447 #endif
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1448 + sys::file_time::time_resolution () > dir_time_last_checked
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1449 || subdirs_modified (dir_name, dir_time_last_checked))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1450 initialize ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1451
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1452 return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1453 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1454
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1455 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1456 load_path::dir_info::is_package (const std::string& name) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1457 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1458 std::size_t pos = name.find ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1459
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1460 if (pos == std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1461 return package_dir_map.find (name) != package_dir_map.end ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1462 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1463 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1464 std::string name_head = name.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1465 std::string name_tail = name.substr (pos + 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1466
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1467 const_package_dir_map_iterator it = package_dir_map.find (name_head);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1468
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1469 if (it != package_dir_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1470 return it->second.is_package (name_tail);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1471 else
25957
d8993fe43a64 remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents: 25952
diff changeset
1472 return false;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1473 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1474 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1475
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1476 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
1477 load_path::dir_info::initialize ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1478 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1479 is_relative = ! sys::env::absolute_pathname (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1480
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1481 dir_time_last_checked = sys::file_time (static_cast<OCTAVE_TIME_T> (0));
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1482
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1483 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1484 std::string msg;
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1485
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1486 if (sys::dir_exists (dir_name, msg))
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1487 #else
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1488 sys::file_stat fs (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1489
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1490 if (fs)
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1491 #endif
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1492 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1493 method_file_map.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1494 package_dir_map.clear ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1495
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1496 #if defined (OCTAVE_USE_WINDOWS_API)
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1497 dir_mtime = sys::file_time (dir_name);
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1498 #else
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1499 dir_mtime = fs.mtime ().unix_time ();
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1500 #endif
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1501
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1502 dir_time_last_checked = sys::file_time ();
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1503
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1504 get_file_list (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1505
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1506 try
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1507 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1508 abs_dir_name = sys::canonicalize_file_name (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1509
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1510 // FIXME: nothing is ever removed from this cache of
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1511 // directory information, so there could be some resource
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1512 // problems. Perhaps it should be pruned from time to time.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1513
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1514 s_abs_dir_cache[abs_dir_name] = *this;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1515 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1516 catch (const execution_exception&)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1517 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1518 // Skip updating if we don't know where we are but don't treat
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1519 // it as an error.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1520
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1521 interpreter& interp = __get_interpreter__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1522
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1523 interp.recover_from_exception ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1524 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1525 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1526 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1527 {
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1528 #if ! defined (OCTAVE_USE_WINDOWS_API)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1529 std::string msg = fs.error ();
32090
7d663f770c5a load-path: Avoid using file_stat on Windows (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 32086
diff changeset
1530 #endif
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1531 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1532 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1533 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1534
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1535 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1536 load_path::dir_info::get_file_list (const std::string& d)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1537 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1538 string_vector flist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1539 std::string msg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1540
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1541 if (! sys::get_dirlist (d, flist, msg))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1542 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1543 warning ("load_path: %s: %s", d.c_str (), msg.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1544 return;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1545 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1546
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1547 octave_idx_type len = flist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1548
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1549 all_files.resize (len);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1550 fcn_files.resize (len);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1551
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1552 octave_idx_type all_files_count = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1553 octave_idx_type fcn_files_count = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1554
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1555 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1556 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1557 std::string fname = flist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1558
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1559 std::string full_name = sys::file_ops::concat (d, fname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1560
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1561 if (sys::dir_exists (full_name))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1562 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1563 if (fname == "private")
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1564 get_private_file_map (full_name);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1565 else if (fname[0] == '@')
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1566 get_method_file_map (full_name, fname.substr (1));
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1567 else if (fname[0] == '+')
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1568 get_package_dir (full_name, fname.substr (1));
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1569 }
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1570 else if (sys::file_exists (full_name))
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1571 {
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1572 all_files[all_files_count++] = fname;
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1573
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1574 std::size_t pos = fname.rfind ('.');
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1575
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1576 if (pos != std::string::npos)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1577 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1578 std::string ext = fname.substr (pos);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1579
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1580 if (ext == ".m" || ext == ".oct" || ext == ".mex")
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1581 {
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1582 std::string base = fname.substr (0, pos);
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1583
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1584 if (valid_identifier (base))
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1585 fcn_files[fcn_files_count++] = fname;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1586 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1587 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1588 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1589 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1590
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1591 all_files.resize (all_files_count);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1592 fcn_files.resize (fcn_files_count);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1593 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1594
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1595 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1596 load_path::dir_info::get_private_file_map (const std::string& d)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1597 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1598 private_file_map = get_fcn_files (d);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1599 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1600
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1601 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1602 load_path::dir_info::get_method_file_map (const std::string& d,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1603 const std::string& class_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1604 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1605 method_file_map[class_name].method_file_map = get_fcn_files (d);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1606
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1607 std::string pd = sys::file_ops::concat (d, "private");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1608
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
1609 if (sys::dir_exists (pd))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1610 method_file_map[class_name].private_file_map = get_fcn_files (pd);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1611 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1612
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1613 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1614 load_path::dir_info::get_package_dir (const std::string& d,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1615 const std::string& package_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1616 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1617 package_dir_map[package_name] = dir_info (d);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1618 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1619
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1620 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1621 load_path::package_info::move (const dir_info& di, bool at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1622 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1623 std::string dir_name = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1624
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1625 auto s = std::find (m_dir_list.begin (), m_dir_list.end (), dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1626
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1627 if (s != m_dir_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1628 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1629 m_dir_list.erase (s);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1630
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1631 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1632 m_dir_list.push_back (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1633 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1634 m_dir_list.push_front (dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1635 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1636
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1637 move_fcn_map (dir_name, di.fcn_files, at_end);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1638
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1639 // No need to move elements of private function map.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1640
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1641 move_method_map (dir_name, at_end);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1642 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1643
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1644 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1645 load_path::package_info::remove (const dir_info& di)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1646 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1647 std::string dir = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1648
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1649 string_vector fcn_files = di.fcn_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1650
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1651 m_dir_list.remove (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1652
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1653 remove_fcn_map (dir, fcn_files);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1654
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1655 remove_private_fcn_map (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1656
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1657 remove_method_map (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1658 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1659
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1660 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1661 load_path::package_info::display (std::ostream& os) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1662 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1663 os << "*** package_info: "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1664 << (m_package_name.empty () ? "<top-level>" : m_package_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1665 << "\n\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1666
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1667 for (const auto& dir : m_dir_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1668 os << dir << "\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1669 os << "\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1670
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1671 for (const auto& dir_fnlst : m_private_fcn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1672 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1673 os << "\n*** private functions in "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1674 << sys::file_ops::concat (dir_fnlst.first, "private")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1675 << ":\n\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1676
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1677 print_fcn_list (os, dir_fnlst.second);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1678 }
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
1679
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
1680 #if defined (DEBUG_LOAD_PATH)
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
1681
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1682 for (const auto& nm_filst : m_fcn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1683 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1684 os << nm_filst.first << ":\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1685
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1686 const file_info_list_type& file_info_list = nm_filst.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1687
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1688 for (const auto& finfo : file_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1689 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1690 os << " " << finfo.dir_name << " (";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1691
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1692 print_types (os, finfo.types);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1693
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1694 os << ")\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1695 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1696 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1697
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1698 for (const auto& cls_fnmap : m_method_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1699 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1700 os << "CLASS " << cls_fnmap.first << ":\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1701
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1702 const fcn_map_type& fm = cls_fnmap.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1703
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1704 for (const auto& nm_fnlst : m_fcn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1705 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1706 os << " " << nm_fnlst.first << ":\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1707
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1708 const file_info_list_type& file_info_list = nm_fnlst.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1709
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1710 for (const auto& finfo : file_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1711 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1712 os << " " << finfo.dir_name << " (";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1713
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1714 print_types (os, finfo.types);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1715
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1716 os << ")\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1717 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1718 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1719 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1720
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1721 os << "\n";
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
1722
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
1723 #endif
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1724 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1725
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1726 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1727 load_path::package_info::find_fcn (const std::string& fcn,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1728 std::string& dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1729 int type) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1730 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1731 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1732
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1733 // update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1734
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1735 if (fcn.length () > 0 && fcn[0] == '@')
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1736 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1737 std::size_t pos = fcn.find ('/');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1738
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1739 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1740 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1741 std::string class_name = fcn.substr (1, pos-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1742 std::string meth = fcn.substr (pos+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1743
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1744 retval = find_method (class_name, meth, dir_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1745 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1746 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1747 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1748 {
31864
359de694adce avoid unneccessary string initialization (patch #10218)
Petter Tomner <tomner@kth.se>
parents: 31838
diff changeset
1749 // Ensure that dir_name is empty if function is not found.
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1750 dir_name = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1751
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1752 const_fcn_map_iterator p = m_fcn_map.find (fcn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1753
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1754 if (p != m_fcn_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1755 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1756 const file_info_list_type& file_info_list = p->second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1757
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1758 for (const auto& fi : file_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1759 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1760 retval = sys::file_ops::concat (fi.dir_name, fcn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1761
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1762 if (check_file_type (retval, type, fi.types,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1763 fcn, "load_path::find_fcn"))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1764 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1765 dir_name = fi.dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1766 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1767 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1768 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1769 retval = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1770 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1771 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1772 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1773
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1774 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1775 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1776
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1777 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1778 load_path::package_info::find_private_fcn (const std::string& dir,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1779 const std::string& fcn,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1780 int type) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1781 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1782 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1783
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1784 // update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1785
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1786 const_private_fcn_map_iterator q = m_private_fcn_map.find (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1787
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1788 if (q != m_private_fcn_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1789 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1790 const dir_info::fcn_file_map_type& fcn_file_map = q->second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1791
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1792 dir_info::const_fcn_file_map_iterator p = fcn_file_map.find (fcn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1793
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1794 if (p != fcn_file_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1795 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1796 std::string fname
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1797 = sys::file_ops::concat (sys::file_ops::concat (dir, "private"),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1798 fcn);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1799
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1800 if (check_file_type (fname, type, p->second, fcn,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1801 "load_path::find_private_fcn"))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1802 retval = fname;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1803 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1804 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1805
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1806 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1807 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1808
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1809 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1810 load_path::package_info::find_method (const std::string& class_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1811 const std::string& meth,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1812 std::string& dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1813 int type) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1814 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1815 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1816
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1817 // update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1818
31864
359de694adce avoid unneccessary string initialization (patch #10218)
Petter Tomner <tomner@kth.se>
parents: 31838
diff changeset
1819 // Ensure that dir_name is empty if method is not found.
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1820 dir_name = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1821
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1822 const_method_map_iterator q = m_method_map.find (class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1823
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1824 if (q != m_method_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1825 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1826 const fcn_map_type& m = q->second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1827
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1828 const_fcn_map_iterator p = m.find (meth);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1829
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1830 if (p != m.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1831 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1832 const file_info_list_type& file_info_list = p->second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1833
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1834 for (const auto& fi : file_info_list)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1835 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1836 retval = sys::file_ops::concat (fi.dir_name, meth);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1837
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1838 bool found = check_file_type (retval, type, fi.types,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1839 meth, "load_path::find_method");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1840
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1841 if (found)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1842 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1843 dir_name = fi.dir_name;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1844 break;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1845 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1846 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1847 retval = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1848 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1849 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1850 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1851
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1852 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1853 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1854
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1855 std::list<std::string>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1856 load_path::package_info::methods (const std::string& class_name) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1857 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1858 std::list<std::string> retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1859
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1860 // update ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1861
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1862 const_method_map_iterator mtd_map_it = m_method_map.find (class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1863
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1864 if (mtd_map_it != m_method_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1865 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1866 for (const auto& nm_filst : mtd_map_it->second)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1867 retval.push_back (nm_filst.first);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1868 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1869
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1870 if (! retval.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1871 retval.sort ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1872
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1873 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1874 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1875
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1876 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1877 load_path::package_info::overloads (const std::string& meth,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1878 std::list<std::string>& l) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1879 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1880 for (const auto& cls_fnmap : m_method_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1881 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1882 const fcn_map_type& m = cls_fnmap.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1883
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1884 if (m.find (meth) != m.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1885 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1886 std::string class_name = cls_fnmap.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1887
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1888 if (! m_package_name.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1889 class_name = m_package_name + '.' + class_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1890
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1891 l.push_back (class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1892 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1893 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1894 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1895
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1896 string_vector
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31741
diff changeset
1897 load_path::package_info::fcn_names () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1898 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1899 std::size_t len = m_fcn_map.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1900
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1901 string_vector retval (len);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1902
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1903 octave_idx_type count = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1904
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1905 for (const auto& nm_filst : m_fcn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1906 retval[count++] = nm_filst.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1907
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1908 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1909 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1910
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1911 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1912 load_path::package_info::add_to_fcn_map (const dir_info& di,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1913 bool at_end, bool updating)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1914 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1915 std::string dir_name = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1916
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1917 string_vector fcn_files = di.fcn_files;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1918
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1919 octave_idx_type len = fcn_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1920
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1921 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1922 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1923 std::string fname = fcn_files[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1924
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1925 std::string ext;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1926 std::string base = fname;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1927
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1928 std::size_t pos = fname.rfind ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1929
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1930 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1931 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1932 base = fname.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1933 ext = fname.substr (pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1934 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1935
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1936 file_info_list_type& file_info_list = m_fcn_map[base];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1937
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1938 auto p = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1939
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1940 while (p != file_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1941 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1942 if (p->dir_name == dir_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1943 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1944
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1945 p++;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1946 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1947
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1948 int t = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1949 if (ext == ".m")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1950 t = load_path::M_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1951 else if (ext == ".oct")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1952 t = load_path::OCT_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1953 else if (ext == ".mex")
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1954 t = load_path::MEX_FILE;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1955
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1956 if (p == file_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1957 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1958 // Warn if a built-in or library function is being shadowed,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1959 // but not if we are just updating (rehashing) the list.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1960
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1961 if (! updating)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1962 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1963 if (file_info_list.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1964 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1965 symbol_table& symtab = __get_symbol_table__ ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1966
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1967 if (symtab.is_built_in_function_name (base))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1968 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1969 std::string fcn_path = sys::file_ops::concat (dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1970 fname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1971
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1972 warning_with_id ("Octave:shadowed-function",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1973 "function %s shadows a built-in function",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1974 fcn_path.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1975 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1976 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1977 else if (! at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1978 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1979 file_info& old = file_info_list.front ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1980
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1981 // FIXME: do we need to be more careful about the
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1982 // way we look for old.dir_name in sys_path to avoid
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1983 // partial matches?
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1984
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1985 // Don't warn about Contents.m files since we expect
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1986 // more than one to exist in the load path.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1987
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1988 if (fname != "Contents.m"
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1989 && s_sys_path.find (old.dir_name) != std::string::npos
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1990 && in_path_list (s_sys_path, old.dir_name))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1991 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1992 std::string fcn_path = sys::file_ops::concat (dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1993 fname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1994
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1995 warning_with_id ("Octave:shadowed-function",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1996 "function %s shadows a core library function",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1997 fcn_path.c_str ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1998 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1999 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2000 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2001
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2002 file_info fi (dir_name, t);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2003
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2004 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2005 file_info_list.push_back (fi);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2006 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2007 file_info_list.push_front (fi);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2008 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2009 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2010 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2011 file_info& fi = *p;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2012
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2013 fi.types |= t;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2014 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2015 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2016 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2017
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2018 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2019 load_path::package_info::add_to_private_fcn_map (const dir_info& di)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2020 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2021 dir_info::fcn_file_map_type private_file_map = di.private_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2022
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2023 if (! private_file_map.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2024 m_private_fcn_map[di.abs_dir_name] = private_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2025 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2026
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2027 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2028 load_path::package_info::add_to_method_map (const dir_info& di, bool at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2029 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2030 std::string dir_name = di.abs_dir_name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2031
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2032 // <CLASS_NAME, CLASS_INFO>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2033 dir_info::method_file_map_type method_file_map = di.method_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2034
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2035 for (const auto& cls_ci : method_file_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2036 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2037 std::string class_name = cls_ci.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2038
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2039 fcn_map_type& fm = m_method_map[class_name];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2040
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2041 std::string full_dir_name
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2042 = sys::file_ops::concat (dir_name, '@' + class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2043
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2044 const dir_info::class_info& ci = cls_ci.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2045
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2046 // <FCN_NAME, TYPES>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2047 const dir_info::fcn_file_map_type& m = ci.method_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2048
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2049 for (const auto& nm_typ : m)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2050 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2051 std::string base = nm_typ.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2052 int types = nm_typ.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2053
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2054 file_info_list_type& file_info_list = fm[base];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2055
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2056 auto p2 = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2057 while (p2 != file_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2058 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2059 if (p2->dir_name == full_dir_name)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2060 break;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2061
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2062 p2++;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2063 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2064
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2065 if (p2 == file_info_list.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2066 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2067 file_info fi (full_dir_name, types);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2068
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2069 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2070 file_info_list.push_back (fi);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2071 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2072 file_info_list.push_front (fi);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2073 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2074 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2075 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2076 // FIXME: is this possible?
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2077 file_info& fi = *p2;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2078
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2079 fi.types = types;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2080 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2081 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2082
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2083 // <FCN_NAME, TYPES>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2084 dir_info::fcn_file_map_type private_file_map = ci.private_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2085
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2086 if (! private_file_map.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2087 m_private_fcn_map[full_dir_name] = private_file_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2088 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2089 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2090
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2091 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2092 load_path::package_info::move_fcn_map (const std::string& dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2093 const string_vector& fcn_files,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2094 bool at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2095 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2096 octave_idx_type len = fcn_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2097
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2098 for (octave_idx_type k = 0; k < len; k++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2099 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2100 std::string fname = fcn_files[k];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2101
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2102 std::string ext;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2103 std::string base = fname;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2104
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2105 std::size_t pos = fname.rfind ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2106
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2107 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2108 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2109 base = fname.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2110 ext = fname.substr (pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2111 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2112
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2113 file_info_list_type& file_info_list = m_fcn_map[base];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2114
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2115 if (file_info_list.size () == 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2116 continue;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2117 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2118 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2119 for (auto fi_it = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2120 fi_it != file_info_list.end ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2121 fi_it++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2122 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2123 if (fi_it->dir_name == dir_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2124 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2125 file_info fi_tmp = *fi_it;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2126
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2127 file_info_list.erase (fi_it);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2128
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2129 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2130 file_info_list.push_back (fi_tmp);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2131 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2132 file_info_list.push_front (fi_tmp);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2133
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2134 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2135 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2136 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2137 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2138 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2139 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2140
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2141 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2142 load_path::package_info::move_method_map (const std::string& dir_name,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2143 bool at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2144 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2145 for (auto& cls_fnmap : m_method_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2146 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2147 std::string class_name = cls_fnmap.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2148
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2149 fcn_map_type& fn_map = cls_fnmap.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2150
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2151 std::string full_dir_name
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2152 = sys::file_ops::concat (dir_name, '@' + class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2153
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2154 for (auto& nm_filst : fn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2155 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2156 file_info_list_type& file_info_list = nm_filst.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2157
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2158 if (file_info_list.size () == 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2159 continue;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2160 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2161 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2162 for (auto fi_it = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2163 fi_it != file_info_list.end (); fi_it++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2164 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2165 if (fi_it->dir_name == full_dir_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2166 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2167 file_info fi_tmp = *fi_it;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2168
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2169 file_info_list.erase (fi_it);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2170
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2171 if (at_end)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2172 file_info_list.push_back (fi_tmp);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2173 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2174 file_info_list.push_front (fi_tmp);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2175
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2176 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2177 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2178 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2179 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2180 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2181 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2182 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2183
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2184 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2185 load_path::package_info::remove_fcn_map (const std::string& dir,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2186 const string_vector& fcn_files)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2187 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2188 octave_idx_type len = fcn_files.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2189
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2190 for (octave_idx_type k = 0; k < len; k++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2191 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2192 std::string fname = fcn_files[k];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2193
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2194 std::string ext;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2195 std::string base = fname;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2196
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2197 std::size_t pos = fname.rfind ('.');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2198
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2199 if (pos != std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2200 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2201 base = fname.substr (0, pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2202 ext = fname.substr (pos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2203 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2204
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2205 file_info_list_type& file_info_list = m_fcn_map[base];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2206
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2207 for (auto fi_it = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2208 fi_it != file_info_list.end ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2209 fi_it++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2210 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2211 if (fi_it->dir_name == dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2212 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2213 file_info_list.erase (fi_it);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2214
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2215 if (file_info_list.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2216 m_fcn_map.erase (fname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2217
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2218 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2219 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2220 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2221 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2222 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2223
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2224 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2225 load_path::package_info::remove_private_fcn_map (const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2226 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2227 auto p = m_private_fcn_map.find (dir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2228
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2229 if (p != m_private_fcn_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2230 m_private_fcn_map.erase (p);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2231 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2232
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2233 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2234 load_path::package_info::remove_method_map (const std::string& dir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2235 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2236 for (auto& cls_fnmap : m_method_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2237 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2238 std::string class_name = cls_fnmap.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2239
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2240 fcn_map_type& fn_map = cls_fnmap.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2241
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2242 std::string full_dir_name
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2243 = sys::file_ops::concat (dir, '@' + class_name);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2244
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2245 for (auto& nm_filst : fn_map)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2246 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2247 file_info_list_type& file_info_list = nm_filst.second;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2248
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2249 if (file_info_list.size () == 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2250 continue;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2251 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2252 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2253 for (auto fi_it = file_info_list.begin ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2254 fi_it != file_info_list.end (); fi_it++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2255 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2256 if (fi_it->dir_name == full_dir_name)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2257 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2258 file_info_list.erase (fi_it);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2259 // FIXME: if there are no other elements, we
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2260 // should remove this element of fn_map but calling
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2261 // erase here would invalidate the iterator fi_it.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2262
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2263 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2264 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2265 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2266 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2267 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2268 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2269 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2270
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2271 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2272 load_path::package_info::check_file_type (std::string& fname, int type,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2273 int possible_types,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2274 const std::string& fcn,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2275 const char *who) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2276 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2277 bool retval = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2278
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2279 if (type == load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2280 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2281 if ((type & possible_types) == load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2282 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2283 fname += ".oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2284 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2285 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2286 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2287 else if (type == load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2288 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2289 if ((type & possible_types) == load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2290 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2291 fname += ".m";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2292 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2293 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2294 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2295 else if (type == load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2296 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2297 if ((type & possible_types) == load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2298 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2299 fname += ".mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2300 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2301 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2302 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2303 else if (type == (load_path::M_FILE | load_path::OCT_FILE))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2304 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2305 if (possible_types & load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2306 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2307 fname += ".oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2308 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2309 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2310 else if (possible_types & load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2311 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2312 fname += ".m";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2313 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2314 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2315 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2316 else if (type == (load_path::M_FILE | load_path::MEX_FILE))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2317 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2318 if (possible_types & load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2319 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2320 fname += ".mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2321 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2322 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2323 else if (possible_types & load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2324 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2325 fname += ".m";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2326 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2327 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2328 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2329 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2330 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2331 if (possible_types & load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2332 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2333 fname += ".oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2334 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2335 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2336 else if (possible_types & load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2337 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2338 fname += ".mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2339 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2340 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2341 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2342 else if (type == (load_path::M_FILE | load_path::OCT_FILE
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2343 | load_path::MEX_FILE))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2344 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2345 if (possible_types & load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2346 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2347 fname += ".oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2348 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2349 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2350 else if (possible_types & load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2351 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2352 fname += ".mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2353 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2354 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2355 else if (possible_types & load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2356 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2357 fname += ".m";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2358 retval = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2359 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2360 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2361 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2362 error ("%s: %s: invalid type code = %d", who, fcn.c_str (), type);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2363
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2364 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2365 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2366
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2367 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2368 load_path::package_info::print_types (std::ostream& os, int types) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2369 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2370 bool printed_type = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2371
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2372 if (types & load_path::OCT_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2373 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2374 os << "oct";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2375 printed_type = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2376 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2377
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2378 if (types & load_path::MEX_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2379 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2380 if (printed_type)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2381 os << '|';
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2382 os << "mex";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2383 printed_type = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2384 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2385
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2386 if (types & load_path::M_FILE)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2387 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2388 if (printed_type)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2389 os << '|';
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2390 os << 'm';
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2391 printed_type = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2392 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2393 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2394
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2395 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2396 load_path::package_info::print_fcn_list (std::ostream& os,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2397 const load_path::dir_info::fcn_file_map_type& lst) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2398 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2399 for (const auto& nm_typ : lst)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2400 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2401 os << " " << nm_typ.first << " (";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2402
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2403 print_types (os, nm_typ.second);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2404
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2405 os << ")\n";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2406 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2407 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2408
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2409 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2410 genpath (const std::string& dirname, const string_vector& skip)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2411 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2412 std::string retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2413 string_vector dirlist;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2414 std::string msg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2415
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2416 if (! sys::get_dirlist (dirname, dirlist, msg))
23445
8e310ef0fa97 move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents: 23438
diff changeset
2417 return retval;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2418
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2419 retval = dirname;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2420
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2421 dirlist = dirlist.sort (false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2422
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2423 octave_idx_type len = dirlist.numel ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2424
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2425 for (octave_idx_type i = 0; i < len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2426 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2427 std::string elt = dirlist[i];
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2428
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2429 bool skip_p = (elt == "." || elt == ".." || elt[0] == '@'
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2430 || elt[0] == '+');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2431
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2432 if (! skip_p)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2433 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2434 for (octave_idx_type j = 0; j < skip.numel (); j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2435 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2436 skip_p = (elt == skip[j]);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2437 if (skip_p)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2438 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2439 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2440
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2441 if (! skip_p)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2442 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2443 std::string nm = sys::file_ops::concat (dirname, elt);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2444
32080
e9fdfebc6db0 Avoid using file_stat in libinterp/corefcn (bug #59711).
Markus Mützel <markus.muetzel@gmx.de>
parents: 31864
diff changeset
2445 if (sys::dir_exists (nm))
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2446 retval += (directory_path::path_sep_str ()
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2447 + genpath (nm, skip));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2448 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2449 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2450 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2451
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2452 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2453 }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2454
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2455 DEFUN (genpath, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2456 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2457 @deftypefn {} {@var{pathstr} =} genpath (@var{dir})
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2458 @deftypefnx {} {@var{pathstr} =} genpath (@var{dir}, @var{skipdir1}, @dots{})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2459 Return a path constructed from @var{dir} and all its subdirectories.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2460
24513
e61e26d1ede9 doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents: 24425
diff changeset
2461 The path does not include package directories (beginning with @samp{+}),
e61e26d1ede9 doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents: 24425
diff changeset
2462 old-style class directories (beginning with @samp{@@}), @file{private}
e61e26d1ede9 doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents: 24425
diff changeset
2463 directories, or any subdirectories of these types.
e61e26d1ede9 doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents: 24425
diff changeset
2464
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2465 If additional string parameters are given, the resulting path will exclude
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2466 directories with those names.
24513
e61e26d1ede9 doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents: 24425
diff changeset
2467 @seealso{path, addpath}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2468 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2469 {
20816
b16bcd7a2a33 Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents: 20812
diff changeset
2470 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
2471
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2472 if (nargin == 0)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2473 print_usage ();
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2474
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2475 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2476
10971
386aa01ca84c genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 10957
diff changeset
2477 if (nargin == 1)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2478 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20581
diff changeset
2479 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
2480
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2481 retval = genpath (dirname);
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2482 }
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2483 else
10971
386aa01ca84c genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 10957
diff changeset
2484 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20581
diff changeset
2485 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
2486
386aa01ca84c genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 10957
diff changeset
2487 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
2488
386aa01ca84c genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 10957
diff changeset
2489 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
2490 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
2491
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2492 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
2493 }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2494
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2495 return retval;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2496 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2497
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2498 DEFMETHOD (rehash, interp, , ,
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2499 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2500 @deftypefn {} {} rehash ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2501 Reinitialize Octave's load path directory cache.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2502 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2503 {
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2504 load_path& lp = interp.get_load_path ();
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2505
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2506 lp.rehash ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2507
21078
49852ff04747 maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents: 21021
diff changeset
2508 return ovl ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2509 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2510
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2511 DEFMETHOD (command_line_path, interp, args, ,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2512 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2513 @deftypefn {} {@var{pathstr} =} command_line_path ()
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2514 Return the path argument given to Octave at the command line when the
31593
0f93c3a756f7 doc: grammarcheck documentation ahead of 8.1 release.
Rik <rik@octave.org>
parents: 31144
diff changeset
2515 interpreter was started (@w{@env{--path @var{arg}}}).
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2516
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2517 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2518 @end deftypefn */)
8586
31ab3b83bc8a savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents: 8511
diff changeset
2519 {
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2520 if (! args.empty ())
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2521 print_usage ();
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2522
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2523 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2524
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2525 return ovl (lp.get_command_line_path ());
8586
31ab3b83bc8a savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents: 8511
diff changeset
2526 }
31ab3b83bc8a savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents: 8511
diff changeset
2527
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2528 DEFMETHOD (restoredefaultpath, interp, args, ,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2529 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2530 @deftypefn {} {@var{pathstr} =} restoredefaultpath ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2531 Restore Octave's path to its initial state at startup.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2532
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2533 The re-initialized path is returned as an output.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2534 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2535 @end deftypefn */)
7391
f071480b7eac [project @ 2008-01-17 07:50:33 by jwe]
jwe
parents: 7374
diff changeset
2536 {
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2537 if (! args.empty ())
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2538 print_usage ();
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2539
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2540 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2541
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2542 lp.initialize (true);
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2543
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2544 return ovl (lp.system_path ());
7391
f071480b7eac [project @ 2008-01-17 07:50:33 by jwe]
jwe
parents: 7374
diff changeset
2545 }
f071480b7eac [project @ 2008-01-17 07:50:33 by jwe]
jwe
parents: 7374
diff changeset
2546
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
2547 // 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
2548 // 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
2549 // 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
2550 // ~/.octaverc file
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
2551
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2552 DEFMETHOD (__pathorig__, interp, , ,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
2553 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2554 @deftypefn {} {@var{str} =} __pathorig__ ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2555 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2556 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2557 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2558 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2559
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2560 return ovl (lp.system_path ());
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2561 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2562
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2563 DEFMETHOD (path, interp, args, nargout,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2564 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2565 @deftypefn {} {} path ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2566 @deftypefnx {} {@var{str} =} path ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2567 @deftypefnx {} {@var{str} =} path (@var{path1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2568 Modify or display Octave's load path.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2569
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2570 If @var{nargin} and @var{nargout} are zero, display the elements of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2571 Octave's load path in an easy to read format.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2572
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2573 If @var{nargin} is zero and nargout is greater than zero, return the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2574 current load path.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2575
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2576 If @var{nargin} is greater than zero, concatenate the arguments,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2577 separating them with @code{pathsep}. Set the internal search path
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2578 to the result and return it.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2579
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2580 No checks are made for duplicate elements.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2581 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2582 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2583 {
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20816
diff changeset
2584 int nargin = args.length ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2585
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2586 string_vector argv = args.make_argv ("path");
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2587
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2588 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2589
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20816
diff changeset
2590 if (nargin > 0)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2591 {
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2592 std::string path = argv[1];
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2593
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20816
diff changeset
2594 for (int i = 2; i <= nargin; i++)
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2595 path += directory_path::path_sep_str () + argv[i];
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2596
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2597 lp.set (path, true);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2598
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2599 lp.rehash ();
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2600 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2601
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2602 if (nargout > 0)
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2603 return ovl (lp.path ());
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20816
diff changeset
2604 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
2605 {
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2606 octave_stdout <<
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2607 "\nOctave's search path contains the following directories:\n\n";
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2608
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2609 string_vector dirs = lp.dirs ();
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2610
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2611 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
2612
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
2613 octave_stdout << "\n";
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2614 }
20820
eed8ec05f1c8 always return value from DEFUN functions
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
2615
21125
8f76684324b5 maint: change "return octave_value ()" to "return ovl ()".
Rik <rik@octave.org>
parents: 21078
diff changeset
2616 return ovl ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2617 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2618
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2619 DEFMETHOD (addpath, interp, args, nargout,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2620 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2621 @deftypefn {} {} addpath (@var{dir1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2622 @deftypefnx {} {} addpath (@var{dir1}, @dots{}, @var{option})
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2623 @deftypefnx {} {@var{oldpath} =} addpath (@dots{})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2624 Add named directories to the function search path.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2625
27834
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2626 If @var{option} is @qcode{"-begin"} or 0 (the default), prepend the directory
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2627 name(s) to the current path. If @var{option} is @qcode{"-end"} or 1, append
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2628 the directory name(s) to the current path. Directories added to the path must
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2629 exist.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2630
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2631 In addition to accepting individual directory arguments, lists of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2632 directory names separated by @code{pathsep} are also accepted. For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2633
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2634 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2635 addpath ("dir1:/dir2:~/dir3")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2636 @end example
22387
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2637
27834
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2638 The newly added paths appear in the load path in the same order that they
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2639 appear in the arguments of @code{addpath}. When extending the load path to
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2640 the front, the last path in the list of arguments is added first. When
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2641 extending the load path to the end, the first path in the list of arguments
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2642 is added first.
ef6378f8e420 Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27745
diff changeset
2643
22387
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2644 For each directory that is added, and that was not already in the path,
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2645 @code{addpath} checks for the existence of a file named @file{PKG_ADD}
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2646 (note lack of .m extension) and runs it if it exists.
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2647
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2648 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2649 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2650 {
21953
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2651 // Originally written by Bill Denney and Etienne Grossman.
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2652 // Heavily modified and translated to C++ by jwe.
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2653
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2654 int nargin = args.length ();
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2655
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2656 if (nargin == 0)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2657 print_usage ();
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2658
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2659 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2660
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2661 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2662
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2663 if (nargout > 0)
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2664 retval = lp.path ();
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2665
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2666 bool append = false;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2667
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2668 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
2669
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2670 if (option_arg.is_string ())
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2671 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2672 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
2673
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2674 if (option == "-end")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2675 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2676 append = true;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2677 nargin--;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2678 }
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2679 else if (option == "-begin")
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2680 nargin--;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2681 }
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23519
diff changeset
2682 else if (option_arg.isnumeric ())
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2683 {
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2684 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
2685
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2686 if (val == 0)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2687 nargin--;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2688 else if (val == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2689 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2690 append = true;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2691 nargin--;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2692 }
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2693 else
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20820
diff changeset
2694 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
2695 }
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2696
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2697 bool need_to_update = false;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2698
21953
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2699 octave_value_list arglist (args.slice (0, nargin));
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2700 if (! append)
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2701 arglist.reverse ();
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2702
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2703 for (int i = 0; i < arglist.length (); i++)
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2704 {
21953
c46e2532d421 Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents: 21745
diff changeset
2705 std::string arg = arglist(i).xstring_value ("addpath: all arguments must be strings");
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2706
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2707 std::list<std::string> dir_elts = split_path (arg);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2708
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2709 if (! append)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2710 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
2711
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
2712 for (auto dir : dir_elts)
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2713 {
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
2714 // Remove duplicate directory separators
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
2715 auto it_start = dir.begin ();
24424
ceae837bc9ea Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents: 23219
diff changeset
2716 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
ceae837bc9ea Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents: 23219
diff changeset
2717 // In Windows, start check at second character (for UNC paths).
ceae837bc9ea Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents: 23219
diff changeset
2718 it_start++;
ceae837bc9ea Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents: 23219
diff changeset
2719 #endif
25951
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25376
diff changeset
2720 dir.erase (std::unique
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25376
diff changeset
2721 (it_start, dir.end (),
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25376
diff changeset
2722 [] (char l, char r)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2723 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2724 return l == r && sys::file_ops::is_dir_sep (l);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2725 }),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2726 dir.end ());
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2727
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2728 auto pos = dir.find_last_of (sys::file_ops::dir_sep_chars ());
23994
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2729 if (pos == std::string::npos)
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2730 {
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2731 if (! dir.empty () && dir[0] == '+')
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2732 warning_with_id ("Octave:addpath-pkg",
27497
5a0543de1e47 Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27474
diff changeset
2733 "addpath: package directories should not be "
5a0543de1e47 Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27474
diff changeset
2734 "added to path: %s\n", dir.c_str ());
23994
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2735 }
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2736 else
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2737 {
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2738 if (pos + 1 < dir.length () && dir[pos+1] == '+')
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2739 warning_with_id ("Octave:addpath-pkg",
27497
5a0543de1e47 Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27474
diff changeset
2740 "addpath: package directories should not be "
5a0543de1e47 Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27474
diff changeset
2741 "added to path: %s\n", dir.c_str ());
23994
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2742 }
8785b3717140 Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents: 23970
diff changeset
2743
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2744 if (append)
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2745 lp.append (dir, true);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2746 else
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2747 lp.prepend (dir, true);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2748
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2749 need_to_update = true;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2750 }
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2751 }
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2752
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2753 if (need_to_update)
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2754 lp.rehash ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2755
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2756 return retval;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2757 }
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2758
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2759 DEFMETHOD (rmpath, interp, args, nargout,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2760 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2761 @deftypefn {} {} rmpath (@var{dir1}, @dots{})
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2762 @deftypefnx {} {@var{oldpath} =} rmpath (@var{dir1}, @dots{})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2763 Remove @var{dir1}, @dots{} from the current function search path.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2764
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2765 In addition to accepting individual directory arguments, lists of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2766 directory names separated by @code{pathsep} are also accepted. For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2767
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2768 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2769 rmpath ("dir1:/dir2:~/dir3")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2770 @end example
22387
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2771
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2772 For each directory that is removed, @code{rmpath} checks for the
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2773 existence of a file named @file{PKG_DEL} (note lack of .m extension)
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2774 and runs it if it exists.
4e97eaf021e4 doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents: 22327
diff changeset
2775
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2776 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2777 @end deftypefn */)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2778 {
20812
d9ca869ca124 maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents: 20803
diff changeset
2779 // Originally written by Etienne Grossmann. Heavily modified and translated
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2780 // to C++ by jwe.
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2781
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2782 int nargin = args.length ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2783
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2784 if (nargin == 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2785 print_usage ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
2786
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2787 octave_value retval;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2788
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2789 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2790
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2791 if (nargout > 0)
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2792 retval = lp.path ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2793
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2794 bool need_to_update = false;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2795
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2796 for (int i = 0; i < nargin; i++)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2797 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2798 std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings");
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2799 std::list<std::string> dir_elts = split_path (arg);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2800
29248
37584021e209 load-path.cc: Avoid copying string for loop variable.
Markus Mützel <markus.muetzel@gmx.de>
parents: 28439
diff changeset
2801 for (const auto& dir : dir_elts)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2802 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2803 //dir = regexprep (dir_elts{j}, '//+', "/");
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
2804 //dir = regexprep (dir, '/$', "");
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2805
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2806 if (! lp.remove (dir))
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2807 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
2808 else
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2809 need_to_update = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2810 }
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2811 }
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2812
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20770
diff changeset
2813 if (need_to_update)
31741
e31eae72aecd move rehash_internal to private rehash function in load_path class
John W. Eaton <jwe@octave.org>
parents: 31740
diff changeset
2814 lp.rehash ();
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2815
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2816 return retval;
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents:
diff changeset
2817 }
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
2818
23519
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2819 DEFMETHOD (__dump_load_path__, interp, , ,
4fe410bd918d use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents: 23445
diff changeset
2820 doc: /* -*- texinfo -*-
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22094
diff changeset
2821 @deftypefn {} {} __dump_load_path__ ()
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30862
diff changeset
2822 Pretty print Octave path directories and the files within each directory.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21956
diff changeset
2823 @end deftypefn */)
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
2824 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
2825 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2826
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23418
diff changeset
2827 lp.display (octave_stdout);
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
2828
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20939
diff changeset
2829 return ovl ();
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16567
diff changeset
2830 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29937
diff changeset
2831
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31593
diff changeset
2832 OCTAVE_END_NAMESPACE(octave)