GNU Octave  4.2.1
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-2017 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 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <cstdlib>
28 #include <cstring>
29 
30 #include <algorithm>
31 #include <fstream>
32 #include <iostream>
33 #include <map>
34 #include <sstream>
35 #include <string>
36 
37 #include "cmd-edit.h"
38 #include "file-ops.h"
39 #include "file-stat.h"
40 #include "oct-env.h"
41 #include "oct-locbuf.h"
42 #include "str-vec.h"
43 
44 #include "call-stack.h"
45 #include <defaults.h>
46 #include "Cell.h"
47 #include "defun.h"
48 #include "dirfns.h"
49 #include "error.h"
50 #include "errwarn.h"
51 #include "help.h"
52 #include "input.h"
53 #include "load-path.h"
54 #include "ovl.h"
55 #include "ov-usr-fcn.h"
56 #include "ov-fcn-handle.h"
57 #include "pager.h"
58 #include "parse.h"
59 #include "pathsearch.h"
60 #include "procstream.h"
61 #include "pt-pr-code.h"
62 #include "sighandlers.h"
63 #include "symtab.h"
64 #include "interpreter.h"
65 #include "unwind-prot.h"
66 #include "utils.h"
67 #include "variables.h"
68 #include "version.h"
69 #include "quit.h"
70 
71 // Name of the doc cache file specified on the command line.
72 // (--doc-cache-file file)
74 
75 // Name of the file containing local Texinfo macros that are prepended
76 // to doc strings before processing.
77 // (--texi-macros-file)
79 
80 // Name of the info file specified on command line.
81 // (--info-file file)
83 
84 // Name of the info reader we'd like to use.
85 // (--info-program program)
87 
88 // Name of the makeinfo program to run.
89 static std::string Vmakeinfo_program = "makeinfo";
90 
91 // If TRUE, don't print additional help message in help and usage
92 // functions.
93 static bool Vsuppress_verbose_help_message = false;
94 
95 const static char * const operators[] =
96 {
97  "!",
98  "~",
99  "!=",
100  "~=",
101  "\"",
102  "#",
103  "%",
104  "#{",
105  "%{",
106  "#}",
107  "%}",
108  "...",
109  "&",
110  "&&",
111  "'",
112  "(",
113  ")",
114  "*",
115  "**",
116  "^",
117  "+",
118  "++",
119  ",",
120  "-",
121  "--",
122  ".'",
123  ".*",
124  ".**",
125  ".^",
126  "./",
127  "/",
128  ".\\",
129  "\\",
130  ":",
131  ";",
132  "<",
133  "<=",
134  "=",
135  "==",
136  ">",
137  ">=",
138  "[",
139  "]",
140  "|",
141  "||",
142  0
143 };
144 
145 const static string_vector operator_names (operators);
146 
147 const static char * const keywords[] =
148 {
149  "break",
150  "case",
151  "catch",
152  "continue",
153  "do",
154  "else",
155  "elseif",
156  "end",
157  "end_try_catch",
158  "end_unwind_protect",
159  "endfor",
160  "endfunction",
161  "endif",
162  "endparfor",
163  "endswitch",
164  "endwhile",
165  "for",
166  "function",
167  "global",
168  "if",
169  "otherwise",
170  "parfor",
171  "persistent",
172  "return",
173  "static",
174  "switch",
175  "try",
176  "until",
177  "unwind_protect",
178  "unwind_protect_cleanup",
179  "varargin",
180  "varargout",
181  "while",
182  0
183 };
184 
185 const static string_vector keyword_names (keywords);
186 
187 // Return a vector of all functions from this file,
188 // for use in command line auto-completion.
189 static string_vector
191 {
193 
195 
196  if (! curr_fcn)
197  return retval;
198 
199  // All subfunctions are listed in the top-level function of this file.
200  while (curr_fcn->is_subfunction ())
201  curr_fcn = symbol_table::get_curr_fcn (curr_fcn->parent_fcn_scope ());
202 
203  // Get subfunctions.
204  const std::list<std::string> names = curr_fcn->subfunction_names ();
205 
206  size_t sz = names.size ();
207  retval.resize (sz);
208 
209  // Loop over them.
210  size_t i = 0;
211  for (std::list<std::string>::const_iterator p = names.begin ();
212  p != names.end (); p++)
213  retval(i++) = *p;
214 
215  retval.resize (i);
216  return retval;
217 }
218 
219 // FIXME: It's not likely that this does the right thing now.
220 
223 {
224  const int key_len = keyword_names.numel ();
225 
227  const int bif_len = bif.numel ();
228 
230  const int cfl_len = cfl.numel ();
231 
233  const int lcl_len = lcl.numel ();
234 
235  const string_vector ffl = load_path::fcn_names ();
236  const int ffl_len = ffl.numel ();
237 
238  const string_vector afl = autoloaded_functions ();
239  const int afl_len = afl.numel ();
240 
241  const string_vector lfl = local_functions ();
242  const int lfl_len = lfl.numel ();
243 
244  const int total_len
245  = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
246 
247  string_vector list (total_len);
248 
249  // Put all the symbols in one big list.
250 
251  int j = 0;
252  int i = 0;
253  for (i = 0; i < key_len; i++)
254  list[j++] = keyword_names[i];
255 
256  for (i = 0; i < bif_len; i++)
257  list[j++] = bif[i];
258 
259  for (i = 0; i < cfl_len; i++)
260  list[j++] = cfl[i];
261 
262  for (i = 0; i < lcl_len; i++)
263  list[j++] = lcl[i];
264 
265  for (i = 0; i < ffl_len; i++)
266  list[j++] = ffl[i];
267 
268  for (i = 0; i < afl_len; i++)
269  list[j++] = afl[i];
270 
271  for (i = 0; i < lfl_len; i++)
272  list[j++] = lfl[i];
273 
274  return list;
275 }
276 
277 static bool
279 {
280  const size_t p1 = msg.find ('\n');
281  std::string t = msg.substr (0, p1);
282  // FIXME: this comparison should be case-insensitive
283  const size_t p2 = t.find ("<html");
284 
285  return (p2 != std::string::npos);
286 }
287 
288 static bool
289 looks_like_texinfo (const std::string& msg, size_t& p1)
290 {
291  p1 = msg.find ('\n');
292 
293  std::string t = msg.substr (0, p1);
294 
295  if (p1 == std::string::npos)
296  p1 = 0;
297 
298  size_t p2 = t.find ("-*- texinfo -*-");
299 
300  return (p2 != std::string::npos);
301 }
302 
303 static bool
305  std::string& w, bool& symbol_found)
306 {
307  bool retval = false;
308 
310 
311  if (val.is_defined ())
312  {
314 
315  if (fcn)
316  {
317  symbol_found = true;
318 
319  h = fcn->doc_string ();
320 
321  retval = true;
322 
323  w = fcn->fcn_file_name ();
324 
325  if (w.empty ())
326  w = fcn->is_user_function ()
327  ? "command-line function" : "built-in function";
328  }
329  }
330 
331  return retval;
332 }
333 
334 static bool
336  std::string& file, bool& symbol_found)
337 {
338  bool retval = false;
339 
340  h = get_help_from_file (nm, symbol_found, file);
341 
342  if (h.length () > 0)
343  retval = true;
344 
345  return retval;
346 }
347 
348 static bool
350  bool& symbol_found)
351 {
352  typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
353  typedef std::map<std::string, txt_limits_type> help_txt_map_type;
354 
355  static help_txt_map_type help_txt_map;
356  static bool initialized = false;
357 
358  h = "";
359  symbol_found = false;
360 
361  // FIXME: Should we cache the timestamp of the file and reload the
362  // offsets if it changes? Or just warn about that? Or just ignore
363  // it, and assume it won't change?
364 
365  if (! initialized)
366  {
368 
369  std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
370 
371  if (! file)
372  error ("failed to open docstrings file: %s", fname.c_str ());
373 
374  // Ignore header;
376 
377  if (file.eof ())
378  error ("invalid built-in-docstrings file!");
379 
380  // FIXME: eliminate fixed buffer size.
381  size_t bufsize = 1000;
382  OCTAVE_LOCAL_BUFFER (char, buf, bufsize);
383 
384  while (! file.eof ())
385  {
387  int i = 0;
388  int c;
389  while (file && (c = file.get ()) != std::istream::traits_type::eof ())
390  {
391  if (c == '\n' || c == '\r')
392  {
393  buf[i] = '\0';
394  name = buf;
395  break;
396  }
397  else
398  buf[i++] = c;
399  }
400 
401  // Skip @c FILENAME which is part of current DOCSTRINGS
402  // syntax. This may disappear if a specific format for
403  // docstring files is developed.
404  while (file
405  && (c = file.get ()) != std::istream::traits_type::eof ()
406  && c != '\n' && c != '\r')
407  ; // skip text
408 
409  // skip newline characters
410  while (file
411  && (c = file.get ()) != std::istream::traits_type::eof ()
412  && c == '\n' && c == '\r')
413  ; // skip text
414 
415  file.unget ();
416 
417  // Position of beginning of help text.
418  std::streampos beg = file.tellg ();
419 
420  // Skip help text.
422 
423  // Position of end of help text.
424  std::streamoff len;
425 
426  if (! file.eof ())
427  len = file.tellg () - beg - 1;
428  else
429  {
430  file.seekg (0, file.end);
431  len = file.tellg () - beg - 1;
432  file.setstate (file.eofbit); // reset eof flag
433  }
434 
435  help_txt_map[name] = txt_limits_type (beg, len);
436  }
437 
438  initialized = true;
439  }
440 
441  help_txt_map_type::const_iterator it = help_txt_map.find (nm);
442 
443  if (it != help_txt_map.end ())
444  {
445  txt_limits_type txt_limits = it->second;
446 
447  std::streampos beg = txt_limits.first;
448  std::streamoff len = txt_limits.second;
449 
451 
452  std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
453 
454  if (! file)
455  error ("failed to open docstrings file: %s", fname.c_str ());
456 
457  file.seekg (beg);
458 
459  size_t txt_len = len;
460  OCTAVE_LOCAL_BUFFER (char, buf, txt_len + 1);
461 
462  file.read (buf, txt_len);
463 
464  buf[txt_len] = '\0';
465 
466  h = buf;
467 
468  symbol_found = true;
469  }
470 
471  return symbol_found;
472 }
473 
475 raw_help (const std::string& nm, bool& symbol_found)
476 {
477  std::string h;
478  std::string w;
479  std::string f;
480 
481  bool found;
482 
483  found = raw_help_from_symbol_table (nm, h, w, symbol_found);
484 
485  if (! found)
486  found = raw_help_from_file (nm, h, f, symbol_found);
487 
488  bool external_doc = h.compare (0, 12, "external-doc") == 0;
489 
490  if (! found || external_doc)
491  {
492  std::string tmp_nm = nm;
493 
494  if (external_doc && h.length () > 12 && h[12] == ':')
495  tmp_nm = h.substr (13);
496 
497  raw_help_from_docstrings_file (tmp_nm, h, symbol_found);
498  }
499 
500  return h;
501 }
502 
503 DEFUN (built_in_docstrings_file, args, nargout,
504  doc: /* -*- texinfo -*-
505 @deftypefn {} {@var{val} =} built_in_docstrings_file ()
506 @deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val})
507 @deftypefnx {} {} built_in_docstrings_file (@var{new_val}, "local")
508 Query or set the internal variable that specifies the name of the
509 file containing docstrings for built-in Octave functions.
510 
511 The default value is
512 @file{@var{octave-home}/share/octave/@var{version}/etc/built-in-docstrings},
513 in which @var{octave-home} is the root directory of the Octave installation,
514 and @var{version} is the Octave version number. The default value may be
515 overridden by the environment variable
516 @w{@env{OCTAVE_BUILT_IN_DOCSTRINGS_FILE}}, or the command line argument
517 @option{--built-in-docstrings-file FNAME}.
518 
519 Note: This variable is only used when Octave is initializing itself.
520 Modifying it during a running session of Octave will have no effect.
521 @end deftypefn */)
522 {
523  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (built_in_docstrings_file);
524 }
525 
526 static void
527 do_get_help_text (const std::string& name, std::string& text,
529 {
530  bool symbol_found = false;
531  text = raw_help (name, symbol_found);
532 
533  format = "Not found";
534  if (symbol_found)
535  {
536  size_t idx = -1;
537  if (text.empty ())
538  {
539  format = "Not documented";
540  }
541  else if (looks_like_texinfo (text, idx))
542  {
543  format = "texinfo";
544  text.erase (0, idx);
545  }
546  else if (looks_like_html (text))
547  {
548  format = "html";
549  }
550  else
551  {
552  format = "plain text";
553  }
554  }
555 }
556 
557 DEFUN (get_help_text, args, ,
558  doc: /* -*- texinfo -*-
559 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text (@var{name})
560 Return the raw help text of function @var{name}.
561 
562 The raw help text is returned in @var{text} and the format in @var{format}
563 The format is a string which is one of @qcode{"texinfo"},
564 @qcode{"html"}, or @qcode{"plain text"}.
565 @seealso{get_help_text_from_file}
566 @end deftypefn */)
567 {
568  if (args.length () != 1)
569  print_usage ();
570 
571  const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
572 
574 
575  do_get_help_text (name, text, format);
576 
577  return ovl (text, format);
578 }
579 
580 static void
581 do_get_help_text_from_file (const std::string& fname, std::string& text,
582  std::string& format)
583 {
584  bool symbol_found = false;
585 
586  std::string f;
587 
588  raw_help_from_file (fname, text, f, symbol_found);
589 
590  format = "Not found";
591  if (symbol_found)
592  {
593  size_t idx = -1;
594  if (text.empty ())
595  {
596  format = "Not documented";
597  }
598  else if (looks_like_texinfo (text, idx))
599  {
600  format = "texinfo";
601  text.erase (0, idx);
602  }
603  else if (looks_like_html (text))
604  {
605  format = "html";
606  }
607  else
608  {
609  format = "plain text";
610  }
611  }
612 }
613 
614 DEFUN (get_help_text_from_file, args, ,
615  doc: /* -*- texinfo -*-
616 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})
617 Return the raw help text from the file @var{fname}.
618 
619 The raw help text is returned in @var{text} and the format in @var{format}
620 The format is a string which is one of @qcode{"texinfo"},
621 @qcode{"html"}, or @qcode{"plain text"}.
622 @seealso{get_help_text}
623 @end deftypefn */)
624 {
625  if (args.length () != 1)
626  print_usage ();
627 
628  const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
629 
631 
632  do_get_help_text_from_file (fname, text, format);
633 
634  return ovl (text, format);
635 }
636 
637 // Return a cell array of strings containing the names of all
638 // operators.
639 
640 DEFUN (__operators__, , ,
641  doc: /* -*- texinfo -*-
642 @deftypefn {} {} __operators__ ()
643 Undocumented internal function.
644 @end deftypefn */)
645 {
646  return ovl (Cell (operator_names));
647 }
648 
649 // Return a cell array of strings containing the names of all
650 // keywords.
651 
652 DEFUN (__keywords__, , ,
653  doc: /* -*- texinfo -*-
654 @deftypefn {} {} __keywords__ ()
655 Undocumented internal function.
656 @end deftypefn */)
657 {
658  return ovl (Cell (keyword_names));
659 }
660 
661 // Return a cell array of strings containing the names of all builtin
662 // functions.
663 
664 DEFUN (__builtins__, , ,
665  doc: /* -*- texinfo -*-
666 @deftypefn {} {} __builtins__ ()
667 Undocumented internal function.
668 @end deftypefn */)
669 {
671 
672  return ovl (Cell (bif));
673 }
674 
675 DEFUN (localfunctions, args, ,
676  doc: /* -*- texinfo -*-
677 @deftypefn {} {} localfunctions ()
678 Return a list of all local functions, i.e., subfunctions, within the current
679 file.
680 
681 The return value is a column cell array of function handles to all local
682 functions accessible from the function from which @code{localfunctions} is
683 called. Nested functions are @emph{not} included in the list.
684 
685 If the call is from the command line, an anonymous function, or a script,
686 the return value is an empty cell array.
687 
688 Compatibility Note: Subfunctions which contain nested functions are not
689 included in the list. This is a known issue.
690 @end deftypefn */)
691 {
692  if (args.length () != 0)
693  print_usage ();
694 
695  Cell retval;
696 
697  // Find the main function we are in.
699 
700  if (! parent_fcn)
701  return ovl (retval);
702 
703  // Find the subfunctions of this function.
704  // FIXME: This includes all nested functions.
705  // Once handles of nested functions are implemented,
706  // we will need to exclude ones not in scope.
707  const std::list<std::string> names = parent_fcn->subfunction_names ();
708  const std::map<std::string, octave_value> h = parent_fcn->subfunctions ();
709 
710  size_t sz = names.size ();
711  retval.resize (dim_vector (sz, 1));
712 
713  // loop over them.
714  size_t i = 0;
715  for (std::list<std::string>::const_iterator p = names.begin ();
716  p != names.end (); p++)
717  {
718  std::map<std::string, octave_value>::const_iterator q = h.find (*p);
719  if (q != h.end () &&
720  ! q->second.user_function_value ()->is_nested_function ())
721  retval(i++) = octave_value (new octave_fcn_handle (q->second, *p));
722  }
723 
724  // remove pre-allocation for nested functions
725  retval.resize (dim_vector (i, 1));
726 
727  return ovl (retval);
728 }
729 
730 /*
731 %!test
732 %! f = tempname (".", "oct_");
733 %! fcn_name = f(3:end);
734 %! f = [f ".m"];
735 %! unwind_protect
736 %! fid = fopen (f, "w+");
737 %! fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
738 %! fprintf (fid, "function z = b(x)\n z = x+1; end\n");
739 %! fprintf (fid, "function z = c(x)\n z = 2*x; end\n");
740 %! fclose (fid);
741 %! d = eval (fcn_name);
742 %! assert (size (d), [2, 1]);
743 %! assert (d{1}(3), 4);
744 %! assert (d{2}(3), 6);
745 %! unwind_protect_cleanup
746 %! unlink (f);
747 %! end_unwind_protect
748 */
749 
750 static std::string
751 do_which (const std::string& name, std::string& type)
752 {
754 
755  type = "";
756 
758 
759  if (name.find_first_of ('.') == std::string::npos)
760  {
761  if (val.is_defined ())
762  {
764 
765  if (fcn)
766  {
767  file = fcn->fcn_file_name ();
768 
769  if (file.empty ())
770  {
771  if (fcn->is_user_function ())
772  type = "command-line function";
773  else
774  {
775  file = fcn->src_file_name ();
776  type = "built-in function";
777  }
778  }
779  else
780  type = val.is_user_script ()
781  ? std::string ("script") : std::string ("function");
782  }
783  }
784  else
785  {
786  // We might find a file that contains only a doc string.
787 
788  file = load_path::find_fcn_file (name);
789  }
790  }
791  else
792  {
793  // File query.
794 
795  // For compatibility: "file." queries "file".
796  if (name.size () > 1 && name[name.size () - 1] == '.')
797  file = load_path::find_file (name.substr (0, name.size () - 1));
798  else
799  file = load_path::find_file (name);
800 
801  file = octave::sys::env::make_absolute (file);
802  }
803 
804  return file;
805 }
806 
808 do_which (const std::string& name)
809 {
811 
813 
814  retval = do_which (name, type);
815 
816  return retval;
817 }
818 
819 DEFUN (__which__, args, ,
820  doc: /* -*- texinfo -*-
821 @deftypefn {} {} __which__ (@var{name}, @dots{})
822 Undocumented internal function.
823 @end deftypefn */)
824 {
825  string_vector argv = args.make_argv ();
826 
827  int nargin = argv.numel ();
828 
829  octave_map m (dim_vector (1, nargin));
830 
831  Cell names (1, nargin);
832  Cell files (1, nargin);
833  Cell types (1, nargin);
834 
835  for (int i = 0; i < nargin; i++)
836  {
837  std::string name = argv[i];
838 
840 
841  std::string file = do_which (name, type);
842 
843  names(i) = name;
844  files(i) = file;
845  types(i) = type;
846  }
847 
848  m.assign ("name", names);
849  m.assign ("file", files);
850  m.assign ("type", types);
851 
852  return ovl (m);
853 }
854 
855 // FIXME: Are we sure this function always does the right thing?
856 inline bool
857 file_is_in_dir (const std::string filename, const std::string dir)
858 {
859  if (filename.find (dir) == 0)
860  {
861  const int dir_len = dir.size ();
862  const int filename_len = filename.size ();
863  const int max_allowed_seps = octave::sys::file_ops::is_dir_sep (dir[dir_len-1]) ? 0
864  : 1;
865 
866  int num_seps = 0;
867  for (int i = dir_len; i < filename_len; i++)
868  if (octave::sys::file_ops::is_dir_sep (filename[i]))
869  num_seps++;
870 
871  return (num_seps <= max_allowed_seps);
872  }
873  else
874  return false;
875 }
876 
877 // Return a cell array of strings containing the names of all
878 // functions available in DIRECTORY. If no directory is given, search
879 // the current path.
880 
881 DEFUN (__list_functions__, args, ,
882  doc: /* -*- texinfo -*-
883 @deftypefn {} {@var{retval} =} __list_functions__ ()
884 @deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory})
885 Return a list of all functions (.m and .oct functions) in the load path.
886 
887 If the optional argument @var{directory} is given then list only the functions
888 in that directory.
889 @seealso{path}
890 @end deftypefn */)
891 {
893 
894  if (args.length () == 0)
895  {
896  // Get list of all functions
899 
900  retval = Cell (ffl.append (afl));
901  }
902  else
903  {
904  std::string dir = args(0).xstring_value ("__list_functions__: DIRECTORY argument must be a string");
905 
906  string_vector fl = load_path::files (dir, true);
907 
908  // Return a sorted list with unique entries (in case of .m and .oct
909  // versions of the same function in a given directory, for example).
910  fl.sort (true);
911 
912  retval = Cell (fl);
913  }
914 
915  return retval;
916 }
917 
918 DEFUN (doc_cache_file, args, nargout,
919  doc: /* -*- texinfo -*-
920 @deftypefn {} {@var{val} =} doc_cache_file ()
921 @deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val})
922 @deftypefnx {} {} doc_cache_file (@var{new_val}, "local")
923 Query or set the internal variable that specifies the name of the
924 Octave documentation cache file.
925 
926 A cache file significantly improves the performance of the @code{lookfor}
927 command. The default value is
928 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},
929 in which @var{octave-home} is the root directory of the Octave installation,
930 and @var{version} is the Octave version number.
931 The default value may be overridden by the environment variable
932 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument
933 @option{--doc-cache-file FNAME}.
934 
935 When called from inside a function with the @qcode{"local"} option, the
936 variable is changed locally for the function and any subroutines it calls.
937 The original variable value is restored when exiting the function.
938 @seealso{doc_cache_create, lookfor, info_program, doc, help, makeinfo_program}
939 @seealso{lookfor}
940 @end deftypefn */)
941 {
942  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file);
943 }
944 
945 DEFUN (texi_macros_file, args, nargout,
946  doc: /* -*- texinfo -*-
947 @deftypefn {} {@var{val} =} texi_macros_file ()
948 @deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val})
949 @deftypefnx {} {} texi_macros_file (@var{new_val}, "local")
950 Query or set the internal variable that specifies the name of the
951 file containing Texinfo macros that are prepended to documentation strings
952 before they are passed to makeinfo.
953 
954 The default value is
955 @file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},
956 in which @var{octave-home} is the root directory of the Octave installation,
957 and @var{version} is the Octave version number.
958 The default value may be overridden by the environment variable
959 @w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument
960 @option{--texi-macros-file FNAME}.
961 
962 When called from inside a function with the @qcode{"local"} option, the
963 variable is changed locally for the function and any subroutines it calls.
964 The original variable value is restored when exiting the function.
965 @seealso{makeinfo_program}
966 @end deftypefn */)
967 {
968  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (texi_macros_file);
969 }
970 
971 DEFUN (info_file, args, nargout,
972  doc: /* -*- texinfo -*-
973 @deftypefn {} {@var{val} =} info_file ()
974 @deftypefnx {} {@var{old_val} =} info_file (@var{new_val})
975 @deftypefnx {} {} info_file (@var{new_val}, "local")
976 Query or set the internal variable that specifies the name of the
977 Octave info file.
978 
979 The default value is
980 @file{@var{octave-home}/info/octave.info}, in
981 which @var{octave-home} is the root directory of the Octave installation.
982 The default value may be overridden by the environment variable
983 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument
984 @option{--info-file FNAME}.
985 
986 When called from inside a function with the @qcode{"local"} option, the
987 variable is changed locally for the function and any subroutines it calls.
988 The original variable value is restored when exiting the function.
989 @seealso{info_program, doc, help, makeinfo_program}
990 @end deftypefn */)
991 {
992  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file);
993 }
994 
995 DEFUN (info_program, args, nargout,
996  doc: /* -*- texinfo -*-
997 @deftypefn {} {@var{val} =} info_program ()
998 @deftypefnx {} {@var{old_val} =} info_program (@var{new_val})
999 @deftypefnx {} {} info_program (@var{new_val}, "local")
1000 Query or set the internal variable that specifies the name of the
1001 info program to run.
1002 
1003 The default value is
1004 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info}
1005 in which @var{octave-home} is the root directory of the Octave installation,
1006 @var{version} is the Octave version number, and @var{arch} is the system
1007 type (for example, @code{i686-pc-linux-gnu}). The default value may be
1008 overridden by the environment variable
1009 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument
1010 @option{--info-program NAME}.
1011 
1012 When called from inside a function with the @qcode{"local"} option, the
1013 variable is changed locally for the function and any subroutines it calls.
1014 The original variable value is restored when exiting the function.
1015 @seealso{info_file, doc, help, makeinfo_program}
1016 @end deftypefn */)
1017 {
1018  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program);
1019 }
1020 
1021 DEFUN (makeinfo_program, args, nargout,
1022  doc: /* -*- texinfo -*-
1023 @deftypefn {} {@var{val} =} makeinfo_program ()
1024 @deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val})
1025 @deftypefnx {} {} makeinfo_program (@var{new_val}, "local")
1026 Query or set the internal variable that specifies the name of the
1027 program that Octave runs to format help text containing
1028 Texinfo markup commands.
1029 
1030 The default value is @code{makeinfo}.
1031 
1032 When called from inside a function with the @qcode{"local"} option, the
1033 variable is changed locally for the function and any subroutines it calls.
1034 The original variable value is restored when exiting the function.
1035 @seealso{texi_macros_file, info_file, info_program, doc, help}
1036 @end deftypefn */)
1037 {
1038  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program);
1039 }
1040 
1041 DEFUN (suppress_verbose_help_message, args, nargout,
1042  doc: /* -*- texinfo -*-
1043 @deftypefn {} {@var{val} =} suppress_verbose_help_message ()
1044 @deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})
1045 @deftypefnx {} {} suppress_verbose_help_message (@var{new_val}, "local")
1046 Query or set the internal variable that controls whether Octave
1047 will add additional help information to the end of the output from
1048 the @code{help} command and usage messages for built-in commands.
1049 
1050 When called from inside a function with the @qcode{"local"} option, the
1051 variable is changed locally for the function and any subroutines it calls.
1052 The original variable value is restored when exiting the function.
1053 @end deftypefn */)
1054 {
1055  return SET_INTERNAL_VARIABLE (suppress_verbose_help_message);
1056 }
static const string_vector operator_names(operators)
virtual std::map< std::string, octave_value > subfunctions(void) const
Definition: ov-usr-fcn.cc:66
Definition: Cell.h:37
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
fname
Definition: load-save.cc:754
std::string Vinfo_file
Definition: help.cc:82
static std::list< std::string > cmdline_function_names(void)
Definition: symtab.h:2172
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition: oct-hist.cc:728
void assign(const std::string &k, const Cell &val)
Definition: oct-map.h:347
std::string Vinfo_program
Definition: help.cc:86
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API void print_usage(void)
Definition: defun.cc:52
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
bool is_defined(void) const
Definition: ov.h:536
std::string doc_string(void) const
Definition: ov-fcn.h:175
static std::string find_file(const std::string &file)
Definition: load-path.h:200
static bool raw_help_from_file(const std::string &nm, std::string &h, std::string &file, bool &symbol_found)
Definition: help.cc:335
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
void error(const char *fmt,...)
Definition: error.cc:570
string_vector autoloaded_functions(void)
Definition: oct-parse.cc:8234
std::string raw_help(const std::string &nm, bool &symbol_found)
Definition: help.cc:475
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:126
static const string_vector keyword_names(keywords)
STL namespace.
std::string filename
Definition: urlwrite.cc:340
static std::list< std::string > variable_names(scope_id scope=xcurrent_scope)
Definition: symtab.h:2146
static const char *const operators[]
Definition: help.cc:95
std::string Vbuilt_in_docstrings_file
Definition: defaults.cc:95
virtual std::string src_file_name(void) const
Definition: ov-fcn.h:66
std::string get_help_from_file(const std::string &nm, bool &symbol_found, std::string &full_file)
Definition: oct-parse.cc:8169
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:935
std::string Vdoc_cache_file
Definition: help.cc:73
static bool looks_like_html(const std::string &msg)
Definition: help.cc:278
static string_vector files(const std::string &dir, bool omit_exts=false)
Definition: load-path.h:241
static octave_value find_function(const std::string &name, const octave_value_list &args=octave_value_list(), bool local_funcs=true)
Definition: symtab.cc:1276
void resize(octave_idx_type n, const std::string &rfv="")
Definition: str-vec.h:97
octave_function * fcn
Definition: ov-class.cc:1743
string_vector argv
Definition: load-save.cc:635
static std::string Vmakeinfo_program
Definition: help.cc:89
static string_vector local_functions(void)
Definition: help.cc:190
OCTAVE_EXPORT octave_value_list search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
Definition: utils.cc:302
JNIEnv void * args
Definition: ov-java.cc:67
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
Definition: oct-env.cc:129
double h
Definition: graphics.cc:11205
static string_vector fcn_names(void)
Definition: load-path.h:247
static octave_user_code * caller_user_code(size_t nskip=0)
Definition: call-stack.h:172
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
std::string Vtexi_macros_file
Definition: help.cc:78
static octave_user_code * debug_user_code(void)
Definition: call-stack.h:190
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
std::complex< double > w(std::complex< double > z, double relerr=0)
int nargin
Definition: graphics.cc:10115
string_vector & append(const std::string &s)
Definition: str-vec.cc:107
OCTINTERP_API std::string do_which(const std::string &name)
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1028
octave_value retval
Definition: data.cc:6294
virtual symbol_table::scope_id parent_fcn_scope(void) const
Definition: ov-fcn.h:73
virtual std::list< std::string > subfunction_names(void) const
Definition: ov-fcn.h:154
bool is_user_script(void) const
Definition: ov.h:714
string_vector & sort(bool make_uniq=false)
Definition: str-vec.cc:74
idx type
Definition: ov.cc:3129
virtual bool is_user_function(void) const
Definition: ov-base.h:461
sz
Definition: data.cc:5342
LS_TEXT format
Definition: load-save.cc:1580
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
static octave_user_function * get_curr_fcn(scope_id scope=xcurrent_scope)
Definition: symtab.h:2316
#define SET_NONEMPTY_INTERNAL_STRING_VARIABLE(NM)
Definition: variables.h:129
static bool raw_help_from_symbol_table(const std::string &nm, std::string &h, std::string &w, bool &symbol_found)
Definition: help.cc:304
static bool looks_like_texinfo(const std::string &msg, size_t &p1)
Definition: help.cc:289
octave_function * function_value(bool silent=false) const
Definition: ov.cc:1705
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:228
virtual std::string fcn_file_name(void) const
Definition: ov-fcn.h:64
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
Definition: dlmread.cc:191
static std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
Definition: load-path.h:170
virtual bool is_subfunction(void) const
Definition: ov-fcn.h:85
otherwise an error message is printed The permission mask is a UNIX concept used when creating new objects on a file system such as files
Definition: file-io.cc:2981
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
p
Definition: lu.cc:138
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
string_vector make_name_list(void)
Definition: help.cc:222
static bool Vsuppress_verbose_help_message
Definition: help.cc:93
static bool raw_help_from_docstrings_file(const std::string &nm, std::string &h, bool &symbol_found)
Definition: help.cc:349
static const char *const keywords[]
Definition: help.cc:147
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
static std::list< std::string > built_in_function_names(void)
Definition: symtab.h:2153
static bool is_dir_sep(char c)
Definition: file-ops.h:90
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))