Mercurial > hg > octave-lyh
comparison libinterp/interpfcn/help.cc @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/interpfcn/help.cc@60ff2cef569d |
children | bf0857c789f4 |
comparison
equal
deleted
inserted
replaced
15194:0f0b795044c3 | 15195:2fc554ffbc28 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1993-2012 John W. Eaton | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cstdlib> | |
28 #include <cstring> | |
29 | |
30 #include <algorithm> | |
31 #include <iostream> | |
32 #include <fstream> | |
33 #include <sstream> | |
34 #include <string> | |
35 | |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
38 | |
39 #include "cmd-edit.h" | |
40 #include "file-ops.h" | |
41 #include "file-stat.h" | |
42 #include "oct-env.h" | |
43 #include "str-vec.h" | |
44 | |
45 #include <defaults.h> | |
46 #include "defun.h" | |
47 #include "dirfns.h" | |
48 #include "error.h" | |
49 #include "gripes.h" | |
50 #include "help.h" | |
51 #include "input.h" | |
52 #include "load-path.h" | |
53 #include "oct-obj.h" | |
54 #include "ov-usr-fcn.h" | |
55 #include "pager.h" | |
56 #include "parse.h" | |
57 #include "pathsearch.h" | |
58 #include "procstream.h" | |
59 #include "pt-pr-code.h" | |
60 #include "sighandlers.h" | |
61 #include "symtab.h" | |
62 #include "syswait.h" | |
63 #include "toplev.h" | |
64 #include "unwind-prot.h" | |
65 #include "utils.h" | |
66 #include "variables.h" | |
67 #include "version.h" | |
68 #include "quit.h" | |
69 | |
70 // Name of the doc cache file specified on the command line. | |
71 // (--doc-cache-file file) | |
72 std::string Vdoc_cache_file; | |
73 | |
74 // Name of the file containing local Texinfo macros that are prepended | |
75 // to doc strings before processing. | |
76 // (--texi-macros-file) | |
77 std::string Vtexi_macros_file; | |
78 | |
79 // Name of the info file specified on command line. | |
80 // (--info-file file) | |
81 std::string Vinfo_file; | |
82 | |
83 // Name of the info reader we'd like to use. | |
84 // (--info-program program) | |
85 std::string Vinfo_program; | |
86 | |
87 // Name of the makeinfo program to run. | |
88 static std::string Vmakeinfo_program = "makeinfo"; | |
89 | |
90 // If TRUE, don't print additional help message in help and usage | |
91 // functions. | |
92 static bool Vsuppress_verbose_help_message = false; | |
93 | |
94 #include <map> | |
95 | |
96 typedef std::map<std::string, std::string> map_type; | |
97 typedef map_type::value_type pair_type; | |
98 typedef map_type::const_iterator map_iter; | |
99 | |
100 template<typename T, std::size_t z> | |
101 std::size_t | |
102 size (T const (&)[z]) | |
103 { | |
104 return z; | |
105 } | |
106 | |
107 const static pair_type operators[] = | |
108 { | |
109 pair_type ("!", | |
110 "-*- texinfo -*-\n\ | |
111 @deftypefn {Operator} {} !\n\ | |
112 Logical 'not' operator.\n\ | |
113 @seealso{~, not}\n\ | |
114 @end deftypefn"), | |
115 | |
116 pair_type ("~", | |
117 "-*- texinfo -*-\n\ | |
118 @deftypefn {Operator} {} ~\n\ | |
119 Logical 'not' operator.\n\ | |
120 @seealso{!, not}\n\ | |
121 @end deftypefn"), | |
122 | |
123 pair_type ("!=", | |
124 "-*- texinfo -*-\n\ | |
125 @deftypefn {Operator} {} !=\n\ | |
126 Logical 'not equals' operator.\n\ | |
127 @seealso{~=, ne}\n\ | |
128 @end deftypefn"), | |
129 | |
130 pair_type ("~=", | |
131 "-*- texinfo -*-\n\ | |
132 @deftypefn {Operator} {} ~=\n\ | |
133 Logical 'not equals' operator.\n\ | |
134 @seealso{!=, ne}\n\ | |
135 @end deftypefn"), | |
136 | |
137 pair_type ("\"", | |
138 "-*- texinfo -*-\n\ | |
139 @deftypefn {Operator} {} \"\n\ | |
140 String delimiter.\n\ | |
141 @end deftypefn"), | |
142 | |
143 pair_type ("#", | |
144 "-*- texinfo -*-\n\ | |
145 @deftypefn {Operator} {} #\n\ | |
146 Begin comment character.\n\ | |
147 @seealso{%, #@\\{}\n\ | |
148 @end deftypefn"), | |
149 | |
150 pair_type ("%", | |
151 "-*- texinfo -*-\n\ | |
152 @deftypefn {Operator} {} %\n\ | |
153 Begin comment character.\n\ | |
154 @seealso{#, %@\\{}\n\ | |
155 @end deftypefn"), | |
156 | |
157 pair_type ("#{", | |
158 "-*- texinfo -*-\n\ | |
159 @deftypefn {Operator} {} #@{\n\ | |
160 Begin block comment. There must be nothing else, other than\n\ | |
161 whitespace, in the line both before and after @code{#@{}.\n\ | |
162 It is possible to nest block comments.\n\ | |
163 @seealso{%@\\{, #@\\}, #}\n\ | |
164 @end deftypefn"), | |
165 | |
166 pair_type ("%{", | |
167 "-*- texinfo -*-\n\ | |
168 @deftypefn {Operator} {} %@{\n\ | |
169 Begin block comment. There must be nothing else, other than\n\ | |
170 whitespace, in the line both before and after @code{%@{}.\n\ | |
171 It is possible to nest block comments.\n\ | |
172 @seealso{#@\\{, %@\\}, %}\n\ | |
173 @end deftypefn"), | |
174 | |
175 pair_type ("#}", | |
176 "-*- texinfo -*-\n\ | |
177 @deftypefn {Operator} {} #@}\n\ | |
178 Close block comment. There must be nothing else, other than\n\ | |
179 whitespace, in the line both before and after @code{#@}}.\n\ | |
180 It is possible to nest block comments.\n\ | |
181 @seealso{%@\\}, #@\\{, #}\n\ | |
182 @end deftypefn"), | |
183 | |
184 pair_type ("%}", | |
185 "-*- texinfo -*-\n\ | |
186 @deftypefn {Operator} {} %@}\n\ | |
187 Close block comment. There must be nothing else, other than\n\ | |
188 whitespace, in the line both before and after @code{%@}}.\n\ | |
189 It is possible to nest block comments.\n\ | |
190 @seealso{#@\\}, %@\\{, %}\n\ | |
191 @end deftypefn"), | |
192 | |
193 pair_type ("...", | |
194 "-*- texinfo -*-\n\ | |
195 @deftypefn {Operator} {} ...\n\ | |
196 Continuation marker. Joins current line with following line.\n\ | |
197 @end deftypefn"), | |
198 | |
199 pair_type ("&", | |
200 "-*- texinfo -*-\n\ | |
201 @deftypefn {Operator} {} &\n\ | |
202 Element by element logical 'and' operator.\n\ | |
203 @seealso{&&, and}\n\ | |
204 @end deftypefn"), | |
205 | |
206 pair_type ("&&", | |
207 "-*- texinfo -*-\n\ | |
208 @deftypefn {Operator} {} &&\n\ | |
209 Logical 'and' operator (with short-circuit evaluation).\n\ | |
210 @seealso{&, and}\n\ | |
211 @end deftypefn"), | |
212 | |
213 pair_type ("'", | |
214 "-*- texinfo -*-\n\ | |
215 @deftypefn {Operator} {} '\n\ | |
216 Matrix transpose operator. For complex matrices, computes the\n\ | |
217 complex conjugate (Hermitian) transpose.\n\ | |
218 \n\ | |
219 The single quote character may also be used to delimit strings, but\n\ | |
220 it is better to use the double quote character, since that is never\n\ | |
221 ambiguous.\n\ | |
222 @seealso{.', transpose}\n\ | |
223 @end deftypefn"), | |
224 | |
225 pair_type ("(", | |
226 "-*- texinfo -*-\n\ | |
227 @deftypefn {Operator} {} (\n\ | |
228 Array index or function argument delimiter.\n\ | |
229 @end deftypefn"), | |
230 | |
231 pair_type (")", | |
232 "-*- texinfo -*-\n\ | |
233 @deftypefn {Operator} {} )\n\ | |
234 Array index or function argument delimiter.\n\ | |
235 @end deftypefn"), | |
236 | |
237 pair_type ("*", | |
238 "-*- texinfo -*-\n\ | |
239 @deftypefn {Operator} {} *\n\ | |
240 Multiplication operator.\n\ | |
241 @seealso{.*, times}\n\ | |
242 @end deftypefn"), | |
243 | |
244 pair_type ("**", | |
245 "-*- texinfo -*-\n\ | |
246 @deftypefn {Operator} {} **\n\ | |
247 Power operator. This may return complex results for real inputs. Use\n\ | |
248 @code{realsqrt}, @code{cbrt}, @code{nthroot}, or @code{realroot} to obtain\n\ | |
249 real results when possible.\n\ | |
250 @seealso{power, ^, .**, .^, realpow, realsqrt, cbrt, nthroot}\n\ | |
251 @end deftypefn"), | |
252 | |
253 pair_type ("^", | |
254 "-*- texinfo -*-\n\ | |
255 @deftypefn {Operator} {} ^\n\ | |
256 Power operator. This may return complex results for real inputs. Use\n\ | |
257 @code{realsqrt}, @code{cbrt}, @code{nthroot}, or @code{realroot} to obtain\n\ | |
258 real results when possible.\n\ | |
259 @seealso{power, **, .^, .**, realpow, realsqrt, cbrt, nthroot}\n\ | |
260 @end deftypefn"), | |
261 | |
262 pair_type ("+", | |
263 "-*- texinfo -*-\n\ | |
264 @deftypefn {Operator} {} +\n\ | |
265 Addition operator.\n\ | |
266 @seealso{plus}\n\ | |
267 @end deftypefn"), | |
268 | |
269 pair_type ("++", | |
270 "-*- texinfo -*-\n\ | |
271 @deftypefn {Operator} {} ++\n\ | |
272 Increment operator. As in C, may be applied as a prefix or postfix\n\ | |
273 operator.\n\ | |
274 @seealso{--}\n\ | |
275 @end deftypefn"), | |
276 | |
277 pair_type (",", | |
278 "-*- texinfo -*-\n\ | |
279 @deftypefn {Operator} {} ,\n\ | |
280 Array index, function argument, or command separator.\n\ | |
281 @end deftypefn"), | |
282 | |
283 pair_type ("-", | |
284 "-*- texinfo -*-\n\ | |
285 @deftypefn {Operator} {} -\n\ | |
286 Subtraction or unary negation operator.\n\ | |
287 @seealso{minus}\n\ | |
288 @end deftypefn"), | |
289 | |
290 pair_type ("--", | |
291 "-*- texinfo -*-\n\ | |
292 @deftypefn {Operator} {} --\n\ | |
293 Decrement operator. As in C, may be applied as a prefix or postfix\n\ | |
294 operator.\n\ | |
295 @seealso{++}\n\ | |
296 @end deftypefn"), | |
297 | |
298 pair_type (".'", | |
299 "-*- texinfo -*-\n\ | |
300 @deftypefn {Operator} {} .'\n\ | |
301 Matrix transpose operator. For complex matrices, computes the\n\ | |
302 transpose, @emph{not} the complex conjugate transpose.\n\ | |
303 @seealso{', transpose}\n\ | |
304 @end deftypefn"), | |
305 | |
306 pair_type (".*", | |
307 "-*- texinfo -*-\n\ | |
308 @deftypefn {Operator} {} .*\n\ | |
309 Element by element multiplication operator.\n\ | |
310 @seealso{*, times}\n\ | |
311 @end deftypefn"), | |
312 | |
313 pair_type (".**", | |
314 "-*- texinfo -*-\n\ | |
315 @deftypefn {Operator} {} .*\n\ | |
316 Element by element power operator. If several complex results are possible,\n\ | |
317 returns the one with smallest non-negative argument (angle). Use\n\ | |
318 @code{realpow}, @code{realsqrt}, @code{cbrt}, or @code{nthroot} if a\n\ | |
319 real result is preferred.\n\ | |
320 @seealso{**, ^, .^, power, realpow, realsqrt, cbrt, nthroot}\n\ | |
321 @end deftypefn"), | |
322 | |
323 pair_type (".^", | |
324 "-*- texinfo -*-\n\ | |
325 @deftypefn {Operator} {} .^\n\ | |
326 Element by element power operator. If several complex results are possible,\n\ | |
327 returns the one with smallest non-negative argument (angle). Use\n\ | |
328 @code{realpow}, @code{realsqrt}, @code{cbrt}, or @code{nthroot} if a\n\ | |
329 real result is preferred.\n\ | |
330 @seealso{.**, ^, **, power, realpow, realsqrt, cbrt, nthroot}\n\ | |
331 @end deftypefn"), | |
332 | |
333 pair_type ("./", | |
334 "-*- texinfo -*-\n\ | |
335 @deftypefn {Operator} {} ./\n\ | |
336 Element by element right division operator.\n\ | |
337 @seealso{/, .\\, rdivide, mrdivide}\n\ | |
338 @end deftypefn"), | |
339 | |
340 pair_type ("/", | |
341 "-*- texinfo -*-\n\ | |
342 @deftypefn {Operator} {} /\n\ | |
343 Right division operator.\n\ | |
344 @seealso{./, \\, rdivide, mrdivide}\n\ | |
345 @end deftypefn"), | |
346 | |
347 pair_type (".\\", | |
348 "-*- texinfo -*-\n\ | |
349 @deftypefn {Operator} {} .\\\n\ | |
350 Element by element left division operator.\n\ | |
351 @seealso{\\, ./, rdivide, mrdivide}\n\ | |
352 @end deftypefn"), | |
353 | |
354 pair_type ("\\", | |
355 "-*- texinfo -*-\n\ | |
356 @deftypefn {Operator} {} \\\n\ | |
357 Left division operator.\n\ | |
358 @seealso{.\\, /, ldivide, mldivide}\n\ | |
359 @end deftypefn"), | |
360 | |
361 pair_type (":", | |
362 "-*- texinfo -*-\n\ | |
363 @deftypefn {Operator} {} :\n\ | |
364 Select entire rows or columns of matrices.\n\ | |
365 @end deftypefn"), | |
366 | |
367 pair_type (";", | |
368 "-*- texinfo -*-\n\ | |
369 @deftypefn {Operator} {} ;\n\ | |
370 Array row or command separator.\n\ | |
371 @seealso{,}\n\ | |
372 @end deftypefn"), | |
373 | |
374 pair_type ("<", | |
375 "-*- texinfo -*-\n\ | |
376 @deftypefn {Operator} {} <\n\ | |
377 'Less than' operator.\n\ | |
378 @seealso{lt}\n\ | |
379 @end deftypefn"), | |
380 | |
381 pair_type ("<=", | |
382 "-*- texinfo -*-\n\ | |
383 @deftypefn {Operator} {} <=\n\ | |
384 'Less than' or 'equals' operator.\n\ | |
385 @seealso{le}\n\ | |
386 @end deftypefn"), | |
387 | |
388 pair_type ("=", | |
389 "-*- texinfo -*-\n\ | |
390 @deftypefn {Operator} {} =\n\ | |
391 Assignment operator.\n\ | |
392 @end deftypefn"), | |
393 | |
394 pair_type ("==", | |
395 "-*- texinfo -*-\n\ | |
396 @deftypefn {Operator} {} ==\n\ | |
397 Equality test operator.\n\ | |
398 @seealso{eq}\n\ | |
399 @end deftypefn"), | |
400 | |
401 pair_type (">", | |
402 "-*- texinfo -*-\n\ | |
403 @deftypefn {Operator} {} >\n\ | |
404 'Greater than' operator.\n\ | |
405 @seealso{gt}\n\ | |
406 @end deftypefn"), | |
407 | |
408 pair_type (">=", | |
409 "-*- texinfo -*-\n\ | |
410 @deftypefn {Operator} {} >=\n\ | |
411 'Greater than' or 'equals' operator.\n\ | |
412 @seealso{ge}\n\ | |
413 @end deftypefn"), | |
414 | |
415 pair_type ("[", | |
416 "-*- texinfo -*-\n\ | |
417 @deftypefn {Operator} {} [\n\ | |
418 Return list delimiter.\n\ | |
419 @seealso{]}\n\ | |
420 @end deftypefn"), | |
421 | |
422 pair_type ("]", | |
423 "-*- texinfo -*-\n\ | |
424 @deftypefn {Operator} {} ]\n\ | |
425 Return list delimiter.\n\ | |
426 @seealso{[}\n\ | |
427 @end deftypefn"), | |
428 | |
429 pair_type ("|", | |
430 "-*- texinfo -*-\n\ | |
431 @deftypefn {Operator} {} |\n\ | |
432 Element by element logical 'or' operator.\n\ | |
433 @seealso{||, or}\n\ | |
434 @end deftypefn"), | |
435 | |
436 pair_type ("||", | |
437 "-*- texinfo -*-\n\ | |
438 @deftypefn {Operator} {} ||\n\ | |
439 Logical 'or' (with short-circuit evaluation) operator.\n\ | |
440 @seealso{|, or}\n\ | |
441 @end deftypefn"), | |
442 }; | |
443 | |
444 const static pair_type keywords[] = | |
445 { | |
446 pair_type ("break", | |
447 "-*- texinfo -*-\n\ | |
448 @deftypefn {Keyword} {} break\n\ | |
449 Exit the innermost enclosing do, while or for loop.\n\ | |
450 @seealso{do, while, for, parfor, continue}\n\ | |
451 @end deftypefn"), | |
452 | |
453 pair_type ("case", | |
454 "-*- texinfo -*-\n\ | |
455 @deftypefn {Keyword} {} case @{@var{value}@}\n\ | |
456 A case statement in an switch. Octave cases are exclusive and do not\n\ | |
457 fall-through as do C-language cases. A switch statement must have at least\n\ | |
458 one case. See @code{switch} for an example.\n\ | |
459 @seealso{switch}\n\ | |
460 @end deftypefn"), | |
461 | |
462 pair_type ("catch", | |
463 "-*- texinfo -*-\n\ | |
464 @deftypefn {Keyword} {} catch\n\ | |
465 Begin the cleanup part of a try-catch block.\n\ | |
466 @seealso{try}\n\ | |
467 @end deftypefn"), | |
468 | |
469 pair_type ("continue", | |
470 "-*- texinfo -*-\n\ | |
471 @deftypefn {Keyword} {} continue\n\ | |
472 Jump to the end of the innermost enclosing do, while or for loop.\n\ | |
473 @seealso{do, while, for, parfor, break}\n\ | |
474 @end deftypefn"), | |
475 | |
476 pair_type ("do", | |
477 "-*- texinfo -*-\n\ | |
478 @deftypefn {Keyword} {} do\n\ | |
479 Begin a do-until loop. This differs from a do-while loop in that the\n\ | |
480 body of the loop is executed at least once.\n\ | |
481 @seealso{while}\n\ | |
482 @end deftypefn"), | |
483 | |
484 pair_type ("else", | |
485 "-*- texinfo -*-\n\ | |
486 @deftypefn {Keyword} {} else\n\ | |
487 Alternate action for an if block. See @code{if} for an example.\n\ | |
488 @seealso{if}\n\ | |
489 @end deftypefn"), | |
490 | |
491 pair_type ("elseif", | |
492 "-*- texinfo -*-\n\ | |
493 @deftypefn {Keyword} {} elseif (@var{condition})\n\ | |
494 Alternate conditional test for an if block. See @code{if} for an example.\n\ | |
495 @seealso{if}\n\ | |
496 @end deftypefn"), | |
497 | |
498 pair_type ("end", | |
499 "-*- texinfo -*-\n\ | |
500 @deftypefn {Keyword} {} end\n\ | |
501 Mark the end of any @code{for}, @code{if}, @code{do}, @code{while}, or\n\ | |
502 @code{function} block.\n\ | |
503 @seealso{for, parfor, if, do, while, function}\n\ | |
504 @end deftypefn"), | |
505 | |
506 pair_type ("end_try_catch", | |
507 "-*- texinfo -*-\n\ | |
508 @deftypefn {Keyword} {} end_try_catch\n\ | |
509 Mark the end of an @code{try-catch} block.\n\ | |
510 @seealso{try, catch}\n\ | |
511 @end deftypefn"), | |
512 | |
513 pair_type ("end_unwind_protect", | |
514 "-*- texinfo -*-\n\ | |
515 @deftypefn {Keyword} {} end_unwind_protect\n\ | |
516 Mark the end of an unwind_protect block.\n\ | |
517 @seealso{unwind_protect}\n\ | |
518 @end deftypefn"), | |
519 | |
520 pair_type ("endfor", | |
521 "-*- texinfo -*-\n\ | |
522 @deftypefn {Keyword} {} endfor\n\ | |
523 Mark the end of a for loop. See @code{for} for an example.\n\ | |
524 @seealso{for}\n\ | |
525 @end deftypefn"), | |
526 | |
527 pair_type ("endfunction", | |
528 "-*- texinfo -*-\n\ | |
529 @deftypefn {Keyword} {} endfunction\n\ | |
530 Mark the end of a function.\n\ | |
531 @seealso{function}\n\ | |
532 @end deftypefn"), | |
533 | |
534 pair_type ("endif", | |
535 "-*- texinfo -*-\n\ | |
536 @deftypefn {Keyword} {} endif\n\ | |
537 Mark the end of an if block. See @code{if} for an example.\n\ | |
538 @seealso{if}\n\ | |
539 @end deftypefn"), | |
540 | |
541 pair_type ("endparfor", | |
542 "-*- texinfo -*-\n\ | |
543 @deftypefn {Keyword} {} endparfor\n\ | |
544 Mark the end of a parfor loop. See @code{parfor} for an example.\n\ | |
545 @seealso{parfor}\n\ | |
546 @end deftypefn"), | |
547 | |
548 pair_type ("endswitch", | |
549 "-*- texinfo -*-\n\ | |
550 @deftypefn {Keyword} {} endswitch\n\ | |
551 Mark the end of a switch block. See @code{switch} for an example.\n\ | |
552 @seealso{switch}\n\ | |
553 @end deftypefn"), | |
554 | |
555 pair_type ("endwhile", | |
556 "-*- texinfo -*-\n\ | |
557 @deftypefn {Keyword} {} endwhile\n\ | |
558 Mark the end of a while loop. See @code{while} for an example.\n\ | |
559 @seealso{do, while}\n\ | |
560 @end deftypefn"), | |
561 | |
562 pair_type ("for", | |
563 "-*- texinfo -*-\n\ | |
564 @deftypefn {Keyword} {} for @var{i} = @var{range}\n\ | |
565 Begin a for loop.\n\ | |
566 \n\ | |
567 @example\n\ | |
568 @group\n\ | |
569 for i = 1:10\n\ | |
570 i\n\ | |
571 endfor\n\ | |
572 @end group\n\ | |
573 @end example\n\ | |
574 @seealso{do, parfor, while}\n\ | |
575 @end deftypefn"), | |
576 | |
577 pair_type ("function", | |
578 "-*- texinfo -*-\n\ | |
579 @deftypefn {Keyword} {} function @var{outputs} = function (@var{input}, @dots{})\n\ | |
580 @deftypefnx {Keyword} {} function {} function (@var{input}, @dots{})\n\ | |
581 @deftypefnx {Keyword} {} function @var{outputs} = function\n\ | |
582 Begin a function body with @var{outputs} as results and @var{inputs} as\n\ | |
583 parameters.\n\ | |
584 @seealso{return}\n\ | |
585 @end deftypefn"), | |
586 | |
587 pair_type ("global", | |
588 "-*- texinfo -*-\n\ | |
589 @deftypefn {Keyword} {} global\n\ | |
590 Declare variables to have global scope.\n\ | |
591 \n\ | |
592 @example\n\ | |
593 @group\n\ | |
594 global @var{x};\n\ | |
595 if (isempty (@var{x}))\n\ | |
596 x = 1;\n\ | |
597 endif\n\ | |
598 @end group\n\ | |
599 @end example\n\ | |
600 @seealso{persistent}\n\ | |
601 @end deftypefn"), | |
602 | |
603 pair_type ("if", | |
604 "-*- texinfo -*-\n\ | |
605 @deftypefn {Keyword} {} if (@var{cond}) @dots{} endif\n\ | |
606 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} else @dots{} endif\n\ | |
607 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif\n\ | |
608 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif\n\ | |
609 Begin an if block.\n\ | |
610 \n\ | |
611 @example\n\ | |
612 @group\n\ | |
613 x = 1;\n\ | |
614 if (x == 1)\n\ | |
615 disp (\"one\");\n\ | |
616 elseif (x == 2)\n\ | |
617 disp (\"two\");\n\ | |
618 else\n\ | |
619 disp (\"not one or two\");\n\ | |
620 endif\n\ | |
621 @end group\n\ | |
622 @end example\n\ | |
623 @seealso{switch}\n\ | |
624 @end deftypefn"), | |
625 | |
626 pair_type ("otherwise", | |
627 "-*- texinfo -*-\n\ | |
628 @deftypefn {Keyword} {} otherwise\n\ | |
629 The default statement in a switch block (similar to else in an if block).\n\ | |
630 @seealso{switch}\n\ | |
631 @end deftypefn"), | |
632 | |
633 pair_type ("parfor", | |
634 "-*- texinfo -*-\n\ | |
635 @deftypefn {Keyword} {} for @var{i} = @var{range}\n\ | |
636 @deftypefnx {Keyword} {} for (@var{i} = @var{range}, @var{maxproc})\n\ | |
637 Begin a for loop that may execute in parallel.\n\ | |
638 \n\ | |
639 @example\n\ | |
640 @group\n\ | |
641 parfor i = 1:10\n\ | |
642 i\n\ | |
643 endparfor\n\ | |
644 @end group\n\ | |
645 @end example\n\ | |
646 @seealso{for, do, while}\n\ | |
647 @end deftypefn"), | |
648 | |
649 pair_type ("persistent", | |
650 "-*- texinfo -*-\n\ | |
651 @deftypefn {Keyword} {} persistent @var{var}\n\ | |
652 Declare variables as persistent. A variable that has been declared\n\ | |
653 persistent within a function will retain its contents in memory between\n\ | |
654 subsequent calls to the same function. The difference between persistent\n\ | |
655 variables and global variables is that persistent variables are local in \n\ | |
656 scope to a particular function and are not visible elsewhere.\n\ | |
657 @seealso{global}\n\ | |
658 @end deftypefn"), | |
659 | |
660 pair_type ("return", | |
661 "-*- texinfo -*-\n\ | |
662 @deftypefn {Keyword} {} return\n\ | |
663 Return from a function.\n\ | |
664 @seealso{function}\n\ | |
665 @end deftypefn"), | |
666 | |
667 pair_type ("static", | |
668 "-*- texinfo -*-\n\ | |
669 @deftypefn {Keyword} {} static\n\ | |
670 This function has been deprecated in favor of persistent.\n\ | |
671 @seealso{persistent}\n\ | |
672 @end deftypefn"), | |
673 | |
674 pair_type ("switch", | |
675 "-*- texinfo -*-\n\ | |
676 @deftypefn {Keyword} {} switch @var{statement}\n\ | |
677 Begin a switch block.\n\ | |
678 \n\ | |
679 @example\n\ | |
680 @group\n\ | |
681 yesno = \"yes\"\n\ | |
682 \n\ | |
683 switch yesno\n\ | |
684 case @{\"Yes\" \"yes\" \"YES\" \"y\" \"Y\"@}\n\ | |
685 value = 1;\n\ | |
686 case @{\"No\" \"no\" \"NO\" \"n\" \"N\"@}\n\ | |
687 value = 0;\n\ | |
688 otherwise\n\ | |
689 error (\"invalid value\");\n\ | |
690 endswitch\n\ | |
691 @end group\n\ | |
692 @end example\n\ | |
693 @seealso{if, case, otherwise}\n\ | |
694 @end deftypefn"), | |
695 | |
696 pair_type ("try", | |
697 "-*- texinfo -*-\n\ | |
698 @deftypefn {Keyword} {} try\n\ | |
699 Begin a try-catch block.\n\ | |
700 \n\ | |
701 If an error occurs within a try block, then the catch code will be run and\n\ | |
702 execution will proceed after the catch block (though it is often\n\ | |
703 recommended to use the lasterr function to re-throw the error after cleanup\n\ | |
704 is completed).\n\ | |
705 @seealso{catch, unwind_protect}\n\ | |
706 @end deftypefn"), | |
707 | |
708 pair_type ("until", | |
709 "-*- texinfo -*-\n\ | |
710 @deftypefn {Keyword} {} until\n\ | |
711 End a do-until loop.\n\ | |
712 @seealso{do}\n\ | |
713 @end deftypefn"), | |
714 | |
715 pair_type ("unwind_protect", | |
716 "-*- texinfo -*-\n\ | |
717 @deftypefn {Keyword} {} unwind_protect\n\ | |
718 Begin an unwind_protect block.\n\ | |
719 \n\ | |
720 If an error occurs within the first part of an unwind_protect block\n\ | |
721 the commands within the unwind_protect_cleanup block are executed before\n\ | |
722 the error is thrown. If an error is not thrown, then the\n\ | |
723 unwind_protect_cleanup block is still executed (in other words, the\n\ | |
724 unwind_protect_cleanup will be run with or without an error in the\n\ | |
725 unwind_protect block).\n\ | |
726 @seealso{unwind_protect_cleanup, try}\n\ | |
727 @end deftypefn"), | |
728 | |
729 pair_type ("unwind_protect_cleanup", | |
730 "-*- texinfo -*-\n\ | |
731 @deftypefn {Keyword} {} unwind_protect_cleanup\n\ | |
732 Begin the cleanup section of an unwind_protect block.\n\ | |
733 @seealso{unwind_protect}\n\ | |
734 @end deftypefn"), | |
735 | |
736 pair_type ("varargin", | |
737 "-*- texinfo -*-\n\ | |
738 @deftypefn {Keyword} {} varargin\n\ | |
739 Pass an arbitrary number of arguments into a function.\n\ | |
740 @seealso{varargout, nargin, isargout, nargout, nthargout}\n\ | |
741 @end deftypefn"), | |
742 | |
743 pair_type ("varargout", | |
744 "-*- texinfo -*-\n\ | |
745 @deftypefn {Keyword} {} varargout\n\ | |
746 Pass an arbitrary number of arguments out of a function.\n\ | |
747 @seealso{varargin, nargin, isargout, nargout, nthargout}\n\ | |
748 @end deftypefn"), | |
749 | |
750 pair_type ("while", | |
751 "-*- texinfo -*-\n\ | |
752 @deftypefn {Keyword} {} while\n\ | |
753 Begin a while loop.\n\ | |
754 @seealso{do}\n\ | |
755 @end deftypefn"), | |
756 }; | |
757 | |
758 // Return a copy of the operator or keyword names. | |
759 static string_vector | |
760 names (const map_type& lst) | |
761 { | |
762 string_vector retval (lst.size ()); | |
763 int j = 0; | |
764 for (map_iter iter = lst.begin (); iter != lst.end (); iter ++) | |
765 retval[j++] = iter->first; | |
766 return retval; | |
767 } | |
768 | |
769 const static map_type operators_map (operators, operators + size (operators)); | |
770 const static map_type keywords_map (keywords, keywords + size (keywords)); | |
771 const static string_vector keyword_names = names (keywords_map); | |
772 | |
773 // FIXME -- It's not likely that this does the right thing now. | |
774 | |
775 string_vector | |
776 make_name_list (void) | |
777 { | |
778 const int key_len = keyword_names.length (); | |
779 | |
780 const string_vector bif = symbol_table::built_in_function_names (); | |
781 const int bif_len = bif.length (); | |
782 | |
783 const string_vector cfl = symbol_table::cmdline_function_names (); | |
784 const int cfl_len = cfl.length (); | |
785 | |
786 const string_vector lcl = symbol_table::variable_names (); | |
787 const int lcl_len = lcl.length (); | |
788 | |
789 const string_vector ffl = load_path::fcn_names (); | |
790 const int ffl_len = ffl.length (); | |
791 | |
792 const string_vector afl = autoloaded_functions (); | |
793 const int afl_len = afl.length (); | |
794 | |
795 const int total_len | |
796 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len; | |
797 | |
798 string_vector list (total_len); | |
799 | |
800 // Put all the symbols in one big list. | |
801 | |
802 int j = 0; | |
803 int i = 0; | |
804 for (i = 0; i < key_len; i++) | |
805 list[j++] = keyword_names[i]; | |
806 | |
807 for (i = 0; i < bif_len; i++) | |
808 list[j++] = bif[i]; | |
809 | |
810 for (i = 0; i < cfl_len; i++) | |
811 list[j++] = cfl[i]; | |
812 | |
813 for (i = 0; i < lcl_len; i++) | |
814 list[j++] = lcl[i]; | |
815 | |
816 for (i = 0; i < ffl_len; i++) | |
817 list[j++] = ffl[i]; | |
818 | |
819 for (i = 0; i < afl_len; i++) | |
820 list[j++] = afl[i]; | |
821 | |
822 return list; | |
823 } | |
824 | |
825 static bool | |
826 looks_like_html (const std::string& msg) | |
827 { | |
828 const size_t p1 = msg.find ('\n'); | |
829 std::string t = msg.substr (0, p1); | |
830 const size_t p2 = t.find ("<html"); // FIXME: this comparison should be case-insensitive | |
831 | |
832 return (p2 != std::string::npos); | |
833 } | |
834 | |
835 static bool | |
836 looks_like_texinfo (const std::string& msg, size_t& p1) | |
837 { | |
838 p1 = msg.find ('\n'); | |
839 | |
840 std::string t = msg.substr (0, p1); | |
841 | |
842 if (p1 == std::string::npos) | |
843 p1 = 0; | |
844 | |
845 size_t p2 = t.find ("-*- texinfo -*-"); | |
846 | |
847 return (p2 != std::string::npos); | |
848 } | |
849 | |
850 static bool | |
851 raw_help_from_symbol_table (const std::string& nm, std::string& h, | |
852 std::string& w, bool& symbol_found) | |
853 { | |
854 bool retval = false; | |
855 | |
856 octave_value val = symbol_table::find_function (nm); | |
857 | |
858 if (val.is_defined ()) | |
859 { | |
860 octave_function *fcn = val.function_value (); | |
861 | |
862 if (fcn) | |
863 { | |
864 symbol_found = true; | |
865 | |
866 h = fcn->doc_string (); | |
867 | |
868 retval = true; | |
869 | |
870 w = fcn->fcn_file_name (); | |
871 | |
872 if (w.empty ()) | |
873 w = fcn->is_user_function () | |
874 ? "command-line function" : "built-in function"; | |
875 } | |
876 } | |
877 | |
878 return retval; | |
879 } | |
880 | |
881 static bool | |
882 raw_help_from_file (const std::string& nm, std::string& h, | |
883 std::string& file, bool& symbol_found) | |
884 { | |
885 bool retval = false; | |
886 | |
887 // FIXME -- this is a bit of a kluge... | |
888 unwind_protect frame; | |
889 frame.protect_var (reading_script_file); | |
890 reading_script_file = true; | |
891 | |
892 h = get_help_from_file (nm, symbol_found, file); | |
893 | |
894 if (h.length () > 0) | |
895 retval = true; | |
896 | |
897 return retval; | |
898 } | |
899 | |
900 static bool | |
901 raw_help_from_map (const std::string& nm, std::string& h, | |
902 const map_type& map, bool& symbol_found) | |
903 { | |
904 map_iter idx = map.find (nm); | |
905 symbol_found = (idx != map.end ()); | |
906 h = (symbol_found) ? idx->second : ""; | |
907 return symbol_found; | |
908 } | |
909 | |
910 std::string | |
911 raw_help (const std::string& nm, bool& symbol_found) | |
912 { | |
913 std::string h; | |
914 std::string w; | |
915 std::string f; | |
916 | |
917 (raw_help_from_symbol_table (nm, h, w, symbol_found) | |
918 || raw_help_from_file (nm, h, f, symbol_found) | |
919 || raw_help_from_map (nm, h, operators_map, symbol_found) | |
920 || raw_help_from_map (nm, h, keywords_map, symbol_found)); | |
921 | |
922 return h; | |
923 } | |
924 | |
925 static void | |
926 do_get_help_text (const std::string& name, std::string& text, | |
927 std::string& format) | |
928 { | |
929 bool symbol_found = false; | |
930 text = raw_help (name, symbol_found); | |
931 | |
932 format = "Not found"; | |
933 if (symbol_found) | |
934 { | |
935 size_t idx = -1; | |
936 if (text.empty ()) | |
937 { | |
938 format = "Not documented"; | |
939 } | |
940 else if (looks_like_texinfo (text, idx)) | |
941 { | |
942 format = "texinfo"; | |
943 text.erase (0, idx); | |
944 } | |
945 else if (looks_like_html (text)) | |
946 { | |
947 format = "html"; | |
948 } | |
949 else | |
950 { | |
951 format = "plain text"; | |
952 } | |
953 } | |
954 } | |
955 | |
956 DEFUN (get_help_text, args, , "-*- texinfo -*-\n\ | |
957 @deftypefn {Built-in Function} {[@var{text}, @var{format}] =} get_help_text (@var{name})\n\ | |
958 Return the raw help text of function @var{name}.\n\ | |
959 \n\ | |
960 The raw help text is returned in @var{text} and the format in @var{format}\n\ | |
961 The format is a string which is one of @t{\"texinfo\"}, @t{\"html\"}, or\n\ | |
962 @t{\"plain text\"}.\n\ | |
963 @end deftypefn") | |
964 { | |
965 octave_value_list retval; | |
966 | |
967 if (args.length () == 1) | |
968 { | |
969 const std::string name = args (0).string_value (); | |
970 | |
971 if (! error_state) | |
972 { | |
973 std::string text; | |
974 std::string format; | |
975 | |
976 do_get_help_text (name, text, format); | |
977 | |
978 retval(1) = format; | |
979 retval(0) = text; | |
980 } | |
981 else | |
982 error ("get_help_text: invalid input"); | |
983 } | |
984 else | |
985 print_usage (); | |
986 | |
987 return retval; | |
988 } | |
989 | |
990 static void | |
991 do_get_help_text_from_file (const std::string& fname, std::string& text, | |
992 std::string& format) | |
993 { | |
994 bool symbol_found = false; | |
995 | |
996 std::string f; | |
997 | |
998 raw_help_from_file (fname, text, f, symbol_found); | |
999 | |
1000 format = "Not found"; | |
1001 if (symbol_found) | |
1002 { | |
1003 size_t idx = -1; | |
1004 if (text.empty ()) | |
1005 { | |
1006 format = "Not documented"; | |
1007 } | |
1008 else if (looks_like_texinfo (text, idx)) | |
1009 { | |
1010 format = "texinfo"; | |
1011 text.erase (0, idx); | |
1012 } | |
1013 else if (looks_like_html (text)) | |
1014 { | |
1015 format = "html"; | |
1016 } | |
1017 else | |
1018 { | |
1019 format = "plain text"; | |
1020 } | |
1021 } | |
1022 } | |
1023 | |
1024 DEFUN (get_help_text_from_file, args, , | |
1025 "-*- texinfo -*-\n\ | |
1026 @deftypefn {Built-in Function} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})\n\ | |
1027 Return the raw help text from the file @var{fname}.\n\ | |
1028 \n\ | |
1029 The raw help text is returned in @var{text} and the format in @var{format}\n\ | |
1030 The format is a string which is one of @t{\"texinfo\"}, @t{\"html\"}, or\n\ | |
1031 @t{\"plain text\"}.\n\ | |
1032 @end deftypefn") | |
1033 { | |
1034 octave_value_list retval; | |
1035 | |
1036 if (args.length () == 1) | |
1037 { | |
1038 const std::string fname = args(0).string_value (); | |
1039 | |
1040 if (! error_state) | |
1041 { | |
1042 std::string text; | |
1043 std::string format; | |
1044 | |
1045 do_get_help_text_from_file (fname, text, format); | |
1046 | |
1047 retval(1) = format; | |
1048 retval(0) = text; | |
1049 } | |
1050 else | |
1051 error ("get_help_text_from_file: invalid input"); | |
1052 } | |
1053 else | |
1054 print_usage (); | |
1055 | |
1056 return retval; | |
1057 } | |
1058 | |
1059 // Return a cell array of strings containing the names of all | |
1060 // operators. | |
1061 | |
1062 DEFUN (__operators__, , , | |
1063 "-*- texinfo -*-\n\ | |
1064 @deftypefn {Function File} __operators__ ()\n\ | |
1065 Undocumented internal function.\n\ | |
1066 @end deftypefn") | |
1067 { | |
1068 return octave_value (Cell (names (operators_map))); | |
1069 } | |
1070 | |
1071 // Return a cell array of strings containing the names of all | |
1072 // keywords. | |
1073 | |
1074 DEFUN (__keywords__, , , | |
1075 "-*- texinfo -*-\n\ | |
1076 @deftypefn {Function File} __keywords__ ()\n\ | |
1077 Undocumented internal function.\n\ | |
1078 @end deftypefn") | |
1079 { | |
1080 return octave_value (Cell (names (keywords_map))); | |
1081 } | |
1082 | |
1083 // Return a cell array of strings containing the names of all builtin | |
1084 // functions. | |
1085 | |
1086 DEFUN (__builtins__, , , | |
1087 "-*- texinfo -*-\n\ | |
1088 @deftypefn {Function File} __builtins__ ()\n\ | |
1089 Undocumented internal function.\n\ | |
1090 @end deftypefn") | |
1091 { | |
1092 const string_vector bif = symbol_table::built_in_function_names (); | |
1093 | |
1094 return octave_value (Cell (bif)); | |
1095 } | |
1096 | |
1097 static std::string | |
1098 do_which (const std::string& name, std::string& type) | |
1099 { | |
1100 std::string file; | |
1101 | |
1102 type = std::string (); | |
1103 | |
1104 octave_value val = symbol_table::find_function (name); | |
1105 | |
1106 if (name.find_first_of ('.') == std::string::npos) | |
1107 { | |
1108 if (val.is_defined ()) | |
1109 { | |
1110 octave_function *fcn = val.function_value (); | |
1111 | |
1112 if (fcn) | |
1113 { | |
1114 file = fcn->fcn_file_name (); | |
1115 | |
1116 if (file.empty ()) | |
1117 { | |
1118 if (fcn->is_user_function ()) | |
1119 type = "command-line function"; | |
1120 else | |
1121 { | |
1122 file = fcn->src_file_name (); | |
1123 type = "built-in function"; | |
1124 } | |
1125 } | |
1126 else | |
1127 type = val.is_user_script () | |
1128 ? std::string ("script") : std::string ("function"); | |
1129 } | |
1130 } | |
1131 else | |
1132 { | |
1133 // We might find a file that contains only a doc string. | |
1134 | |
1135 file = load_path::find_fcn_file (name); | |
1136 } | |
1137 } | |
1138 else | |
1139 { | |
1140 // File query. | |
1141 | |
1142 // For compatibility: "file." queries "file". | |
1143 if (name.size () > 1 && name[name.size () - 1] == '.') | |
1144 file = load_path::find_file (name.substr (0, name.size () - 1)); | |
1145 else | |
1146 file = load_path::find_file (name); | |
1147 } | |
1148 | |
1149 | |
1150 return file; | |
1151 } | |
1152 | |
1153 std::string | |
1154 do_which (const std::string& name) | |
1155 { | |
1156 std::string retval; | |
1157 | |
1158 std::string type; | |
1159 | |
1160 retval = do_which (name, type); | |
1161 | |
1162 return retval; | |
1163 } | |
1164 | |
1165 DEFUN (__which__, args, , | |
1166 "-*- texinfo -*-\n\ | |
1167 @deftypefn {Built-in Function} {} __which__ (@var{name}, @dots{})\n\ | |
1168 Undocumented internal function.\n\ | |
1169 @end deftypefn") | |
1170 { | |
1171 octave_value retval; | |
1172 | |
1173 string_vector argv = args.make_argv ("which"); | |
1174 | |
1175 if (! error_state) | |
1176 { | |
1177 int argc = argv.length (); | |
1178 | |
1179 if (argc > 1) | |
1180 { | |
1181 octave_map m (dim_vector (1, argc-1)); | |
1182 | |
1183 Cell names (1, argc-1); | |
1184 Cell files (1, argc-1); | |
1185 Cell types (1, argc-1); | |
1186 | |
1187 for (int i = 1; i < argc; i++) | |
1188 { | |
1189 std::string name = argv[i]; | |
1190 | |
1191 std::string type; | |
1192 | |
1193 std::string file = do_which (name, type); | |
1194 | |
1195 names(i-1) = name; | |
1196 files(i-1) = file; | |
1197 types(i-1) = type; | |
1198 } | |
1199 | |
1200 m.assign ("name", names); | |
1201 m.assign ("file", files); | |
1202 m.assign ("type", types); | |
1203 | |
1204 retval = m; | |
1205 } | |
1206 else | |
1207 print_usage (); | |
1208 } | |
1209 | |
1210 return retval; | |
1211 } | |
1212 | |
1213 // FIXME -- Are we sure this function always does the right thing? | |
1214 inline bool | |
1215 file_is_in_dir (const std::string filename, const std::string dir) | |
1216 { | |
1217 if (filename.find (dir) == 0) | |
1218 { | |
1219 const int dir_len = dir.size (); | |
1220 const int filename_len = filename.size (); | |
1221 const int max_allowed_seps = file_ops::is_dir_sep (dir[dir_len-1]) ? 0 : 1; | |
1222 | |
1223 int num_seps = 0; | |
1224 for (int i = dir_len; i < filename_len; i++) | |
1225 if (file_ops::is_dir_sep (filename[i])) | |
1226 num_seps ++; | |
1227 | |
1228 return (num_seps <= max_allowed_seps); | |
1229 } | |
1230 else | |
1231 return false; | |
1232 } | |
1233 | |
1234 // Return a cell array of strings containing the names of all | |
1235 // functions available in DIRECTORY. If no directory is given, search | |
1236 // the current path. | |
1237 | |
1238 DEFUN (__list_functions__, args, , | |
1239 "-*- texinfo -*-\n\ | |
1240 @deftypefn {Function File} {@var{retval} =} __list_functions__ ()\n\ | |
1241 @deftypefnx {Function File} {@var{retval} =} __list_functions__ (@var{directory})\n\ | |
1242 Undocumented internal function.\n\ | |
1243 @end deftypefn") | |
1244 { | |
1245 octave_value retval; | |
1246 | |
1247 // Get list of functions | |
1248 string_vector ffl = load_path::fcn_names (); | |
1249 string_vector afl = autoloaded_functions (); | |
1250 | |
1251 if (args.length () == 0) | |
1252 retval = Cell (ffl.append (afl)); | |
1253 else | |
1254 { | |
1255 std::string dir = args (0).string_value (); | |
1256 | |
1257 if (! error_state) | |
1258 { | |
1259 string_vector fl = load_path::files (dir, true); | |
1260 | |
1261 if (! error_state) | |
1262 { | |
1263 // Return a sorted list with unique entries (in case of | |
1264 // .m and .oct versions of the same function in a given | |
1265 // directory, for example). | |
1266 fl.sort (true); | |
1267 | |
1268 retval = Cell (fl); | |
1269 } | |
1270 } | |
1271 else | |
1272 error ("__list_functions__: DIRECTORY argument must be a string"); | |
1273 } | |
1274 | |
1275 return retval; | |
1276 } | |
1277 | |
1278 DEFUN (doc_cache_file, args, nargout, | |
1279 "-*- texinfo -*-\n\ | |
1280 @deftypefn {Built-in Function} {@var{val} =} doc_cache_file ()\n\ | |
1281 @deftypefnx {Built-in Function} {@var{old_val} =} doc_cache_file (@var{new_val})\n\ | |
1282 @deftypefnx {Built-in Function} {} doc_cache_file (@var{new_val}, \"local\")\n\ | |
1283 Query or set the internal variable that specifies the name of the\n\ | |
1284 Octave documentation cache file. A cache file significantly improves\n\ | |
1285 the performance of the @code{lookfor} command. The default value is \n\ | |
1286 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},\n\ | |
1287 in which @var{octave-home} is the root directory of the Octave installation,\n\ | |
1288 and @var{version} is the Octave version number.\n\ | |
1289 The default value may be overridden by the environment variable\n\ | |
1290 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument\n\ | |
1291 @samp{--doc-cache-file NAME}.\n\ | |
1292 \n\ | |
1293 When called from inside a function with the \"local\" option, the variable is\n\ | |
1294 changed locally for the function and any subroutines it calls. The original\n\ | |
1295 variable value is restored when exiting the function.\n\ | |
1296 @seealso{lookfor, info_program, doc, help, makeinfo_program}\n\ | |
1297 @end deftypefn") | |
1298 { | |
1299 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file); | |
1300 } | |
1301 | |
1302 DEFUN (texi_macros_file, args, nargout, | |
1303 "-*- texinfo -*-\n\ | |
1304 @deftypefn {Built-in Function} {@var{val} =} texi_macros_file ()\n\ | |
1305 @deftypefnx {Built-in Function} {@var{old_val} =} texi_macros_file (@var{new_val})\n\ | |
1306 @deftypefnx {Built-in Function} {} texi_macros_file (@var{new_val}, \"local\")\n\ | |
1307 Query or set the internal variable that specifies the name of the\n\ | |
1308 file containing Texinfo macros that are prepended to documentation strings\n\ | |
1309 before they are passed to makeinfo. The default value is \n\ | |
1310 @file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},\n\ | |
1311 in which @var{octave-home} is the root directory of the Octave installation,\n\ | |
1312 and @var{version} is the Octave version number.\n\ | |
1313 The default value may be overridden by the environment variable\n\ | |
1314 @w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument\n\ | |
1315 @samp{--texi-macros-file NAME}.\n\ | |
1316 \n\ | |
1317 When called from inside a function with the \"local\" option, the variable is\n\ | |
1318 changed locally for the function and any subroutines it calls. The original\n\ | |
1319 variable value is restored when exiting the function.\n\ | |
1320 @seealso{makeinfo_program}\n\ | |
1321 @end deftypefn") | |
1322 { | |
1323 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (texi_macros_file); | |
1324 } | |
1325 | |
1326 DEFUN (info_file, args, nargout, | |
1327 "-*- texinfo -*-\n\ | |
1328 @deftypefn {Built-in Function} {@var{val} =} info_file ()\n\ | |
1329 @deftypefnx {Built-in Function} {@var{old_val} =} info_file (@var{new_val})\n\ | |
1330 @deftypefnx {Built-in Function} {} info_file (@var{new_val}, \"local\")\n\ | |
1331 Query or set the internal variable that specifies the name of the\n\ | |
1332 Octave info file. The default value is\n\ | |
1333 @file{@var{octave-home}/info/octave.info}, in\n\ | |
1334 which @var{octave-home} is the root directory of the Octave installation.\n\ | |
1335 The default value may be overridden by the environment variable\n\ | |
1336 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument\n\ | |
1337 @samp{--info-file NAME}.\n\ | |
1338 \n\ | |
1339 When called from inside a function with the \"local\" option, the variable is\n\ | |
1340 changed locally for the function and any subroutines it calls. The original\n\ | |
1341 variable value is restored when exiting the function.\n\ | |
1342 @seealso{info_program, doc, help, makeinfo_program}\n\ | |
1343 @end deftypefn") | |
1344 { | |
1345 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file); | |
1346 } | |
1347 | |
1348 DEFUN (info_program, args, nargout, | |
1349 "-*- texinfo -*-\n\ | |
1350 @deftypefn {Built-in Function} {@var{val} =} info_program ()\n\ | |
1351 @deftypefnx {Built-in Function} {@var{old_val} =} info_program (@var{new_val})\n\ | |
1352 @deftypefnx {Built-in Function} {} info_program (@var{new_val}, \"local\")\n\ | |
1353 Query or set the internal variable that specifies the name of the\n\ | |
1354 info program to run. The default value is\n\ | |
1355 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info}\n\ | |
1356 in which @var{octave-home} is the root directory of the Octave installation,\n\ | |
1357 @var{version} is the Octave version number, and @var{arch}\n\ | |
1358 is the system type (for example, @code{i686-pc-linux-gnu}). The\n\ | |
1359 default value may be overridden by the environment variable\n\ | |
1360 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument\n\ | |
1361 @samp{--info-program NAME}.\n\ | |
1362 \n\ | |
1363 When called from inside a function with the \"local\" option, the variable is\n\ | |
1364 changed locally for the function and any subroutines it calls. The original\n\ | |
1365 variable value is restored when exiting the function.\n\ | |
1366 @seealso{info_file, doc, help, makeinfo_program}\n\ | |
1367 @end deftypefn") | |
1368 { | |
1369 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program); | |
1370 } | |
1371 | |
1372 DEFUN (makeinfo_program, args, nargout, | |
1373 "-*- texinfo -*-\n\ | |
1374 @deftypefn {Built-in Function} {@var{val} =} makeinfo_program ()\n\ | |
1375 @deftypefnx {Built-in Function} {@var{old_val} =} makeinfo_program (@var{new_val})\n\ | |
1376 @deftypefnx {Built-in Function} {} makeinfo_program (@var{new_val}, \"local\")\n\ | |
1377 Query or set the internal variable that specifies the name of the\n\ | |
1378 program that Octave runs to format help text containing\n\ | |
1379 Texinfo markup commands. The default value is @code{makeinfo}.\n\ | |
1380 \n\ | |
1381 When called from inside a function with the \"local\" option, the variable is\n\ | |
1382 changed locally for the function and any subroutines it calls. The original\n\ | |
1383 variable value is restored when exiting the function.\n\ | |
1384 @seealso{texi_macros_file, info_file, info_program, doc, help}\n\ | |
1385 @end deftypefn") | |
1386 { | |
1387 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program); | |
1388 } | |
1389 | |
1390 DEFUN (suppress_verbose_help_message, args, nargout, | |
1391 "-*- texinfo -*-\n\ | |
1392 @deftypefn {Built-in Function} {@var{val} =} suppress_verbose_help_message ()\n\ | |
1393 @deftypefnx {Built-in Function} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})\n\ | |
1394 @deftypefnx {Built-in Function} {} suppress_verbose_help_message (@var{new_val}, \"local\")\n\ | |
1395 Query or set the internal variable that controls whether Octave\n\ | |
1396 will add additional help information to the end of the output from\n\ | |
1397 the @code{help} command and usage messages for built-in commands.\n\ | |
1398 \n\ | |
1399 When called from inside a function with the \"local\" option, the variable is\n\ | |
1400 changed locally for the function and any subroutines it calls. The original\n\ | |
1401 variable value is restored when exiting the function.\n\ | |
1402 @end deftypefn") | |
1403 { | |
1404 return SET_INTERNAL_VARIABLE (suppress_verbose_help_message); | |
1405 } |