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