Mercurial > octave
annotate libinterp/corefcn/help.cc @ 23693:b9378eff6d13
move symbol_table class inside octave namespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 25 Jun 2017 09:50:51 -0400 |
parents | b0e9c030f063 |
children | b2d55b52ee51 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22556
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
1 | 25 #endif |
26 | |
1343 | 27 #include <cstdlib> |
28 #include <cstring> | |
29 | |
5769 | 30 #include <algorithm> |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
31 #include <fstream> |
3503 | 32 #include <iostream> |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
33 #include <map> |
5765 | 34 #include <sstream> |
1755 | 35 #include <string> |
36 | |
3295 | 37 #include "cmd-edit.h" |
38 #include "file-ops.h" | |
6253 | 39 #include "file-stat.h" |
2926 | 40 #include "oct-env.h" |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
19152
diff
changeset
|
41 #include "oct-locbuf.h" |
1755 | 42 #include "str-vec.h" |
43 | |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
44 #include "Cell.h" |
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
45 #include "builtin-defun-decls.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
46 #include "call-stack.h" |
23466
5da300c55e89
use "" instead of <> for including defaults.h and version.h
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
47 #include "defaults.h" |
1352 | 48 #include "defun.h" |
49 #include "dirfns.h" | |
50 #include "error.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
51 #include "errwarn.h" |
1352 | 52 #include "help.h" |
2177 | 53 #include "input.h" |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
54 #include "interpreter-private.h" |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
55 #include "interpreter.h" |
5832 | 56 #include "load-path.h" |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
57 #include "ov-fcn-handle.h" |
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
58 #include "ov-usr-fcn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
59 #include "ovl.h" |
1352 | 60 #include "pager.h" |
3018 | 61 #include "parse.h" |
1466 | 62 #include "pathsearch.h" |
3295 | 63 #include "procstream.h" |
7336 | 64 #include "pt-pr-code.h" |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
65 #include "quit.h" |
529 | 66 #include "sighandlers.h" |
67 #include "symtab.h" | |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
68 #include "unwind-prot.h" |
242 | 69 #include "utils.h" |
1352 | 70 #include "variables.h" |
3301 | 71 #include "version.h" |
529 | 72 |
8861 | 73 // Name of the doc cache file specified on the command line. |
74 // (--doc-cache-file file) | |
75 std::string Vdoc_cache_file; | |
76 | |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
77 // Name of the file containing local Texinfo macros that are prepended |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
78 // to doc strings before processing. |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
79 // (--texi-macros-file) |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
80 std::string Vtexi_macros_file; |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
81 |
2202 | 82 // Name of the info file specified on command line. |
83 // (--info-file file) | |
3523 | 84 std::string Vinfo_file; |
2202 | 85 |
86 // Name of the info reader we'd like to use. | |
87 // (--info-program program) | |
5794 | 88 std::string Vinfo_program; |
2202 | 89 |
3686 | 90 // Name of the makeinfo program to run. |
5794 | 91 static std::string Vmakeinfo_program = "makeinfo"; |
3686 | 92 |
2189 | 93 // If TRUE, don't print additional help message in help and usage |
94 // functions. | |
5794 | 95 static bool Vsuppress_verbose_help_message = false; |
2189 | 96 |
22199
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
97 const static char * const operators[] = |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
98 { |
22199
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
99 "!", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
100 "~", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
101 "!=", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
102 "~=", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
103 "\"", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
104 "#", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
105 "%", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
106 "#{", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
107 "%{", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
108 "#}", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
109 "%}", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
110 "...", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
111 "&", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
112 "&&", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
113 "'", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
114 "(", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
115 ")", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
116 "*", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
117 "**", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
118 "^", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
119 "+", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
120 "++", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
121 ",", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
122 "-", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
123 "--", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
124 ".'", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
125 ".*", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
126 ".**", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
127 ".^", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
128 "./", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
129 "/", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
130 ".\\", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
131 "\\", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
132 ":", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
133 ";", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
134 "<", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
135 "<=", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
136 "=", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
137 "==", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
138 ">", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
139 ">=", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
140 "[", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
141 "]", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
142 "|", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
143 "||", |
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
144 0 |
1 | 145 }; |
146 | |
22199
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
147 const static string_vector operator_names (operators); |
1 | 148 |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
149 // Return a vector of all functions from this file, |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
150 // for use in command line auto-completion. |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
151 static string_vector |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
152 local_functions (void) |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
153 { |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
154 string_vector retval; |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
155 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
156 octave::call_stack& cs = octave::__get_call_stack__ ("local_functions"); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
157 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
158 octave_user_code *curr_fcn = cs.caller_user_code (); |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
159 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
160 if (! curr_fcn) |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
161 return retval; |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
162 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
163 // All subfunctions are listed in the top-level function of this file. |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
164 while (curr_fcn->is_subfunction ()) |
23604
b0e9c030f063
eliminate some warnings introduced by recent changes
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
165 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
166 octave::symbol_table::scope *pscope = curr_fcn->parent_fcn_scope (); |
23604
b0e9c030f063
eliminate some warnings introduced by recent changes
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
167 curr_fcn = pscope->function (); |
b0e9c030f063
eliminate some warnings introduced by recent changes
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
168 } |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
169 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
170 // Get subfunctions. |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
171 const std::list<std::string> names = curr_fcn->subfunction_names (); |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
172 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
173 size_t sz = names.size (); |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
174 retval.resize (sz); |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
175 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
176 // Loop over them. |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
177 size_t i = 0; |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22825
diff
changeset
|
178 for (const auto& nm : names) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22825
diff
changeset
|
179 retval(i++) = nm; |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
180 |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
181 return retval; |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
182 } |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
183 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
184 // FIXME: It's not likely that this does the right thing now. |
3016 | 185 |
186 string_vector | |
187 make_name_list (void) | |
188 { | |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
189 const static string_vector keywords = Fiskeyword ()(0).string_vector_value (); |
23085
dffa2b8c9482
maint: strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
190 const static int key_len = keywords.numel (); |
3016 | 191 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
192 octave::symbol_table& symtab = octave::__get_symbol_table__ ("make_name_list"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
193 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
194 const string_vector bif = symtab.built_in_function_names (); |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
195 const int bif_len = bif.numel (); |
4009 | 196 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
197 const string_vector cfl = symtab.cmdline_function_names (); |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
198 const int cfl_len = cfl.numel (); |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12670
diff
changeset
|
199 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
200 const string_vector lcl = symtab.variable_names (); |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
201 const int lcl_len = lcl.numel (); |
3016 | 202 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
203 octave::load_path& lp = octave::__get_load_path__ ("make_name_list"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
204 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
205 const string_vector ffl = lp.fcn_names (); |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
206 const int ffl_len = ffl.numel (); |
3016 | 207 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23065
diff
changeset
|
208 const string_vector afl = octave::autoloaded_functions (); |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20172
diff
changeset
|
209 const int afl_len = afl.numel (); |
5592 | 210 |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
211 const string_vector lfl = local_functions (); |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
212 const int lfl_len = lfl.numel (); |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
213 |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12670
diff
changeset
|
214 const int total_len |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
215 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len; |
3016 | 216 |
217 string_vector list (total_len); | |
218 | |
219 // Put all the symbols in one big list. | |
220 | |
221 int j = 0; | |
222 int i = 0; | |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
223 |
3016 | 224 for (i = 0; i < key_len; i++) |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
225 list[j++] = keywords[i]; |
3016 | 226 |
7336 | 227 for (i = 0; i < bif_len; i++) |
228 list[j++] = bif[i]; | |
4009 | 229 |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12670
diff
changeset
|
230 for (i = 0; i < cfl_len; i++) |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12670
diff
changeset
|
231 list[j++] = cfl[i]; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12670
diff
changeset
|
232 |
3016 | 233 for (i = 0; i < lcl_len; i++) |
234 list[j++] = lcl[i]; | |
235 | |
236 for (i = 0; i < ffl_len; i++) | |
237 list[j++] = ffl[i]; | |
238 | |
5592 | 239 for (i = 0; i < afl_len; i++) |
240 list[j++] = afl[i]; | |
241 | |
22172
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
242 for (i = 0; i < lfl_len; i++) |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
243 list[j++] = lfl[i]; |
ed8a0c39e14c
Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
22156
diff
changeset
|
244 |
3016 | 245 return list; |
246 } | |
247 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
248 static bool |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
249 looks_like_html (const std::string& msg) |
3014 | 250 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
251 const size_t p1 = msg.find ('\n'); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
252 std::string t = msg.substr (0, p1); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
253 // FIXME: this comparison should be case-insensitive |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
254 const size_t p2 = t.find ("<html"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
255 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
256 return (p2 != std::string::npos); |
2470 | 257 } |
3014 | 258 |
259 static bool | |
3523 | 260 looks_like_texinfo (const std::string& msg, size_t& p1) |
3295 | 261 { |
262 p1 = msg.find ('\n'); | |
263 | |
3523 | 264 std::string t = msg.substr (0, p1); |
3295 | 265 |
8021 | 266 if (p1 == std::string::npos) |
3295 | 267 p1 = 0; |
268 | |
269 size_t p2 = t.find ("-*- texinfo -*-"); | |
270 | |
8021 | 271 return (p2 != std::string::npos); |
3295 | 272 } |
273 | |
3355 | 274 static bool |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
275 raw_help_from_symbol_table (const std::string& nm, std::string& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
276 std::string& w, bool& symbol_found) |
3355 | 277 { |
278 bool retval = false; | |
279 | |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
280 octave::symbol_table& symtab = octave::__get_symbol_table__ ("raw_help_from_symbol_table"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
281 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
282 octave_value val = symtab.find_function (nm); |
3355 | 283 |
7336 | 284 if (val.is_defined ()) |
3355 | 285 { |
7336 | 286 octave_function *fcn = val.function_value (); |
287 | |
288 if (fcn) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
289 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
290 symbol_found = true; |
5399 | 291 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
292 h = fcn->doc_string (); |
7336 | 293 |
8631
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
294 retval = true; |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
295 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
296 w = fcn->fcn_file_name (); |
6243 | 297 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
298 if (w.empty ()) |
8631
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
299 w = fcn->is_user_function () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
300 ? "command-line function" : "built-in function"; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
301 } |
6243 | 302 } |
3355 | 303 |
6243 | 304 return retval; |
305 } | |
306 | |
307 static bool | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
308 raw_help_from_file (const std::string& nm, std::string& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
309 std::string& file, bool& symbol_found) |
6243 | 310 { |
311 bool retval = false; | |
312 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23065
diff
changeset
|
313 h = octave::get_help_from_file (nm, symbol_found, file); |
6243 | 314 |
315 if (h.length () > 0) | |
316 retval = true; | |
317 | |
318 return retval; | |
319 } | |
320 | |
321 static bool | |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
322 raw_help_from_docstrings_file (const std::string& nm, std::string& h, |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
323 bool& symbol_found) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
324 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
325 typedef std::pair<std::streampos, std::streamoff> txt_limits_type; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
326 typedef std::map<std::string, txt_limits_type> help_txt_map_type; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
327 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
328 static help_txt_map_type help_txt_map; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
329 static bool initialized = false; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
330 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
331 h = ""; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
332 symbol_found = false; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
333 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
334 // FIXME: Should we cache the timestamp of the file and reload the |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
335 // offsets if it changes? Or just warn about that? Or just ignore |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
336 // it, and assume it won't change? |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
337 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
338 if (! initialized) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
339 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
340 std::string fname = Vbuilt_in_docstrings_file; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
341 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
342 std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
343 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
344 if (! file) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
345 error ("failed to open docstrings file: %s", fname.c_str ()); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
346 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
347 // Ignore header; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
348 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
349 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
350 if (file.eof ()) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
351 error ("invalid built-in-docstrings file!"); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
352 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
353 // FIXME: eliminate fixed buffer size. |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
354 size_t bufsize = 1000; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
355 OCTAVE_LOCAL_BUFFER (char, buf, bufsize); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
356 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
357 while (! file.eof ()) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
358 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
359 std::string name; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
360 int i = 0; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
361 int c; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
362 while (file && (c = file.get ()) != std::istream::traits_type::eof ()) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
363 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
364 if (c == '\n' || c == '\r') |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
365 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
366 buf[i] = '\0'; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
367 name = buf; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
368 break; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
369 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
370 else |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
371 buf[i++] = c; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
372 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
373 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
374 // Skip @c FILENAME which is part of current DOCSTRINGS |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
375 // syntax. This may disappear if a specific format for |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
376 // docstring files is developed. |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
377 while (file |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
378 && (c = file.get ()) != std::istream::traits_type::eof () |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
379 && c != '\n' && c != '\r') |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
380 ; // skip text |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
381 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
382 // skip newline characters |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
383 while (file |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
384 && (c = file.get ()) != std::istream::traits_type::eof () |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
385 && c == '\n' && c == '\r') |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
386 ; // skip text |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
387 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
388 file.unget (); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
389 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
390 // Position of beginning of help text. |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
391 std::streampos beg = file.tellg (); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
392 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
393 // Skip help text. |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
394 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d); |
22295
12f1d273d22a
maint: Remove trailing spaces from code.
Rik <rik@octave.org>
parents:
22199
diff
changeset
|
395 |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
396 // Position of end of help text. |
22556
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
397 std::streamoff len; |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
398 |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
399 if (! file.eof ()) |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
400 len = file.tellg () - beg - 1; |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
401 else |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
402 { |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
403 file.seekg (0, file.end); |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
404 len = file.tellg () - beg - 1; |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
405 file.setstate (file.eofbit); // reset eof flag |
121e9639b604
doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
406 } |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
407 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
408 help_txt_map[name] = txt_limits_type (beg, len); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
409 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
410 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
411 initialized = true; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
412 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
413 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
414 help_txt_map_type::const_iterator it = help_txt_map.find (nm); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
415 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
416 if (it != help_txt_map.end ()) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
417 { |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
418 txt_limits_type txt_limits = it->second; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
419 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
420 std::streampos beg = txt_limits.first; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
421 std::streamoff len = txt_limits.second; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
422 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
423 std::string fname = Vbuilt_in_docstrings_file; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
424 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
425 std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
426 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
427 if (! file) |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
428 error ("failed to open docstrings file: %s", fname.c_str ()); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
429 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
430 file.seekg (beg); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
431 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
432 size_t txt_len = len; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
433 OCTAVE_LOCAL_BUFFER (char, buf, txt_len + 1); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
434 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
435 file.read (buf, txt_len); |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
436 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
437 buf[txt_len] = '\0'; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
438 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
439 h = buf; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
440 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
441 symbol_found = true; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
442 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
443 |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
444 return symbol_found; |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
445 } |
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
446 |
6243 | 447 std::string |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
448 raw_help (const std::string& nm, bool& symbol_found) |
6243 | 449 { |
450 std::string h; | |
451 std::string w; | |
452 std::string f; | |
453 | |
20138
4ff975c58584
Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents:
19872
diff
changeset
|
454 bool found; |
4ff975c58584
Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents:
19872
diff
changeset
|
455 |
4ff975c58584
Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents:
19872
diff
changeset
|
456 found = raw_help_from_symbol_table (nm, h, w, symbol_found); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
457 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
458 if (! found) |
22199
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
459 found = raw_help_from_file (nm, h, f, symbol_found); |
6243 | 460 |
22884
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
461 bool external_doc = h.compare (0, 12, "external-doc") == 0; |
22822
4e9241cf59db
find help for function aliases again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22556
diff
changeset
|
462 |
4e9241cf59db
find help for function aliases again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22556
diff
changeset
|
463 if (! found || external_doc) |
22884
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
464 { |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
465 std::string tmp_nm = nm; |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
466 |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
467 if (external_doc && h.length () > 12 && h[12] == ':') |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
468 tmp_nm = h.substr (13); |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
469 |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
470 raw_help_from_docstrings_file (tmp_nm, h, symbol_found); |
0419dec5d5c1
allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents:
22822
diff
changeset
|
471 } |
22198
f6181638f6c5
search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents:
22172
diff
changeset
|
472 |
6243 | 473 return h; |
474 } | |
475 | |
15470
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
476 DEFUN (built_in_docstrings_file, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
477 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
478 @deftypefn {} {@var{val} =} built_in_docstrings_file () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
479 @deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
480 @deftypefnx {} {} built_in_docstrings_file (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
481 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
482 file containing docstrings for built-in Octave functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
483 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
484 The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
485 @file{@var{octave-home}/share/octave/@var{version}/etc/built-in-docstrings}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
486 in which @var{octave-home} is the root directory of the Octave installation, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
487 and @var{version} is the Octave version number. The default value may be |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
488 overridden by the environment variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
489 @w{@env{OCTAVE_BUILT_IN_DOCSTRINGS_FILE}}, or the command line argument |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
490 @option{--built-in-docstrings-file FNAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
491 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
492 Note: This variable is only used when Octave is initializing itself. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
493 Modifying it during a running session of Octave will have no effect. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
494 @end deftypefn */) |
15470
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
495 { |
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
496 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (built_in_docstrings_file); |
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
497 } |
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
498 |
1140 | 499 static void |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
500 do_get_help_text (const std::string& name, std::string& text, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
501 std::string& format) |
1140 | 502 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
503 bool symbol_found = false; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
504 text = raw_help (name, symbol_found); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
505 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
506 format = "Not found"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
507 if (symbol_found) |
1140 | 508 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
509 size_t idx = -1; |
8631
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
510 if (text.empty ()) |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
511 { |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
512 format = "Not documented"; |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
513 } |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
514 else if (looks_like_texinfo (text, idx)) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
515 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
516 format = "texinfo"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
517 text.erase (0, idx); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
518 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
519 else if (looks_like_html (text)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
520 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
521 format = "html"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
522 } |
5399 | 523 else |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
524 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
525 format = "plain text"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
526 } |
1140 | 527 } |
528 } | |
529 | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
530 DEFUN (get_help_text, args, , |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
531 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
532 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text (@var{name}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
533 Return the raw help text of function @var{name}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
534 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
535 The raw help text is returned in @var{text} and the format in @var{format} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
536 The format is a string which is one of @qcode{"texinfo"}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
537 @qcode{"html"}, or @qcode{"plain text"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
538 @seealso{get_help_text_from_file} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
539 @end deftypefn */) |
529 | 540 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
541 if (args.length () != 1) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
542 print_usage (); |
1755 | 543 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
544 const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string"); |
529 | 545 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20922
diff
changeset
|
546 std::string text, format; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
547 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
548 do_get_help_text (name, text, format); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
549 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20922
diff
changeset
|
550 return ovl (text, format); |
529 | 551 } |
552 | |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
553 static void |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
554 do_get_help_text_from_file (const std::string& fname, std::string& text, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
555 std::string& format) |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
556 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
557 bool symbol_found = false; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
558 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
559 std::string f; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
560 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
561 raw_help_from_file (fname, text, f, symbol_found); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
562 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
563 format = "Not found"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
564 if (symbol_found) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
565 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
566 size_t idx = -1; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
567 if (text.empty ()) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
568 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
569 format = "Not documented"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
570 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
571 else if (looks_like_texinfo (text, idx)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
572 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
573 format = "texinfo"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
574 text.erase (0, idx); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
575 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
576 else if (looks_like_html (text)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
577 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
578 format = "html"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
579 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
580 else |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
581 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
582 format = "plain text"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
583 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
584 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
585 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
586 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
587 DEFUN (get_help_text_from_file, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
588 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
589 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
590 Return the raw help text from the file @var{fname}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
591 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
592 The raw help text is returned in @var{text} and the format in @var{format} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
593 The format is a string which is one of @qcode{"texinfo"}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
594 @qcode{"html"}, or @qcode{"plain text"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
595 @seealso{get_help_text} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
596 @end deftypefn */) |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
597 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
598 if (args.length () != 1) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
599 print_usage (); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
600 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
601 const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string"); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
602 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20922
diff
changeset
|
603 std::string text, format; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
604 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
605 do_get_help_text_from_file (fname, text, format); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
606 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20922
diff
changeset
|
607 return ovl (text, format); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
608 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
609 |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
610 // Return a cell array of strings containing the names of all operators. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
611 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
612 DEFUN (__operators__, , , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
613 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
614 @deftypefn {} {} __operators__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
615 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
616 @end deftypefn */) |
3355 | 617 { |
22199
af0dca907fae
get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents:
22198
diff
changeset
|
618 return ovl (Cell (operator_names)); |
3355 | 619 } |
620 | |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
621 // Return a cell array of strings containing the names of all keywords. |
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
622 // iskeyword() function is located in lex.ll and is based on what the parser |
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
623 // thinks is a keyword. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
624 |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
625 DEFALIAS (__keywords__, iskeyword) |
581 | 626 |
23065
7c7a61c2e0ed
Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents:
23052
diff
changeset
|
627 // Return a cell array of strings with the names of all builtin functions. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
628 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
629 DEFMETHOD (__builtins__, interp, , , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
630 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
631 @deftypefn {} {} __builtins__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
632 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
633 @end deftypefn */) |
3355 | 634 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
635 octave::symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
636 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
637 const string_vector bif = symtab.built_in_function_names (); |
3355 | 638 |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
639 return ovl (Cell (bif)); |
3355 | 640 } |
641 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
642 DEFMETHOD (localfunctions, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
643 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
644 @deftypefn {} {} localfunctions () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
645 Return a list of all local functions, i.e., subfunctions, within the current |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
646 file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
647 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
648 The return value is a column cell array of function handles to all local |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
649 functions accessible from the function from which @code{localfunctions} is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
650 called. Nested functions are @emph{not} included in the list. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
651 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
652 If the call is from the command line, an anonymous function, or a script, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
653 the return value is an empty cell array. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
654 |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
655 @seealso{functions} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
656 @end deftypefn */) |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
657 { |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
658 if (args.length () != 0) |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
659 print_usage (); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
660 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
661 Cell retval; |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
662 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
663 // Find the main function we are in. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
664 octave::call_stack& cs = interp.get_call_stack (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
665 octave_user_code *parent_fcn = cs.debug_user_code (); |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
666 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
667 if (! parent_fcn) |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
668 return ovl (retval); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
669 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
670 // Find the subfunctions of this function. |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
671 // 1) subfunction_names contains only valid subfunctions |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
672 // 2) subfunctions contains both nested functions and subfunctions |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
673 const std::list<std::string> names = parent_fcn->subfunction_names (); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
674 const std::map<std::string, octave_value> h = parent_fcn->subfunctions (); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
675 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
676 size_t sz = names.size (); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
677 retval.resize (dim_vector (sz, 1)); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
678 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
679 // loop over them. |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
680 size_t i = 0; |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22825
diff
changeset
|
681 for (const auto& nm : names) |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
682 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22825
diff
changeset
|
683 std::map<std::string, octave_value>::const_iterator nm_fcn = h.find (nm); |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
684 if (nm_fcn != h.end ()) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22825
diff
changeset
|
685 retval(i++) = octave_value (new octave_fcn_handle (nm_fcn->second, nm)); |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
686 } |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
687 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
688 return ovl (retval); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
689 } |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
690 |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
691 /* |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
692 %!test |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
693 %! f = tempname (".", "oct_"); |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
694 %! fcn_name = f(3:end); |
22016
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
695 %! f = [f ".m"]; |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
696 %! unwind_protect |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
697 %! fid = fopen (f, "w+"); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
698 %! fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
699 %! fprintf (fid, "function z = b(x)\n z = x+1; end\n"); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
700 %! fprintf (fid, "function z = c(x)\n z = 2*x; end\n"); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
701 %! fclose (fid); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
702 %! d = eval (fcn_name); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
703 %! assert (size (d), [2, 1]); |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
704 %! assert (d{1} (3), 4); |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22885
diff
changeset
|
705 %! assert (d{2} (3), 6); |
22016
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
706 %! unwind_protect_cleanup |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
707 %! unlink (f); |
d4ce10f57918
Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents:
21966
diff
changeset
|
708 %! end_unwind_protect |
21765
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
709 */ |
23a610a3f001
Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21733
diff
changeset
|
710 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
711 static std::string |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
712 do_which (const std::string& name, std::string& type) |
3355 | 713 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
714 std::string file; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
715 |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20996
diff
changeset
|
716 type = ""; |
3355 | 717 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
718 octave::symbol_table& symtab = octave::__get_symbol_table__ ("do_which"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
719 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
720 octave_value val = symtab.find_function (name); |
7336 | 721 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
722 if (name.find_first_of ('.') == std::string::npos) |
3355 | 723 { |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
724 if (val.is_defined ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
725 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
726 octave_function *fcn = val.function_value (); |
7336 | 727 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
728 if (fcn) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
729 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
730 file = fcn->fcn_file_name (); |
3355 | 731 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
732 if (file.empty ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
733 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
734 if (fcn->is_user_function ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
735 type = "command-line function"; |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
736 else |
15005
74c7265c057a
fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents:
14766
diff
changeset
|
737 { |
74c7265c057a
fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents:
14766
diff
changeset
|
738 file = fcn->src_file_name (); |
74c7265c057a
fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents:
14766
diff
changeset
|
739 type = "built-in function"; |
74c7265c057a
fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents:
14766
diff
changeset
|
740 } |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
741 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
742 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
743 type = val.is_user_script () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
744 ? std::string ("script") : std::string ("function"); |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
745 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
746 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
747 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
748 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
749 // We might find a file that contains only a doc string. |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
750 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
751 octave::load_path& lp = octave::__get_load_path__ ("do_which"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
752 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
753 file = lp.find_fcn_file (name); |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
754 } |
7336 | 755 } |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
756 else |
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
757 { |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
758 // File query. |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
759 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
760 octave::load_path& lp = octave::__get_load_path__ ("do_which"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
761 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
762 // For compatibility: "file." queries "file". |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
763 if (name.size () > 1 && name[name.size () - 1] == '.') |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
764 file = lp.find_file (name.substr (0, name.size () - 1)); |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
765 else |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
766 file = lp.find_file (name); |
17829
c2d9d42f4fe1
which: return the full path to a regular file (bug #40332)
Mike Miller <mtmiller@ieee.org>
parents:
17787
diff
changeset
|
767 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
768 file = octave::sys::env::make_absolute (file); |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
769 } |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
770 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
771 return file; |
3355 | 772 } |
773 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
774 std::string |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
775 do_which (const std::string& name) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
776 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
777 std::string retval; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
778 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
779 std::string type; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
780 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
781 retval = do_which (name, type); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
782 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
783 return retval; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
784 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
785 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
786 DEFUN (__which__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
787 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
788 @deftypefn {} {} __which__ (@var{name}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
789 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
790 @end deftypefn */) |
581 | 791 { |
20996 | 792 string_vector argv = args.make_argv (); |
1755 | 793 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
794 int nargin = argv.numel (); |
581 | 795 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
796 octave_map m (dim_vector (1, nargin)); |
581 | 797 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
798 Cell names (1, nargin); |
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
799 Cell files (1, nargin); |
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
800 Cell types (1, nargin); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
801 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
802 for (int i = 0; i < nargin; i++) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
803 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
804 std::string name = argv[i]; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
805 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
806 std::string type; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
807 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
808 std::string file = do_which (name, type); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
809 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
810 names(i) = name; |
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
811 files(i) = file; |
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
812 types(i) = type; |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
813 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
814 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
815 m.assign ("name", names); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
816 m.assign ("file", files); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
817 m.assign ("type", types); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20714
diff
changeset
|
818 |
20922
49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
819 return ovl (m); |
581 | 820 } |
821 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
822 // FIXME: Are we sure this function always does the right thing? |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
823 inline bool |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
824 file_is_in_dir (const std::string filename, const std::string dir) |
5447 | 825 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
826 if (filename.find (dir) == 0) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
827 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
828 const int dir_len = dir.size (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
829 const int filename_len = filename.size (); |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23445
diff
changeset
|
830 const int max_allowed_seps = |
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23445
diff
changeset
|
831 (octave::sys::file_ops::is_dir_sep (dir[dir_len-1]) ? 0 : 1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
832 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
833 int num_seps = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
834 for (int i = dir_len; i < filename_len; i++) |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
835 if (octave::sys::file_ops::is_dir_sep (filename[i])) |
20714
7b6d8c19dab0
Cuddle increment (++) and decrement (--) operators with variable in question.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
836 num_seps++; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
837 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
838 return (num_seps <= max_allowed_seps); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
839 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
840 else |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
841 return false; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
842 } |
5447 | 843 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
844 // Return a cell array of strings containing the names of all |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
845 // functions available in DIRECTORY. If no directory is given, search |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
846 // the current path. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
847 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
848 DEFUN (__list_functions__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
849 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
850 @deftypefn {} {@var{retval} =} __list_functions__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
851 @deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory}) |
22337
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
852 Return a list of all functions (.m and .oct functions) in the load path. |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
853 |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
854 If the optional argument @var{directory} is given then list only the functions |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
855 in that directory. |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
856 @seealso{path} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
857 @end deftypefn */) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
858 { |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
859 octave_value retval; |
5447 | 860 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
861 octave::load_path& lp = octave::__get_load_path__ ("__list_functions__"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
862 |
22337
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
863 if (args.length () == 0) |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
864 { |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
865 // Get list of all functions |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
866 string_vector ffl = lp.fcn_names (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23065
diff
changeset
|
867 string_vector afl = octave::autoloaded_functions (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
868 |
22337
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
869 retval = Cell (ffl.append (afl)); |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
870 } |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
871 else |
5447 | 872 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
873 std::string dir = args(0).xstring_value ("__list_functions__: DIRECTORY argument must be a string"); |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
874 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
875 string_vector fl = lp.files (dir, true); |
19403
03067dab10ca
Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents:
19269
diff
changeset
|
876 |
22337
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
877 // Return a sorted list with unique entries (in case of .m and .oct |
77c209d63b75
Update __list_functions__ internal function.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
878 // versions of the same function in a given directory, for example). |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
879 fl.sort (true); |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
880 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
881 retval = Cell (fl); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
882 } |
5447 | 883 |
884 return retval; | |
885 } | |
886 | |
8861 | 887 DEFUN (doc_cache_file, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
888 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
889 @deftypefn {} {@var{val} =} doc_cache_file () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
890 @deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
891 @deftypefnx {} {} doc_cache_file (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
892 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
893 Octave documentation cache file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
894 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
895 A cache file significantly improves the performance of the @code{lookfor} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
896 command. The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
897 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
898 in which @var{octave-home} is the root directory of the Octave installation, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
899 and @var{version} is the Octave version number. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
900 The default value may be overridden by the environment variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
901 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
902 @option{--doc-cache-file FNAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
903 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
904 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
905 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
906 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
907 @seealso{doc_cache_create, lookfor, info_program, doc, help, makeinfo_program} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
908 @seealso{lookfor} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
909 @end deftypefn */) |
8861 | 910 { |
911 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file); | |
912 } | |
913 | |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
914 DEFUN (texi_macros_file, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
915 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
916 @deftypefn {} {@var{val} =} texi_macros_file () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
917 @deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
918 @deftypefnx {} {} texi_macros_file (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
919 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
920 file containing Texinfo macros that are prepended to documentation strings |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
921 before they are passed to makeinfo. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
922 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
923 The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
924 @file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
925 in which @var{octave-home} is the root directory of the Octave installation, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
926 and @var{version} is the Octave version number. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
927 The default value may be overridden by the environment variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
928 @w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
929 @option{--texi-macros-file FNAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
930 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
931 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
932 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
933 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
934 @seealso{makeinfo_program} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
935 @end deftypefn */) |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
936 { |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
937 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (texi_macros_file); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
938 } |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14360
diff
changeset
|
939 |
5794 | 940 DEFUN (info_file, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
941 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
942 @deftypefn {} {@var{val} =} info_file () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
943 @deftypefnx {} {@var{old_val} =} info_file (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
944 @deftypefnx {} {} info_file (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
945 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
946 Octave info file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
947 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
948 The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
949 @file{@var{octave-home}/info/octave.info}, in |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
950 which @var{octave-home} is the root directory of the Octave installation. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
951 The default value may be overridden by the environment variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
952 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
953 @option{--info-file FNAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
954 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
955 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
956 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
957 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
958 @seealso{info_program, doc, help, makeinfo_program} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
959 @end deftypefn */) |
2202 | 960 { |
5794 | 961 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file); |
2202 | 962 } |
963 | |
5794 | 964 DEFUN (info_program, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
965 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
966 @deftypefn {} {@var{val} =} info_program () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
967 @deftypefnx {} {@var{old_val} =} info_program (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
968 @deftypefnx {} {} info_program (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
969 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
970 info program to run. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
971 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
972 The default value is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
973 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
974 in which @var{octave-home} is the root directory of the Octave installation, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
975 @var{version} is the Octave version number, and @var{arch} is the system |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
976 type (for example, @code{i686-pc-linux-gnu}). The default value may be |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
977 overridden by the environment variable |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
978 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
979 @option{--info-program NAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
980 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
981 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
982 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
983 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
984 @seealso{info_file, doc, help, makeinfo_program} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
985 @end deftypefn */) |
5794 | 986 { |
987 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program); | |
988 } | |
3686 | 989 |
5794 | 990 DEFUN (makeinfo_program, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
991 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
992 @deftypefn {} {@var{val} =} makeinfo_program () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
993 @deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
994 @deftypefnx {} {} makeinfo_program (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
995 Query or set the internal variable that specifies the name of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
996 program that Octave runs to format help text containing |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
997 Texinfo markup commands. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
998 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
999 The default value is @code{makeinfo}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1000 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1001 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1002 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1003 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1004 @seealso{texi_macros_file, info_file, info_program, doc, help} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1005 @end deftypefn */) |
5794 | 1006 { |
1007 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program); | |
1008 } | |
2202 | 1009 |
5794 | 1010 DEFUN (suppress_verbose_help_message, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1011 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1012 @deftypefn {} {@var{val} =} suppress_verbose_help_message () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1013 @deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1014 @deftypefnx {} {} suppress_verbose_help_message (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1015 Query or set the internal variable that controls whether Octave |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1016 will add additional help information to the end of the output from |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1017 the @code{help} command and usage messages for built-in commands. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1018 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1019 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1020 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1021 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21921
diff
changeset
|
1022 @end deftypefn */) |
5794 | 1023 { |
1024 return SET_INTERNAL_VARIABLE (suppress_verbose_help_message); | |
2189 | 1025 } |