annotate libinterp/corefcn/help.cc @ 23065:7c7a61c2e0ed

Replace out-of-date __keywords__ with alias to iskeyword. * help.cc: Add #include "builtin-defun-decls.h". Sort list of #includes. Remove static variable keywords and keyword_names. * help.cc (make_name_list): New static variable keywords to hold output of Fiskeyword. New static variable key_len to hold number of keywords. * help.cc (F__keywords): Remove DEFUN and replace with DEFALIAS to iskeyword. * file-editor-tab.cc (update_lexer): Call Fiskeyword rather than F__keywords__. * help.m: Replace call to iskeyword with __keywords__.
author Rik <rik@octave.org>
date Tue, 17 Jan 2017 17:42:27 -0800
parents f97e22a9012a
children 4e3d47dc7e25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22295
diff changeset
3 Copyright (C) 1993-2016 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
27 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
28 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
29
5769
2b9a5ce46678 [project @ 2006-04-18 15:57:06 by jwe]
jwe
parents: 5768
diff changeset
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
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3408
diff changeset
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
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5738
diff changeset
34 #include <sstream>
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
35 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
36
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
37 #include "cmd-edit.h"
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
38 #include "file-ops.h"
6253
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 6243
diff changeset
39 #include "file-stat.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2900
diff changeset
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
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
42 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
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"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
47 #include "defun.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
48 #include "dirfns.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
49 #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
50 #include "errwarn.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
51 #include "help.h"
2177
0bddc913621b [project @ 1996-05-13 16:36:11 by jwe]
jwe
parents: 2124
diff changeset
52 #include "input.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
53 #include "interpreter.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
54 #include "load-path.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
55 #include "ov-fcn-handle.h"
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
56 #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
57 #include "ovl.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
58 #include "pager.h"
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
59 #include "parse.h"
1466
2f85a175308f [project @ 1995-09-22 07:48:59 by jwe]
jwe
parents: 1443
diff changeset
60 #include "pathsearch.h"
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
61 #include "procstream.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
62 #include "pt-pr-code.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
63 #include "quit.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
64 #include "sighandlers.h"
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
65 #include "symtab.h"
8672
2a49c32d4322 allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents: 8631
diff changeset
66 #include "unwind-prot.h"
242
742c4795aea9 [project @ 1993-11-30 21:26:43 by jwe]
jwe
parents: 240
diff changeset
67 #include "utils.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
68 #include "variables.h"
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3296
diff changeset
69 #include "version.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
70 #include <defaults.h>
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
71
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
72 // Name of the doc cache file specified on the command line.
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
73 // (--doc-cache-file file)
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
74 std::string Vdoc_cache_file;
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
75
14614
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
76 // 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
77 // 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
78 // (--texi-macros-file)
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
79 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
80
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
81 // Name of the info file specified on command line.
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
82 // (--info-file file)
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
83 std::string Vinfo_file;
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
84
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
85 // Name of the info reader we'd like to use.
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
86 // (--info-program program)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
87 std::string Vinfo_program;
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
88
3686
9507d6de9bbd [project @ 2000-06-29 16:30:44 by jwe]
jwe
parents: 3584
diff changeset
89 // Name of the makeinfo program to run.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
90 static std::string Vmakeinfo_program = "makeinfo";
3686
9507d6de9bbd [project @ 2000-06-29 16:30:44 by jwe]
jwe
parents: 3584
diff changeset
91
2189
d01936305d99 [project @ 1996-05-14 03:31:57 by jwe]
jwe
parents: 2177
diff changeset
92 // If TRUE, don't print additional help message in help and usage
d01936305d99 [project @ 1996-05-14 03:31:57 by jwe]
jwe
parents: 2177
diff changeset
93 // functions.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
94 static bool Vsuppress_verbose_help_message = false;
2189
d01936305d99 [project @ 1996-05-14 03:31:57 by jwe]
jwe
parents: 2177
diff changeset
95
22199
af0dca907fae get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents: 22198
diff changeset
96 const static char * const operators[] =
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
97 {
22199
af0dca907fae get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents: 22198
diff changeset
98 "!",
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 0
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
144 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
145
22199
af0dca907fae get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents: 22198
diff changeset
146 const static string_vector operator_names (operators);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
147
22172
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
148 // 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
149 // 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
150 static string_vector
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
151 local_functions (void)
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
152 {
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
153 string_vector retval;
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
154
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22974
diff changeset
155 octave_user_code *curr_fcn = octave::call_stack::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
156
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
157 if (! curr_fcn)
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
158 return retval;
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 // 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
161 while (curr_fcn->is_subfunction ())
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
162 curr_fcn = symbol_table::get_curr_fcn (curr_fcn->parent_fcn_scope ());
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
163
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
164 // Get subfunctions.
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
165 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
166
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
167 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
168 retval.resize (sz);
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 // Loop over them.
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
171 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
172 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
173 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
174
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
175 return retval;
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
176 }
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
177
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
178 // FIXME: It's not likely that this does the right thing now.
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
179
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
180 string_vector
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
181 make_name_list (void)
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
182 {
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
183 const static string_vector keywords = Fiskeyword ()(0).string_vector_value ();
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
184 const static int key_len = keywords.numel ();
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
185
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
186 const string_vector bif = symbol_table::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
187 const int bif_len = bif.numel ();
4009
27e461aed956 [project @ 2002-07-31 09:33:03 by jwe]
jwe
parents: 3917
diff changeset
188
12911
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12670
diff changeset
189 const string_vector cfl = symbol_table::cmdline_function_names ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
190 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
191
10500
8f27f368aba2 fix generating names for TAB completion
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
192 const string_vector lcl = symbol_table::variable_names ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
193 const int lcl_len = lcl.numel ();
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
194
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
195 const string_vector ffl = load_path::fcn_names ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
196 const int ffl_len = ffl.numel ();
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
197
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
198 const string_vector afl = autoloaded_functions ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
199 const int afl_len = afl.numel ();
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5576
diff changeset
200
22172
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
201 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
202 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
203
12911
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12670
diff changeset
204 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
205 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
206
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
207 string_vector list (total_len);
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
208
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
209 // Put all the symbols in one big list.
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
210
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
211 int j = 0;
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
212 int i = 0;
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
213
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
214 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
215 list[j++] = keywords[i];
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
216
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
217 for (i = 0; i < bif_len; i++)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
218 list[j++] = bif[i];
4009
27e461aed956 [project @ 2002-07-31 09:33:03 by jwe]
jwe
parents: 3917
diff changeset
219
12911
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12670
diff changeset
220 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
221 list[j++] = cfl[i];
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12670
diff changeset
222
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
223 for (i = 0; i < lcl_len; i++)
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
224 list[j++] = lcl[i];
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
225
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
226 for (i = 0; i < ffl_len; i++)
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
227 list[j++] = ffl[i];
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
228
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5576
diff changeset
229 for (i = 0; i < afl_len; i++)
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5576
diff changeset
230 list[j++] = afl[i];
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5576
diff changeset
231
22172
ed8a0c39e14c Allow TAB autocompletion of local functions in debug mode (bug #48317)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22156
diff changeset
232 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
233 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
234
3016
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
235 return list;
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
236 }
f512c16826d1 [project @ 1997-06-03 03:16:13 by jwe]
jwe
parents: 3014
diff changeset
237
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
238 static bool
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
239 looks_like_html (const std::string& msg)
3014
38de16594cb4 [project @ 1997-06-02 20:28:09 by jwe]
jwe
parents: 3013
diff changeset
240 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
241 const size_t p1 = msg.find ('\n');
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
242 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
243 // 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
244 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
245
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
246 return (p2 != std::string::npos);
2470
1e673f0648b5 [project @ 1996-11-05 21:46:06 by jwe]
jwe
parents: 2442
diff changeset
247 }
3014
38de16594cb4 [project @ 1997-06-02 20:28:09 by jwe]
jwe
parents: 3013
diff changeset
248
38de16594cb4 [project @ 1997-06-02 20:28:09 by jwe]
jwe
parents: 3013
diff changeset
249 static bool
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
250 looks_like_texinfo (const std::string& msg, size_t& p1)
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
251 {
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
252 p1 = msg.find ('\n');
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
253
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
254 std::string t = msg.substr (0, p1);
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
255
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
256 if (p1 == std::string::npos)
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
257 p1 = 0;
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
258
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
259 size_t p2 = t.find ("-*- texinfo -*-");
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
260
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
261 return (p2 != std::string::npos);
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
262 }
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
263
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
264 static bool
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
265 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
266 std::string& w, bool& symbol_found)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
267 {
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
268 bool retval = false;
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
269
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
270 octave_value val = symbol_table::find_function (nm);
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
271
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
272 if (val.is_defined ())
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
273 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
274 octave_function *fcn = val.function_value ();
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
275
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
276 if (fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
277 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
278 symbol_found = true;
5399
db34dff19947 [project @ 2005-06-17 21:16:20 by jwe]
jwe
parents: 5393
diff changeset
279
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
280 h = fcn->doc_string ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
281
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
282 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
283
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
284 w = fcn->fcn_file_name ();
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
285
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
286 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
287 w = fcn->is_user_function ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
288 ? "command-line function" : "built-in function";
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
289 }
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
290 }
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
291
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
292 return retval;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
293 }
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
294
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
295 static bool
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
296 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
297 std::string& file, bool& symbol_found)
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
298 {
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
299 bool retval = false;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
300
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
301 h = get_help_from_file (nm, symbol_found, file);
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
302
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
303 if (h.length () > 0)
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
304 retval = true;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
305
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
306 return retval;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
307 }
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
308
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
309 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
310 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
311 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
312 {
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
313 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
314 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
315
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
316 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
317 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
318
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
319 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
320 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
321
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 // 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
323 // 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
324 // 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
325
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 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
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 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
329
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 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
331
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 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
333 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
334
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 // 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
336 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
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 (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
339 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
340
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 // 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
342 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
343 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
344
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 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
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 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
348 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
349 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
350 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
351 {
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 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
353 {
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 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
355 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
356 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
357 }
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 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
359 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
360 }
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
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 // 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
363 // 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
364 // 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
365 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
366 && (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
367 && 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
368 ; // 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
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 // 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
371 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
372 && (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
373 && 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
374 ; // 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
375
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 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
377
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 // 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
379 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
380
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 // 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
382 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
383
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
384 // 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
385 std::streamoff len;
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
386
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
387 if (! file.eof ())
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
388 len = file.tellg () - beg - 1;
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
389 else
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
390 {
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
391 file.seekg (0, file.end);
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
392 len = file.tellg () - beg - 1;
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
393 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
394 }
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
395
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 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
397 }
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
398
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
399 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
400 }
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
401
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
402 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
403
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
404 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
405 {
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
406 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
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 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
409 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
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 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
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 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
414
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 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
416 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
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 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
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 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
421 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
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 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
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 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
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 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
428
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 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
430 }
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 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
433 }
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
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
435 std::string
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
436 raw_help (const std::string& nm, bool& symbol_found)
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
437 {
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
438 std::string h;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
439 std::string w;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
440 std::string f;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
441
20138
4ff975c58584 Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents: 19872
diff changeset
442 bool found;
4ff975c58584 Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents: 19872
diff changeset
443
4ff975c58584 Check error_state before searching for help text (bug #44934).
Rik <rik@octave.org>
parents: 19872
diff changeset
444 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
445
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20581
diff changeset
446 if (! found)
22199
af0dca907fae get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents: 22198
diff changeset
447 found = raw_help_from_file (nm, h, f, symbol_found);
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
448
22884
0419dec5d5c1 allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents: 22822
diff changeset
449 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
450
4e9241cf59db find help for function aliases again (bug #49687)
John W. Eaton <jwe@octave.org>
parents: 22556
diff changeset
451 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
452 {
0419dec5d5c1 allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents: 22822
diff changeset
453 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
454
0419dec5d5c1 allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents: 22822
diff changeset
455 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
456 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
457
0419dec5d5c1 allow external docstrings from .oct files to be found again (bug #49687)
John W. Eaton <jwe@octave.org>
parents: 22822
diff changeset
458 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
459 }
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
460
6243
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
461 return h;
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
462 }
7924a9086c08 [project @ 2007-01-17 21:47:50 by jwe]
jwe
parents: 6138
diff changeset
463
15470
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
464 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
465 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
466 @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
467 @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
468 @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
469 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
470 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
471
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
472 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
473 @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
474 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
475 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
476 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
477 @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
478 @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
479
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
480 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
481 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
482 @end deftypefn */)
15470
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
483 {
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
484 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
485 }
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
486
1140
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
487 static void
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
488 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
489 std::string& format)
1140
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
490 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
491 bool symbol_found = false;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
492 text = raw_help (name, symbol_found);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
493
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
494 format = "Not found";
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
495 if (symbol_found)
1140
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
496 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
497 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
498 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
499 {
52956d669506 Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents: 8630
diff changeset
500 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
501 }
52956d669506 Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents: 8630
diff changeset
502 else if (looks_like_texinfo (text, idx))
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
503 {
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
504 format = "texinfo";
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
505 text.erase (0, idx);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
506 }
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
507 else if (looks_like_html (text))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
508 {
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
509 format = "html";
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
510 }
5399
db34dff19947 [project @ 2005-06-17 21:16:20 by jwe]
jwe
parents: 5393
diff changeset
511 else
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
512 {
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
513 format = "plain text";
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
514 }
1140
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
515 }
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
516 }
26d986865487 [project @ 1995-02-26 03:23:43 by jwe]
jwe
parents: 1118
diff changeset
517
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
518 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
519 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
520 @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
521 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
522
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
523 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
524 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
525 @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
526 @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
527 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
528 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
529 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
530 print_usage ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
531
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
532 const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
533
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
534 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
535
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
536 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
537
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
538 return ovl (text, format);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
539 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
540
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
541 static void
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
542 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
543 std::string& format)
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
544 {
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
545 bool symbol_found = false;
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
546
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
547 std::string f;
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
548
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
549 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
550
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
551 format = "Not found";
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
552 if (symbol_found)
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
553 {
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
554 size_t idx = -1;
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
555 if (text.empty ())
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 format = "Not documented";
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 else if (looks_like_texinfo (text, idx))
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 format = "texinfo";
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
562 text.erase (0, idx);
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
563 }
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
564 else if (looks_like_html (text))
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 format = "html";
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
567 }
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
568 else
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
569 {
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
570 format = "plain text";
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
571 }
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 }
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
574
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
575 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
576 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
577 @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
578 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
579
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
580 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
581 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
582 @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
583 @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
584 @end deftypefn */)
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
585 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
586 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
587 print_usage ();
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
588
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
589 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
590
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
591 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
592
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
593 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
594
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
595 return ovl (text, format);
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
596 }
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
597
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
598 // 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
599
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
600 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
601 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
602 @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
603 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
604 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
605 {
22199
af0dca907fae get help text for operators and keywords from docstrings file
John W. Eaton <jwe@octave.org>
parents: 22198
diff changeset
606 return ovl (Cell (operator_names));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
607 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
608
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
609 // 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
610 // 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
611 // 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
612
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
613 DEFALIAS (__keywords__, iskeyword)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
614
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
615 // 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
616
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
617 DEFUN (__builtins__, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
618 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
619 @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
620 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
621 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
622 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
623 const string_vector bif = symbol_table::built_in_function_names ();
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
624
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21100
diff changeset
625 return ovl (Cell (bif));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
626 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
627
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
628 DEFUN (localfunctions, 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
629 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
630 @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
631 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
632 file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
633
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
634 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
635 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
636 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
637
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
638 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
639 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
640
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
641 @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
642 @end deftypefn */)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
643 {
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
644 if (args.length () != 0)
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
645 print_usage ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
646
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
647 Cell retval;
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
648
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
649 // Find the main function we are in.
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22974
diff changeset
650 octave_user_code *parent_fcn = octave::call_stack::debug_user_code ();
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
651
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
652 if (! parent_fcn)
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
653 return ovl (retval);
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
654
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
655 // 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
656 // 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
657 // 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
658 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
659 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
660
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
661 size_t sz = names.size ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
662 retval.resize (dim_vector (sz, 1));
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
663
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
664 // loop over them.
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
665 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
666 for (const auto& nm : names)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
667 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22825
diff changeset
668 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
669 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
670 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
671 }
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
672
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
673 return ovl (retval);
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
674 }
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 /*
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
677 %!test
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
678 %! f = tempname (".", "oct_");
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
679 %! fcn_name = f(3:end);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
680 %! f = [f ".m"];
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
681 %! unwind_protect
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
682 %! fid = fopen (f, "w+");
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
683 %! 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
684 %! 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
685 %! 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
686 %! fclose (fid);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
687 %! d = eval (fcn_name);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
688 %! 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
689 %! assert (d{1} (3), 4);
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
690 %! assert (d{2} (3), 6);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
691 %! unwind_protect_cleanup
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
692 %! unlink (f);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
693 %! end_unwind_protect
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
694 */
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
695
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
696 static std::string
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
697 do_which (const std::string& name, std::string& type)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
698 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
699 std::string file;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
700
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20996
diff changeset
701 type = "";
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
702
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
703 octave_value val = symbol_table::find_function (name);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
704
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
705 if (name.find_first_of ('.') == std::string::npos)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
706 {
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
707 if (val.is_defined ())
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
708 {
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
709 octave_function *fcn = val.function_value ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
710
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
711 if (fcn)
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
712 {
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
713 file = fcn->fcn_file_name ();
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
714
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
715 if (file.empty ())
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
716 {
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
717 if (fcn->is_user_function ())
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
718 type = "command-line function";
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
719 else
15005
74c7265c057a fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents: 14766
diff changeset
720 {
74c7265c057a fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents: 14766
diff changeset
721 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
722 type = "built-in function";
74c7265c057a fix failure with function handles caused by changeset ea6997657614
John W. Eaton <jwe@octave.org>
parents: 14766
diff changeset
723 }
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
724 }
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
725 else
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
726 type = val.is_user_script ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
727 ? std::string ("script") : std::string ("function");
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
728 }
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 else
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
731 {
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
732 // 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
733
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
734 file = load_path::find_fcn_file (name);
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
735 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7272
diff changeset
736 }
8672
2a49c32d4322 allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents: 8631
diff changeset
737 else
2a49c32d4322 allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents: 8631
diff changeset
738 {
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
739 // File query.
8672
2a49c32d4322 allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents: 8631
diff changeset
740
9416
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
741 // For compatibility: "file." queries "file".
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
742 if (name.size () > 1 && name[name.size () - 1] == '.')
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
743 file = load_path::find_file (name.substr (0, name.size () - 1));
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
744 else
2cc47338e427 allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
745 file = load_path::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
746
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
747 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
748 }
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
749
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
750 return file;
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
751 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
752
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
753 std::string
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
754 do_which (const std::string& name)
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
755 {
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
756 std::string retval;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
757
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
758 std::string type;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
759
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
760 retval = do_which (name, type);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
761
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
762 return retval;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
763 }
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
764
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
765 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
766 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
767 @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
768 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
769 @end deftypefn */)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
770 {
20996
20bd3d4fabad Clean up instances of make_argv().
Rik <rik@octave.org>
parents: 20940
diff changeset
771 string_vector argv = args.make_argv ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
772
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
773 int nargin = argv.numel ();
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
774
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
775 octave_map m (dim_vector (1, nargin));
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
776
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
777 Cell names (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
778 Cell files (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
779 Cell types (1, nargin);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
780
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
781 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
782 {
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
783 std::string name = argv[i];
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
784
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
785 std::string type;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
786
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
787 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
788
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
789 names(i) = name;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
790 files(i) = file;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
791 types(i) = type;
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
792 }
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
793
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
794 m.assign ("name", names);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
795 m.assign ("file", files);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
796 m.assign ("type", types);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
797
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
798 return ovl (m);
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
799 }
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
800
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
801 // 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
802 inline bool
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
803 file_is_in_dir (const std::string filename, const std::string dir)
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
804 {
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
805 if (filename.find (dir) == 0)
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
806 {
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
807 const int dir_len = dir.size ();
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
808 const int filename_len = filename.size ();
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
809 const int max_allowed_seps = octave::sys::file_ops::is_dir_sep (dir[dir_len-1]) ? 0
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
810 : 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
811
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
812 int num_seps = 0;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
813 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
814 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
815 num_seps++;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
816
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
817 return (num_seps <= max_allowed_seps);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
818 }
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
819 else
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
820 return false;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
821 }
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
822
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
823 // 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
824 // 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
825 // the current path.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
826
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
827 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
828 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
829 @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
830 @deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory})
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
831 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
832
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
833 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
834 in that directory.
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
835 @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
836 @end deftypefn */)
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
837 {
8863
34a821854961 pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents: 8861
diff changeset
838 octave_value retval;
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
839
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
840 if (args.length () == 0)
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
841 {
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
842 // Get list of all functions
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
843 string_vector ffl = load_path::fcn_names ();
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
844 string_vector afl = autoloaded_functions ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
845
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
846 retval = Cell (ffl.append (afl));
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
847 }
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
848 else
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
849 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
850 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
851
19403
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19269
diff changeset
852 string_vector fl = load_path::files (dir, true);
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19269
diff changeset
853
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
854 // 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
855 // 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
856 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
857
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
858 retval = Cell (fl);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
859 }
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
860
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
861 return retval;
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
862 }
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
863
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
864 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
865 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
866 @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
867 @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
868 @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
869 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
870 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
871
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
872 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
873 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
874 @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
875 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
876 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
877 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
878 @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
879 @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
880
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
881 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
882 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
883 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
884 @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
885 @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
886 @end deftypefn */)
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
887 {
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
888 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file);
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
889 }
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
890
14614
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
891 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
892 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
893 @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
894 @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
895 @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
896 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
897 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
898 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
899
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 is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
901 @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
902 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
903 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
904 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
905 @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
906 @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
907
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
908 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
909 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
910 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
911 @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
912 @end deftypefn */)
14614
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
913 {
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
914 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
915 }
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
916
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
917 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
918 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
919 @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
920 @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
921 @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
922 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
923 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
924
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
925 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
926 @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
927 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
928 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
929 @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
930 @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
931
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
932 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
933 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
934 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
935 @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
936 @end deftypefn */)
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
937 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
938 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file);
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
939 }
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
940
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
941 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
942 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
943 @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
944 @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
945 @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
946 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
947 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
948
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
949 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
950 @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
951 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
952 @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
953 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
954 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
955 @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
956 @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
957
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
958 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
959 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
960 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
961 @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
962 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
963 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
964 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
965 }
3686
9507d6de9bbd [project @ 2000-06-29 16:30:44 by jwe]
jwe
parents: 3584
diff changeset
966
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
967 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
968 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
969 @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
970 @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
971 @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
972 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
973 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
974 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
975
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
976 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
977
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
978 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
979 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
980 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
981 @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
982 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
983 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
984 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
985 }
2202
31b62b7c5d2d [project @ 1996-05-15 06:07:11 by jwe]
jwe
parents: 2189
diff changeset
986
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
987 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
988 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
989 @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
990 @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
991 @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
992 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
993 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
994 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
995
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
996 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
997 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
998 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
999 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1000 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1001 return SET_INTERNAL_VARIABLE (suppress_verbose_help_message);
2189
d01936305d99 [project @ 1996-05-14 03:31:57 by jwe]
jwe
parents: 2177
diff changeset
1002 }
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22337
diff changeset
1003