GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
help.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2013 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 \n\
482 @example\n\
483 @group\n\
484 i = 0;\n\
485 do\n\
486  i++\n\
487 until (i == 10)\n\
488 @end group\n\
489 @end example\n\
490 @seealso{for, until, while}\n\
491 @end deftypefn"),
492 
493  pair_type ("else",
494  "-*- texinfo -*-\n\
495 @deftypefn {Keyword} {} else\n\
496 Alternate action for an if block. See @code{if} for an example.\n\
497 @seealso{if}\n\
498 @end deftypefn"),
499 
500  pair_type ("elseif",
501  "-*- texinfo -*-\n\
502 @deftypefn {Keyword} {} elseif (@var{condition})\n\
503 Alternate conditional test for an if block. See @code{if} for an example.\n\
504 @seealso{if}\n\
505 @end deftypefn"),
506 
507  pair_type ("end",
508  "-*- texinfo -*-\n\
509 @deftypefn {Keyword} {} end\n\
510 Mark the end of any @code{for}, @code{if}, @code{do}, @code{while}, or\n\
511 @code{function} block.\n\
512 @seealso{for, parfor, if, do, while, function}\n\
513 @end deftypefn"),
514 
515  pair_type ("end_try_catch",
516  "-*- texinfo -*-\n\
517 @deftypefn {Keyword} {} end_try_catch\n\
518 Mark the end of an @code{try-catch} block.\n\
519 @seealso{try, catch}\n\
520 @end deftypefn"),
521 
522  pair_type ("end_unwind_protect",
523  "-*- texinfo -*-\n\
524 @deftypefn {Keyword} {} end_unwind_protect\n\
525 Mark the end of an unwind_protect block.\n\
526 @seealso{unwind_protect}\n\
527 @end deftypefn"),
528 
529  pair_type ("endfor",
530  "-*- texinfo -*-\n\
531 @deftypefn {Keyword} {} endfor\n\
532 Mark the end of a for loop. See @code{for} for an example.\n\
533 @seealso{for}\n\
534 @end deftypefn"),
535 
536  pair_type ("endfunction",
537  "-*- texinfo -*-\n\
538 @deftypefn {Keyword} {} endfunction\n\
539 Mark the end of a function.\n\
540 @seealso{function}\n\
541 @end deftypefn"),
542 
543  pair_type ("endif",
544  "-*- texinfo -*-\n\
545 @deftypefn {Keyword} {} endif\n\
546 Mark the end of an if block. See @code{if} for an example.\n\
547 @seealso{if}\n\
548 @end deftypefn"),
549 
550  pair_type ("endparfor",
551  "-*- texinfo -*-\n\
552 @deftypefn {Keyword} {} endparfor\n\
553 Mark the end of a parfor loop. See @code{parfor} for an example.\n\
554 @seealso{parfor}\n\
555 @end deftypefn"),
556 
557  pair_type ("endswitch",
558  "-*- texinfo -*-\n\
559 @deftypefn {Keyword} {} endswitch\n\
560 Mark the end of a switch block. See @code{switch} for an example.\n\
561 @seealso{switch}\n\
562 @end deftypefn"),
563 
564  pair_type ("endwhile",
565  "-*- texinfo -*-\n\
566 @deftypefn {Keyword} {} endwhile\n\
567 Mark the end of a while loop. See @code{while} for an example.\n\
568 @seealso{do, while}\n\
569 @end deftypefn"),
570 
571  pair_type ("for",
572  "-*- texinfo -*-\n\
573 @deftypefn {Keyword} {} for @var{i} = @var{range}\n\
574 Begin a for loop.\n\
575 \n\
576 @example\n\
577 @group\n\
578 for i = 1:10\n\
579  i\n\
580 endfor\n\
581 @end group\n\
582 @end example\n\
583 @seealso{do, parfor, while}\n\
584 @end deftypefn"),
585 
586  pair_type ("function",
587  "-*- texinfo -*-\n\
588 @deftypefn {Keyword} {} function @var{outputs} = function (@var{input}, @dots{})\n\
589 @deftypefnx {Keyword} {} function {} function (@var{input}, @dots{})\n\
590 @deftypefnx {Keyword} {} function @var{outputs} = function\n\
591 Begin a function body with @var{outputs} as results and @var{inputs} as\n\
592 parameters.\n\
593 @seealso{return}\n\
594 @end deftypefn"),
595 
596  pair_type ("global",
597  "-*- texinfo -*-\n\
598 @deftypefn {Keyword} {} global\n\
599 Declare variables to have global scope.\n\
600 \n\
601 @example\n\
602 @group\n\
603 global @var{x};\n\
604 if (isempty (@var{x}))\n\
605  x = 1;\n\
606 endif\n\
607 @end group\n\
608 @end example\n\
609 @seealso{persistent}\n\
610 @end deftypefn"),
611 
612  pair_type ("if",
613  "-*- texinfo -*-\n\
614 @deftypefn {Keyword} {} if (@var{cond}) @dots{} endif\n\
615 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} else @dots{} endif\n\
616 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif\n\
617 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif\n\
618 Begin an if block.\n\
619 \n\
620 @example\n\
621 @group\n\
622 x = 1;\n\
623 if (x == 1)\n\
624  disp (\"one\");\n\
625 elseif (x == 2)\n\
626  disp (\"two\");\n\
627 else\n\
628  disp (\"not one or two\");\n\
629 endif\n\
630 @end group\n\
631 @end example\n\
632 @seealso{switch}\n\
633 @end deftypefn"),
634 
635  pair_type ("otherwise",
636  "-*- texinfo -*-\n\
637 @deftypefn {Keyword} {} otherwise\n\
638 The default statement in a switch block (similar to else in an if block).\n\
639 @seealso{switch}\n\
640 @end deftypefn"),
641 
642  pair_type ("parfor",
643  "-*- texinfo -*-\n\
644 @deftypefn {Keyword} {} parfor @var{i} = @var{range}\n\
645 @deftypefnx {Keyword} {} parfor (@var{i} = @var{range}, @var{maxproc})\n\
646 Begin a for loop that may execute in parallel.\n\
647 \n\
648 @example\n\
649 @group\n\
650 parfor i = 1:10\n\
651  i\n\
652 endparfor\n\
653 @end group\n\
654 @end example\n\
655 @seealso{for, do, while}\n\
656 @end deftypefn"),
657 
658  pair_type ("persistent",
659  "-*- texinfo -*-\n\
660 @deftypefn {Keyword} {} persistent @var{var}\n\
661 Declare variables as persistent. A variable that has been declared\n\
662 persistent within a function will retain its contents in memory between\n\
663 subsequent calls to the same function. The difference between persistent\n\
664 variables and global variables is that persistent variables are local in \n\
665 scope to a particular function and are not visible elsewhere.\n\
666 @seealso{global}\n\
667 @end deftypefn"),
668 
669  pair_type ("return",
670  "-*- texinfo -*-\n\
671 @deftypefn {Keyword} {} return\n\
672 Return from a function.\n\
673 @seealso{function}\n\
674 @end deftypefn"),
675 
676  pair_type ("static",
677  "-*- texinfo -*-\n\
678 @deftypefn {Keyword} {} static\n\
679 This function has been deprecated in favor of persistent.\n\
680 @seealso{persistent}\n\
681 @end deftypefn"),
682 
683  pair_type ("switch",
684  "-*- texinfo -*-\n\
685 @deftypefn {Keyword} {} switch @var{statement}\n\
686 Begin a switch block.\n\
687 \n\
688 @example\n\
689 @group\n\
690 yesno = \"yes\"\n\
691 \n\
692 switch yesno\n\
693  case @{\"Yes\" \"yes\" \"YES\" \"y\" \"Y\"@}\n\
694  value = 1;\n\
695  case @{\"No\" \"no\" \"NO\" \"n\" \"N\"@}\n\
696  value = 0;\n\
697  otherwise\n\
698  error (\"invalid value\");\n\
699 endswitch\n\
700 @end group\n\
701 @end example\n\
702 @seealso{if, case, otherwise}\n\
703 @end deftypefn"),
704 
705  pair_type ("try",
706  "-*- texinfo -*-\n\
707 @deftypefn {Keyword} {} try\n\
708 Begin a try-catch block.\n\
709 \n\
710 If an error occurs within a try block, then the catch code will be run and\n\
711 execution will proceed after the catch block (though it is often\n\
712 recommended to use the lasterr function to re-throw the error after cleanup\n\
713 is completed).\n\
714 @seealso{catch, unwind_protect}\n\
715 @end deftypefn"),
716 
717  pair_type ("until",
718  "-*- texinfo -*-\n\
719 @deftypefn {Keyword} {} until\n\
720 End a do-until loop. See @code{do} for an example.\n\
721 @seealso{do}\n\
722 @end deftypefn"),
723 
724  pair_type ("unwind_protect",
725  "-*- texinfo -*-\n\
726 @deftypefn {Keyword} {} unwind_protect\n\
727 Begin an unwind_protect block.\n\
728 \n\
729 If an error occurs within the first part of an unwind_protect block\n\
730 the commands within the unwind_protect_cleanup block are executed before\n\
731 the error is thrown. If an error is not thrown, then the\n\
732 unwind_protect_cleanup block is still executed (in other words, the\n\
733 unwind_protect_cleanup will be run with or without an error in the\n\
734 unwind_protect block).\n\
735 @seealso{unwind_protect_cleanup, try}\n\
736 @end deftypefn"),
737 
738  pair_type ("unwind_protect_cleanup",
739  "-*- texinfo -*-\n\
740 @deftypefn {Keyword} {} unwind_protect_cleanup\n\
741 Begin the cleanup section of an unwind_protect block.\n\
742 @seealso{unwind_protect}\n\
743 @end deftypefn"),
744 
745  pair_type ("varargin",
746  "-*- texinfo -*-\n\
747 @deftypefn {Keyword} {} varargin\n\
748 Pass an arbitrary number of arguments into a function.\n\
749 @seealso{varargout, nargin, isargout, nargout, nthargout}\n\
750 @end deftypefn"),
751 
752  pair_type ("varargout",
753  "-*- texinfo -*-\n\
754 @deftypefn {Keyword} {} varargout\n\
755 Pass an arbitrary number of arguments out of a function.\n\
756 @seealso{varargin, nargin, isargout, nargout, nthargout}\n\
757 @end deftypefn"),
758 
759  pair_type ("while",
760  "-*- texinfo -*-\n\
761 @deftypefn {Keyword} {} while\n\
762 Begin a while loop.\n\
763 \n\
764 @example\n\
765 @group\n\
766 i = 0;\n\
767 while (i < 10)\n\
768  i++\n\
769 endwhile\n\
770 @end group\n\
771 @end example\n\
772 @seealso{do, endwhile, for, until}\n\
773 @end deftypefn"),
774 };
775 
776 // Return a copy of the operator or keyword names.
777 static string_vector
778 names (const map_type& lst)
779 {
780  string_vector retval (lst.size ());
781  int j = 0;
782  for (map_iter iter = lst.begin (); iter != lst.end (); iter ++)
783  retval[j++] = iter->first;
784  return retval;
785 }
786 
787 const static map_type operators_map (operators, operators + size (operators));
788 const static map_type keywords_map (keywords, keywords + size (keywords));
790 
791 // FIXME: It's not likely that this does the right thing now.
792 
795 {
796  const int key_len = keyword_names.length ();
797 
799  const int bif_len = bif.length ();
800 
802  const int cfl_len = cfl.length ();
803 
805  const int lcl_len = lcl.length ();
806 
807  const string_vector ffl = load_path::fcn_names ();
808  const int ffl_len = ffl.length ();
809 
810  const string_vector afl = autoloaded_functions ();
811  const int afl_len = afl.length ();
812 
813  const int total_len
814  = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len;
815 
816  string_vector list (total_len);
817 
818  // Put all the symbols in one big list.
819 
820  int j = 0;
821  int i = 0;
822  for (i = 0; i < key_len; i++)
823  list[j++] = keyword_names[i];
824 
825  for (i = 0; i < bif_len; i++)
826  list[j++] = bif[i];
827 
828  for (i = 0; i < cfl_len; i++)
829  list[j++] = cfl[i];
830 
831  for (i = 0; i < lcl_len; i++)
832  list[j++] = lcl[i];
833 
834  for (i = 0; i < ffl_len; i++)
835  list[j++] = ffl[i];
836 
837  for (i = 0; i < afl_len; i++)
838  list[j++] = afl[i];
839 
840  return list;
841 }
842 
843 static bool
844 looks_like_html (const std::string& msg)
845 {
846  const size_t p1 = msg.find ('\n');
847  std::string t = msg.substr (0, p1);
848  // FIXME: this comparison should be case-insensitive
849  const size_t p2 = t.find ("<html");
850 
851  return (p2 != std::string::npos);
852 }
853 
854 static bool
855 looks_like_texinfo (const std::string& msg, size_t& p1)
856 {
857  p1 = msg.find ('\n');
858 
859  std::string t = msg.substr (0, p1);
860 
861  if (p1 == std::string::npos)
862  p1 = 0;
863 
864  size_t p2 = t.find ("-*- texinfo -*-");
865 
866  return (p2 != std::string::npos);
867 }
868 
869 static bool
870 raw_help_from_symbol_table (const std::string& nm, std::string& h,
871  std::string& w, bool& symbol_found)
872 {
873  bool retval = false;
874 
876 
877  if (val.is_defined ())
878  {
879  octave_function *fcn = val.function_value ();
880 
881  if (fcn)
882  {
883  symbol_found = true;
884 
885  h = fcn->doc_string ();
886 
887  retval = true;
888 
889  w = fcn->fcn_file_name ();
890 
891  if (w.empty ())
892  w = fcn->is_user_function ()
893  ? "command-line function" : "built-in function";
894  }
895  }
896 
897  return retval;
898 }
899 
900 static bool
901 raw_help_from_file (const std::string& nm, std::string& h,
902  std::string& file, bool& symbol_found)
903 {
904  bool retval = false;
905 
906  h = get_help_from_file (nm, symbol_found, file);
907 
908  if (h.length () > 0)
909  retval = true;
910 
911  return retval;
912 }
913 
914 static bool
915 raw_help_from_map (const std::string& nm, std::string& h,
916  const map_type& map, bool& symbol_found)
917 {
918  map_iter idx = map.find (nm);
919  symbol_found = (idx != map.end ());
920  h = (symbol_found) ? idx->second : "";
921  return symbol_found;
922 }
923 
924 std::string
925 raw_help (const std::string& nm, bool& symbol_found)
926 {
927  std::string h;
928  std::string w;
929  std::string f;
930 
931  (raw_help_from_symbol_table (nm, h, w, symbol_found)
932  || raw_help_from_file (nm, h, f, symbol_found)
933  || raw_help_from_map (nm, h, operators_map, symbol_found)
934  || raw_help_from_map (nm, h, keywords_map, symbol_found));
935 
936  return h;
937 }
938 
939 DEFUN (built_in_docstrings_file, args, nargout,
940  "-*- texinfo -*-\n\
941 @deftypefn {Built-in Function} {@var{val} =} built_in_docstrings_file ()\n\
942 @deftypefnx {Built-in Function} {@var{old_val} =} built_in_docstrings_file (@var{new_val})\n\
943 @deftypefnx {Built-in Function} {} built_in_docstrings_file (@var{new_val}, \"local\")\n\
944 Query or set the internal variable that specifies the name of the\n\
945 file containing docstrings for built-in Octave functions.\n\
946 The default value is\n\
947 @file{@var{octave-home}/share/octave/@var{version}/etc/built-in-docstrings},\n\
948 in which @var{octave-home} is the root directory of the Octave installation,\n\
949 and @var{version} is the Octave version number.\n\
950 The default value may be overridden by the environment variable\n\
951 @w{@env{OCTAVE_BUILT_IN_DOCSTRINGS_FILE}}, or the command line argument\n\
952 @samp{--built-in-docstrings-file FNAME}.\n\
953 \n\
954 Note: This variable is only used when Octave is initializing itself.\n\
955 Modifying it during a running session of Octave will have no effect.\n\
956 @end deftypefn")
957 {
958  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (built_in_docstrings_file);
959 }
960 
961 void
963 {
964  std::string fname = Vbuilt_in_docstrings_file;
965 
966  std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
967 
968  if (file)
969  {
970  // Ignore header;
971  file.ignore (1000, 0x1d);
972 
973  if (file.gcount () == 1000)
974  {
975  // We use std::cerr here instead of calling Octave's warning
976  // function because install_built_in_docstrings is called
977  // before the interpreter is initialized, so warning messages
978  // won't work properly.
979 
980  std::cerr << "warning: is builtin-docstrings file corrupted?"
981  << std::endl;
982  return;
983  }
984 
985  // FIXME: eliminate fixed buffer size.
986  size_t bufsize = 100000;
987 
988  OCTAVE_LOCAL_BUFFER (char, buf, bufsize);
989 
990  while (! file.eof ())
991  {
992  file.getline (buf, bufsize, 0x1d);
993 
994  std::string tmp (buf);
995 
996  size_t pos = tmp.find ('\n');
997 
998  std::string fcn = tmp.substr (0, pos);
999 
1001 
1002  if (ov.is_defined ())
1003  {
1004  octave_function *fp = ov.function_value ();
1005 
1006  if (fp)
1007  {
1008  tmp = tmp.substr (pos+1);
1009 
1010  // Strip @c FILENAME which is part of current DOCSTRINGS
1011  // syntax. This may disappear if a specific format for
1012  // docstring files is developed.
1013  while (tmp.length () > 2 && tmp[0] == '@' && tmp[1] == 'c')
1014  {
1015  pos = tmp.find ('\n');
1016  tmp = tmp.substr (pos+1);
1017  }
1018 
1019  fp->document (tmp);
1020  }
1021  }
1022  }
1023  }
1024  else
1025  {
1026  // See note above about using std::cerr instead of warning.
1027 
1028  std::cerr << "warning: docstring file '" << fname << "' not found"
1029  << std::endl;
1030  }
1031 
1032 }
1033 
1034 static void
1035 do_get_help_text (const std::string& name, std::string& text,
1036  std::string& format)
1037 {
1038  bool symbol_found = false;
1039  text = raw_help (name, symbol_found);
1040 
1041  format = "Not found";
1042  if (symbol_found)
1043  {
1044  size_t idx = -1;
1045  if (text.empty ())
1046  {
1047  format = "Not documented";
1048  }
1049  else if (looks_like_texinfo (text, idx))
1050  {
1051  format = "texinfo";
1052  text.erase (0, idx);
1053  }
1054  else if (looks_like_html (text))
1055  {
1056  format = "html";
1057  }
1058  else
1059  {
1060  format = "plain text";
1061  }
1062  }
1063 }
1064 
1065 DEFUN (get_help_text, args, , "-*- texinfo -*-\n\
1066 @deftypefn {Built-in Function} {[@var{text}, @var{format}] =} get_help_text (@var{name})\n\
1067 Return the raw help text of function @var{name}.\n\
1068 \n\
1069 The raw help text is returned in @var{text} and the format in @var{format}\n\
1070 The format is a string which is one of @qcode{\"texinfo\"},\n\
1071 @qcode{\"html\"}, or @qcode{\"plain text\"}.\n\
1072 @end deftypefn")
1073 {
1074  octave_value_list retval;
1075 
1076  if (args.length () == 1)
1077  {
1078  const std::string name = args (0).string_value ();
1079 
1080  if (! error_state)
1081  {
1082  std::string text;
1083  std::string format;
1084 
1085  do_get_help_text (name, text, format);
1086 
1087  retval(1) = format;
1088  retval(0) = text;
1089  }
1090  else
1091  error ("get_help_text: invalid input");
1092  }
1093  else
1094  print_usage ();
1095 
1096  return retval;
1097 }
1098 
1099 static void
1100 do_get_help_text_from_file (const std::string& fname, std::string& text,
1101  std::string& format)
1102 {
1103  bool symbol_found = false;
1104 
1105  std::string f;
1106 
1107  raw_help_from_file (fname, text, f, symbol_found);
1108 
1109  format = "Not found";
1110  if (symbol_found)
1111  {
1112  size_t idx = -1;
1113  if (text.empty ())
1114  {
1115  format = "Not documented";
1116  }
1117  else if (looks_like_texinfo (text, idx))
1118  {
1119  format = "texinfo";
1120  text.erase (0, idx);
1121  }
1122  else if (looks_like_html (text))
1123  {
1124  format = "html";
1125  }
1126  else
1127  {
1128  format = "plain text";
1129  }
1130  }
1131 }
1132 
1133 DEFUN (get_help_text_from_file, args, ,
1134  "-*- texinfo -*-\n\
1135 @deftypefn {Built-in Function} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})\n\
1136 Return the raw help text from the file @var{fname}.\n\
1137 \n\
1138 The raw help text is returned in @var{text} and the format in @var{format}\n\
1139 The format is a string which is one of @qcode{\"texinfo\"},\n\
1140 @qcode{\"html\"}, or @qcode{\"plain text\"}.\n\
1141 @end deftypefn")
1142 {
1143  octave_value_list retval;
1144 
1145  if (args.length () == 1)
1146  {
1147  const std::string fname = args(0).string_value ();
1148 
1149  if (! error_state)
1150  {
1151  std::string text;
1152  std::string format;
1153 
1154  do_get_help_text_from_file (fname, text, format);
1155 
1156  retval(1) = format;
1157  retval(0) = text;
1158  }
1159  else
1160  error ("get_help_text_from_file: invalid input");
1161  }
1162  else
1163  print_usage ();
1164 
1165  return retval;
1166 }
1167 
1168 // Return a cell array of strings containing the names of all
1169 // operators.
1170 
1171 DEFUN (__operators__, , ,
1172  "-*- texinfo -*-\n\
1173 @deftypefn {Function File} __operators__ ()\n\
1174 Undocumented internal function.\n\
1175 @end deftypefn")
1176 {
1177  return octave_value (Cell (names (operators_map)));
1178 }
1179 
1180 // Return a cell array of strings containing the names of all
1181 // keywords.
1182 
1183 DEFUN (__keywords__, , ,
1184  "-*- texinfo -*-\n\
1185 @deftypefn {Function File} __keywords__ ()\n\
1186 Undocumented internal function.\n\
1187 @end deftypefn")
1188 {
1189  return octave_value (Cell (names (keywords_map)));
1190 }
1191 
1192 // Return a cell array of strings containing the names of all builtin
1193 // functions.
1194 
1195 DEFUN (__builtins__, , ,
1196  "-*- texinfo -*-\n\
1197 @deftypefn {Function File} __builtins__ ()\n\
1198 Undocumented internal function.\n\
1199 @end deftypefn")
1200 {
1202 
1203  return octave_value (Cell (bif));
1204 }
1205 
1206 static std::string
1207 do_which (const std::string& name, std::string& type)
1208 {
1209  std::string file;
1210 
1211  type = std::string ();
1212 
1214 
1215  if (name.find_first_of ('.') == std::string::npos)
1216  {
1217  if (val.is_defined ())
1218  {
1219  octave_function *fcn = val.function_value ();
1220 
1221  if (fcn)
1222  {
1223  file = fcn->fcn_file_name ();
1224 
1225  if (file.empty ())
1226  {
1227  if (fcn->is_user_function ())
1228  type = "command-line function";
1229  else
1230  {
1231  file = fcn->src_file_name ();
1232  type = "built-in function";
1233  }
1234  }
1235  else
1236  type = val.is_user_script ()
1237  ? std::string ("script") : std::string ("function");
1238  }
1239  }
1240  else
1241  {
1242  // We might find a file that contains only a doc string.
1243 
1244  file = load_path::find_fcn_file (name);
1245  }
1246  }
1247  else
1248  {
1249  // File query.
1250 
1251  // For compatibility: "file." queries "file".
1252  if (name.size () > 1 && name[name.size () - 1] == '.')
1253  file = load_path::find_file (name.substr (0, name.size () - 1));
1254  else
1255  file = load_path::find_file (name);
1256 
1257  file = octave_env::make_absolute (file);
1258  }
1259 
1260 
1261  return file;
1262 }
1263 
1264 std::string
1265 do_which (const std::string& name)
1266 {
1267  std::string retval;
1268 
1269  std::string type;
1270 
1271  retval = do_which (name, type);
1272 
1273  return retval;
1274 }
1275 
1276 DEFUN (__which__, args, ,
1277  "-*- texinfo -*-\n\
1278 @deftypefn {Built-in Function} {} __which__ (@var{name}, @dots{})\n\
1279 Undocumented internal function.\n\
1280 @end deftypefn")
1281 {
1282  octave_value retval;
1283 
1284  string_vector argv = args.make_argv ("which");
1285 
1286  if (! error_state)
1287  {
1288  int argc = argv.length ();
1289 
1290  if (argc > 1)
1291  {
1292  octave_map m (dim_vector (1, argc-1));
1293 
1294  Cell names (1, argc-1);
1295  Cell files (1, argc-1);
1296  Cell types (1, argc-1);
1297 
1298  for (int i = 1; i < argc; i++)
1299  {
1300  std::string name = argv[i];
1301 
1302  std::string type;
1303 
1304  std::string file = do_which (name, type);
1305 
1306  names(i-1) = name;
1307  files(i-1) = file;
1308  types(i-1) = type;
1309  }
1310 
1311  m.assign ("name", names);
1312  m.assign ("file", files);
1313  m.assign ("type", types);
1314 
1315  retval = m;
1316  }
1317  else
1318  print_usage ();
1319  }
1320 
1321  return retval;
1322 }
1323 
1324 // FIXME: Are we sure this function always does the right thing?
1325 inline bool
1326 file_is_in_dir (const std::string filename, const std::string dir)
1327 {
1328  if (filename.find (dir) == 0)
1329  {
1330  const int dir_len = dir.size ();
1331  const int filename_len = filename.size ();
1332  const int max_allowed_seps = file_ops::is_dir_sep (dir[dir_len-1]) ? 0
1333  : 1;
1334 
1335  int num_seps = 0;
1336  for (int i = dir_len; i < filename_len; i++)
1337  if (file_ops::is_dir_sep (filename[i]))
1338  num_seps ++;
1339 
1340  return (num_seps <= max_allowed_seps);
1341  }
1342  else
1343  return false;
1344 }
1345 
1346 // Return a cell array of strings containing the names of all
1347 // functions available in DIRECTORY. If no directory is given, search
1348 // the current path.
1349 
1350 DEFUN (__list_functions__, args, ,
1351  "-*- texinfo -*-\n\
1352 @deftypefn {Function File} {@var{retval} =} __list_functions__ ()\n\
1353 @deftypefnx {Function File} {@var{retval} =} __list_functions__ (@var{directory})\n\
1354 Undocumented internal function.\n\
1355 @end deftypefn")
1356 {
1357  octave_value retval;
1358 
1359  // Get list of functions
1362 
1363  if (args.length () == 0)
1364  retval = Cell (ffl.append (afl));
1365  else
1366  {
1367  std::string dir = args (0).string_value ();
1368 
1369  if (! error_state)
1370  {
1371  string_vector fl = load_path::files (dir, true);
1372 
1373  if (! error_state)
1374  {
1375  // Return a sorted list with unique entries (in case of
1376  // .m and .oct versions of the same function in a given
1377  // directory, for example).
1378  fl.sort (true);
1379 
1380  retval = Cell (fl);
1381  }
1382  }
1383  else
1384  error ("__list_functions__: DIRECTORY argument must be a string");
1385  }
1386 
1387  return retval;
1388 }
1389 
1390 DEFUN (doc_cache_file, args, nargout,
1391  "-*- texinfo -*-\n\
1392 @deftypefn {Built-in Function} {@var{val} =} doc_cache_file ()\n\
1393 @deftypefnx {Built-in Function} {@var{old_val} =} doc_cache_file (@var{new_val})\n\
1394 @deftypefnx {Built-in Function} {} doc_cache_file (@var{new_val}, \"local\")\n\
1395 Query or set the internal variable that specifies the name of the\n\
1396 Octave documentation cache file. A cache file significantly improves\n\
1397 the performance of the @code{lookfor} command. The default value is \n\
1398 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},\n\
1399 in which @var{octave-home} is the root directory of the Octave installation,\n\
1400 and @var{version} is the Octave version number.\n\
1401 The default value may be overridden by the environment variable\n\
1402 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument\n\
1403 @samp{--doc-cache-file FNAME}.\n\
1404 \n\
1405 When called from inside a function with the @qcode{\"local\"} option, the\n\
1406 variable is changed locally for the function and any subroutines it calls. \n\
1407 The original variable value is restored when exiting the function.\n\
1408 @seealso{doc_cache_create, lookfor, info_program, doc, help, makeinfo_program}\n\
1409 @end deftypefn")
1410 {
1411  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file);
1412 }
1413 
1414 DEFUN (texi_macros_file, args, nargout,
1415  "-*- texinfo -*-\n\
1416 @deftypefn {Built-in Function} {@var{val} =} texi_macros_file ()\n\
1417 @deftypefnx {Built-in Function} {@var{old_val} =} texi_macros_file (@var{new_val})\n\
1418 @deftypefnx {Built-in Function} {} texi_macros_file (@var{new_val}, \"local\")\n\
1419 Query or set the internal variable that specifies the name of the\n\
1420 file containing Texinfo macros that are prepended to documentation strings\n\
1421 before they are passed to makeinfo. The default value is \n\
1422 @file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},\n\
1423 in which @var{octave-home} is the root directory of the Octave installation,\n\
1424 and @var{version} is the Octave version number.\n\
1425 The default value may be overridden by the environment variable\n\
1426 @w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument\n\
1427 @samp{--texi-macros-file FNAME}.\n\
1428 \n\
1429 When called from inside a function with the @qcode{\"local\"} option, the\n\
1430 variable is changed locally for the function and any subroutines it calls. \n\
1431 The original variable value is restored when exiting the function.\n\
1432 @seealso{makeinfo_program}\n\
1433 @end deftypefn")
1434 {
1435  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (texi_macros_file);
1436 }
1437 
1438 DEFUN (info_file, args, nargout,
1439  "-*- texinfo -*-\n\
1440 @deftypefn {Built-in Function} {@var{val} =} info_file ()\n\
1441 @deftypefnx {Built-in Function} {@var{old_val} =} info_file (@var{new_val})\n\
1442 @deftypefnx {Built-in Function} {} info_file (@var{new_val}, \"local\")\n\
1443 Query or set the internal variable that specifies the name of the\n\
1444 Octave info file. The default value is\n\
1445 @file{@var{octave-home}/info/octave.info}, in\n\
1446 which @var{octave-home} is the root directory of the Octave installation.\n\
1447 The default value may be overridden by the environment variable\n\
1448 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument\n\
1449 @samp{--info-file FNAME}.\n\
1450 \n\
1451 When called from inside a function with the @qcode{\"local\"} option, the\n\
1452 variable is changed locally for the function and any subroutines it calls. \n\
1453 The original variable value is restored when exiting the function.\n\
1454 @seealso{info_program, doc, help, makeinfo_program}\n\
1455 @end deftypefn")
1456 {
1457  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file);
1458 }
1459 
1460 DEFUN (info_program, args, nargout,
1461  "-*- texinfo -*-\n\
1462 @deftypefn {Built-in Function} {@var{val} =} info_program ()\n\
1463 @deftypefnx {Built-in Function} {@var{old_val} =} info_program (@var{new_val})\n\
1464 @deftypefnx {Built-in Function} {} info_program (@var{new_val}, \"local\")\n\
1465 Query or set the internal variable that specifies the name of the\n\
1466 info program to run. The default value is\n\
1467 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info}\n\
1468 in which @var{octave-home} is the root directory of the Octave installation,\n\
1469 @var{version} is the Octave version number, and @var{arch}\n\
1470 is the system type (for example, @code{i686-pc-linux-gnu}). The\n\
1471 default value may be overridden by the environment variable\n\
1472 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument\n\
1473 @samp{--info-program NAME}.\n\
1474 \n\
1475 When called from inside a function with the @qcode{\"local\"} option, the\n\
1476 variable is changed locally for the function and any subroutines it calls. \n\
1477 The original variable value is restored when exiting the function.\n\
1478 @seealso{info_file, doc, help, makeinfo_program}\n\
1479 @end deftypefn")
1480 {
1481  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program);
1482 }
1483 
1484 DEFUN (makeinfo_program, args, nargout,
1485  "-*- texinfo -*-\n\
1486 @deftypefn {Built-in Function} {@var{val} =} makeinfo_program ()\n\
1487 @deftypefnx {Built-in Function} {@var{old_val} =} makeinfo_program (@var{new_val})\n\
1488 @deftypefnx {Built-in Function} {} makeinfo_program (@var{new_val}, \"local\")\n\
1489 Query or set the internal variable that specifies the name of the\n\
1490 program that Octave runs to format help text containing\n\
1491 Texinfo markup commands. The default value is @code{makeinfo}.\n\
1492 \n\
1493 When called from inside a function with the @qcode{\"local\"} option, the\n\
1494 variable is changed locally for the function and any subroutines it calls. \n\
1495 The original variable value is restored when exiting the function.\n\
1496 @seealso{texi_macros_file, info_file, info_program, doc, help}\n\
1497 @end deftypefn")
1498 {
1499  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program);
1500 }
1501 
1502 DEFUN (suppress_verbose_help_message, args, nargout,
1503  "-*- texinfo -*-\n\
1504 @deftypefn {Built-in Function} {@var{val} =} suppress_verbose_help_message ()\n\
1505 @deftypefnx {Built-in Function} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})\n\
1506 @deftypefnx {Built-in Function} {} suppress_verbose_help_message (@var{new_val}, \"local\")\n\
1507 Query or set the internal variable that controls whether Octave\n\
1508 will add additional help information to the end of the output from\n\
1509 the @code{help} command and usage messages for built-in commands.\n\
1510 \n\
1511 When called from inside a function with the @qcode{\"local\"} option, the\n\
1512 variable is changed locally for the function and any subroutines it calls. \n\
1513 The original variable value is restored when exiting the function.\n\
1514 @end deftypefn")
1515 {
1516  return SET_INTERNAL_VARIABLE (suppress_verbose_help_message);
1517 }