annotate libinterp/interpfcn/load-path.cc @ 16203:127cccb037bf

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