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
oct-hist.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 /*
24 
25 The functions listed below were adapted from similar functions from
26 GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
27 Software Foundation, Inc.
28 
29  do_history edit_history_readline
30  do_edit_history edit_history_add_hist
31 
32 */
33 
34 #if defined (HAVE_CONFIG_H)
35 # include "config.h"
36 #endif
37 
38 #include <cstdlib>
39 #include <cstring>
40 
41 #include <fstream>
42 #include <string>
43 
44 #include "cmd-hist.h"
45 #include "file-ops.h"
46 #include "lo-mappers.h"
47 #include "octave-link.h"
48 #include "oct-env.h"
49 #include "oct-time.h"
50 #include "str-vec.h"
51 #include "unistd-wrappers.h"
52 
53 #include <defaults.h>
54 #include "defun.h"
55 #include "error.h"
56 #include "errwarn.h"
57 #include "input.h"
58 #include "oct-hist.h"
59 #include "ovl.h"
60 #include "pager.h"
61 #include "parse.h"
62 #include "sighandlers.h"
63 #include "sysdep.h"
64 #include "interpreter.h"
65 #include "unwind-prot.h"
66 #include "utils.h"
67 #include "variables.h"
68 
69 // TRUE means input is coming from temporary history file.
71 
72 static std::string
74 {
76 
77  std::string env_file = octave::sys::env::getenv ("OCTAVE_HISTFILE");
78 
79  if (! env_file.empty ())
80  file = env_file;
81 
82  if (file.empty ())
84  ".octave_hist");
85 
86  return file;
87 }
88 
89 static int
91 {
92  int size = 1000;
93 
94  std::string env_size = octave::sys::env::getenv ("OCTAVE_HISTSIZE");
95 
96  if (! env_size.empty ())
97  {
98  int val;
99 
100  if (sscanf (env_size.c_str (), "%d", &val) == 1)
101  size = val > 0 ? val : 0;
102  }
103 
104  return size;
105 }
106 
107 static std::string
109 {
110  return
111  std::string ("# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <")
113  + std::string ("@")
115  + std::string (">");
116 }
117 
118 // The format of the timestamp marker written to the history file when
119 // Octave exits.
122 
123 // Display, save, or load history. Stolen and modified from bash.
124 //
125 // Arg of -w FILENAME means write file, arg of -r FILENAME
126 // means read file, arg of -q means don't number lines. Arg of N
127 // means only display that many items.
128 
129 static string_vector
131 {
132  bool numbered_output = nargout == 0;
133 
135 
136  string_vector hlist;
137 
140 
141  int nargin = args.length ();
142 
143  // Number of history lines to show (-1 = all)
144  int limit = -1;
145 
146  for (octave_idx_type i = 0; i < nargin; i++)
147  {
148  octave_value arg = args(i);
149 
151 
152  if (arg.is_string ())
153  option = arg.string_value ();
154  else if (arg.is_numeric_type ())
155  {
156  limit = arg.int_value ();
157  if (limit < 0)
158  limit = -limit;
159  continue;
160  }
161  else
162  err_wrong_type_arg ("history", arg);
163 
164  if (option == "-r" || option == "-w" || option == "-a"
165  || option == "-n")
166  {
167  if (i < nargin - 1)
168  {
170  = args(++i).xstring_value ("history: filename must be a string for %s option",
171  option.c_str ());
172 
174  }
175  else
177 
178  if (option == "-a")
179  // Append 'new' lines to file.
181 
182  else if (option == "-w")
183  // Write entire history.
185 
186  else if (option == "-r")
187  {
188  // Read entire file.
191  }
192 
193  else if (option == "-n")
194  {
195  // Read 'new' history from file.
198  }
199 
200  else
201  panic_impossible ();
202 
203  return hlist;
204  }
205  else if (option == "-c")
206  {
209  }
210  else if (option == "-q")
211  numbered_output = false;
212  else if (option == "--")
213  {
214  i++;
215  break;
216  }
217  else
218  {
219  // The last argument found in the command list that looks like
220  // an integer will be used
221  int tmp;
222 
223  if (sscanf (option.c_str (), "%d", &tmp) == 1)
224  {
225  if (tmp > 0)
226  limit = tmp;
227  else
228  limit = -tmp;
229  }
230 
231  else
232  {
233  if (option.length () > 0 && option[0] == '-')
234  error ("history: unrecognized option '%s'", option.c_str ());
235  else
236  error ("history: bad non-numeric arg '%s'", option.c_str ());
237  }
238  }
239  }
240 
241  hlist = octave::command_history::list (limit, numbered_output);
242 
243  int len = hlist.numel ();
244 
245  if (nargout == 0)
246  {
247  for (octave_idx_type i = 0; i < len; i++)
248  octave_stdout << hlist[i] << "\n";
249  }
250 
251  return hlist;
252 }
253 
254 // Read the edited history lines from STREAM and return them
255 // one at a time. This can read unlimited length lines. The
256 // caller should free the storage.
257 
258 static char *
259 edit_history_readline (std::fstream& stream)
260 {
261  char c;
262  int line_len = 128;
263  int lindex = 0;
264  char *line = new char [line_len];
265  line[0] = '\0';
266 
267  while (stream.get (c))
268  {
269  if (lindex + 2 >= line_len)
270  {
271  char *tmp_line = new char [line_len += 128];
272  strcpy (tmp_line, line);
273  delete [] line;
274  line = tmp_line;
275  }
276 
277  if (c == '\n')
278  {
279  line[lindex++] = '\n';
280  line[lindex++] = '\0';
281  return line;
282  }
283  else
284  line[lindex++] = c;
285  }
286 
287  if (! lindex)
288  {
289  delete [] line;
290  return 0;
291  }
292 
293  if (lindex + 2 >= line_len)
294  {
295  char *tmp_line = new char [lindex+3];
296  strcpy (tmp_line, line);
297  delete [] line;
298  line = tmp_line;
299  }
300 
301  // Finish with newline if none in file.
302 
303  line[lindex++] = '\n';
304  line[lindex++] = '\0';
305  return line;
306 }
307 
308 static void
310 {
311  if (! line.empty ())
312  {
313  std::string tmp = line;
314 
315  int len = tmp.length ();
316 
317  if (len > 0 && tmp[len-1] == '\n')
318  tmp.resize (len - 1);
319 
320  if (! tmp.empty ())
323  }
324 }
325 
326 static bool
328 {
329  bool ok = true;
330 
331  if (arg.is_string ())
332  {
333  std::string tmp = arg.string_value ();
334 
335  ok = sscanf (tmp.c_str (), "%d", &val) == 1;
336  }
337  else if (arg.is_numeric_type ())
338  val = arg.int_value ();
339  else
340  ok = false;
341 
342  return ok;
343 }
344 
345 static std::string
347  bool insert_curr, const char *warn_for)
348 {
350 
351  int hist_count = hlist.numel () - 1; // switch to zero-based indexing
352 
353  // The current command line is already part of the history list by
354  // the time we get to this point. Delete the cmd from the list when
355  // executing 'edit_history' so that it doesn't show up in the history
356  // but the actual commands performed will.
357 
358  if (! insert_curr)
359  octave::command_history::remove (hist_count);
360 
361  hist_count--; // skip last entry in history list
362 
363  // If no numbers have been specified, the default is to edit the
364  // last command in the history list.
365 
366  int hist_beg = hist_count;
367  int hist_end = hist_count;
368 
369  bool reverse = false;
370 
371  // Process options.
372 
373  int nargin = args.length ();
374 
375  if (nargin == 2)
376  {
377  if (! get_int_arg (args(0), hist_beg)
378  || ! get_int_arg (args(1), hist_end))
379  error ("%s: arguments must be integers", warn_for);
380 
381  if (hist_beg < 0)
382  hist_beg += (hist_count + 1);
383  else
384  hist_beg--;
385  if (hist_end < 0)
386  hist_end += (hist_count + 1);
387  else
388  hist_end--;
389  }
390  else if (nargin == 1)
391  {
392  if (! get_int_arg (args(0), hist_beg))
393  error ("%s: argument must be an integer", warn_for);
394 
395  if (hist_beg < 0)
396  hist_beg += (hist_count + 1);
397  else
398  hist_beg--;
399 
400  hist_end = hist_beg;
401  }
402 
403  if (hist_beg > hist_count || hist_end > hist_count)
404  error ("%s: history specification out of range", warn_for);
405 
406  if (hist_end < hist_beg)
407  {
408  std::swap (hist_end, hist_beg);
409  reverse = true;
410  }
411 
412  std::string name = octave::sys::tempnam ("", "oct-");
413 
414  std::fstream file (name.c_str (), std::ios::out);
415 
416  if (! file)
417  error ("%s: couldn't open temporary file '%s'", warn_for,
418  name.c_str ());
419 
420  if (reverse)
421  {
422  for (int i = hist_end; i >= hist_beg; i--)
423  file << hlist[i] << "\n";
424  }
425  else
426  {
427  for (int i = hist_beg; i <= hist_end; i++)
428  file << hlist[i] << "\n";
429  }
430 
431  file.close ();
432 
433  return name;
434 }
435 
436 static void
437 unlink_cleanup (const char *file)
438 {
439  octave_unlink_wrapper (file);
440 }
441 
442 static void
444 {
445  std::string name = mk_tmp_hist_file (args, false, "edit_history");
446 
447  if (name.empty ())
448  return;
449 
450  // Call up our favorite editor on the file of commands.
451 
452  std::string cmd = VEDITOR;
453  cmd.append (" \"" + name + "\"");
454 
455  // Ignore interrupts while we are off editing commands. Should we
456  // maybe avoid using system()?
457 
458  volatile octave::interrupt_handler old_interrupt_handler
460 
461  int status = system (cmd.c_str ());
462 
463  octave::set_interrupt_handler (old_interrupt_handler);
464 
465  // Check if text edition was successfull. Abort the operation
466  // in case of failure.
467  if (status != EXIT_SUCCESS)
468  error ("edit_history: text editor command failed");
469 
470  // Write the commands to the history file since source_file
471  // disables command line history while it executes.
472 
473  std::fstream file (name.c_str (), std::ios::in);
474 
475  char *line;
476  //int first = 1;
477  while ((line = edit_history_readline (file)) != 0)
478  {
479  // Skip blank lines.
480 
481  if (line[0] == '\n')
482  {
483  delete [] line;
484  continue;
485  }
486 
487  edit_history_add_hist (line);
488 
489  delete [] line;
490  }
491 
492  file.close ();
493 
494  // Turn on command echo, so the output from this will make better
495  // sense.
496 
498 
499  frame.add_fcn (unlink_cleanup, name.c_str ());
501  frame.protect_var (input_from_tmp_history_file);
502 
504  input_from_tmp_history_file = true;
505 
506  source_file (name);
507 }
508 
509 static void
511 {
512  std::string name = mk_tmp_hist_file (args, false, "run_history");
513 
514  if (name.empty ())
515  return;
516 
517  // Turn on command echo so the output from this will make better sense.
518 
520 
521  frame.add_fcn (unlink_cleanup, name.c_str ());
523  frame.protect_var (input_from_tmp_history_file);
524 
526  input_from_tmp_history_file = true;
527 
528  source_file (name);
529 }
530 
531 void
532 initialize_history (bool read_history_file)
533 {
534  octave::command_history::initialize (read_history_file,
537  octave::sys::env::getenv ("OCTAVE_HISTCONTROL"));
538 
540 }
541 
542 void
544 {
546 
548 
549  if (! timestamp.empty ())
550  if (octave::command_history::add (timestamp))
551  octave_link::append_history (timestamp);
552 }
553 
554 DEFUN (edit_history, args, ,
555  doc: /* -*- texinfo -*-
556 @deftypefn {} {} edit_history
557 @deftypefnx {} {} edit_history @var{cmd_number}
558 @deftypefnx {} {} edit_history @var{first} @var{last}
559 Edit the history list using the editor named by the variable @env{EDITOR}.
560 
561 The commands to be edited are first copied to a temporary file. When you
562 exit the editor, Octave executes the commands that remain in the file. It
563 is often more convenient to use @code{edit_history} to define functions
564 rather than attempting to enter them directly on the command line.
565 The block of commands is executed as soon as you exit the editor.
566 To avoid executing any commands, simply delete all the lines from the buffer
567 before leaving the editor.
568 
569 When invoked with no arguments, edit the previously executed command;
570 With one argument, edit the specified command @var{cmd_number};
571 With two arguments, edit the list of commands between @var{first} and
572 @var{last}. Command number specifiers may also be negative where -1
573 refers to the most recently executed command.
574 The following are equivalent and edit the most recently executed command.
575 
576 @example
577 @group
578 edit_history
579 edit_history -1
580 @end group
581 @end example
582 
583 When using ranges, specifying a larger number for the first command than the
584 last command reverses the list of commands before they are placed in the
585 buffer to be edited.
586 @seealso{run_history, history}
587 @end deftypefn */)
588 {
589  if (args.length () > 2)
590  print_usage ();
591 
593 
594  return ovl ();
595 }
596 
597 DEFUN (history, args, nargout,
598  doc: /* -*- texinfo -*-
599 @deftypefn {} {} history
600 @deftypefnx {} {} history @var{opt1} @dots{}
601 @deftypefnx {} {@var{h} =} history ()
602 @deftypefnx {} {@var{h} =} history (@var{opt1}, @dots{})
603 If invoked with no arguments, @code{history} displays a list of commands
604 that you have executed.
605 
606 Valid options are:
607 
608 @table @code
609 @item @var{n}
610 @itemx -@var{n}
611 Display only the most recent @var{n} lines of history.
612 
613 @item -c
614 Clear the history list.
615 
616 @item -q
617 Don't number the displayed lines of history. This is useful for cutting
618 and pasting commands using the X Window System.
619 
620 @item -r @var{file}
621 Read the file @var{file}, appending its contents to the current
622 history list. If the name is omitted, use the default history file
623 (normally @file{~/.octave_hist}).
624 
625 @item -w @var{file}
626 Write the current history to the file @var{file}. If the name is
627 omitted, use the default history file (normally @file{~/.octave_hist}).
628 @end table
629 
630 For example, to display the five most recent commands that you have
631 typed without displaying line numbers, use the command
632 @kbd{history -q 5}.
633 
634 If invoked with a single output argument, the history will be saved to that
635 argument as a cell string and will not be output to screen.
636 @seealso{edit_history, run_history}
637 @end deftypefn */)
638 {
639  // Call do_history even if nargout is zero to display history list.
640 
642 
643  return nargout > 0 ? ovl (Cell (hlist)) : ovl ();
644 }
645 
646 DEFUN (run_history, args, ,
647  doc: /* -*- texinfo -*-
648 @deftypefn {} {} run_history
649 @deftypefnx {} {} run_history @var{cmd_number}
650 @deftypefnx {} {} run_history @var{first} @var{last}
651 Run commands from the history list.
652 
653 When invoked with no arguments, run the previously executed command;
654 
655 With one argument, run the specified command @var{cmd_number};
656 
657 With two arguments, run the list of commands between @var{first} and
658 @var{last}. Command number specifiers may also be negative where -1
659 refers to the most recently executed command. For example, the command
660 
661 @example
662 @group
663 run_history
664  OR
665 run_history -1
666 @end group
667 @end example
668 
669 @noindent
670 executes the most recent command again.
671 The command
672 
673 @example
674 run_history 13 169
675 @end example
676 
677 @noindent
678 executes commands 13 through 169.
679 
680 Specifying a larger number for the first command than the last command
681 reverses the list of commands before executing them.
682 For example:
683 
684 @example
685 @group
686 disp (1)
687 disp (2)
688 run_history -1 -2
689 @result{}
690  2
691  1
692 @end group
693 @end example
694 
695 @seealso{edit_history, history}
696 @end deftypefn */)
697 {
698  if (args.length () > 2)
699  print_usage ();
700 
702 
703  return ovl ();
704 }
705 
706 DEFUN (history_control, args, nargout,
707  doc: /* -*- texinfo -*-
708 @deftypefn {} {@var{val} =} history_control ()
709 @deftypefnx {} {@var{old_val} =} history_control (@var{new_val})
710 Query or set the internal variable that specifies how commands are saved
711 to the history list.
712 
713 The default value is an empty character string, but may be overridden by the
714 environment variable @w{@env{OCTAVE_HISTCONTROL}}.
715 
716 The value of @code{history_control} is a colon-separated list of values
717 controlling how commands are saved on the history list. If the list
718 of values includes @code{ignorespace}, lines which begin with a space
719 character are not saved in the history list. A value of @code{ignoredups}
720 causes lines matching the previous history entry to not be saved.
721 A value of @code{ignoreboth} is shorthand for @code{ignorespace} and
722 @code{ignoredups}. A value of @code{erasedups} causes all previous lines
723 matching the current line to be removed from the history list before that
724 line is saved. Any value not in the above list is ignored. If
725 @code{history_control} is the empty string, all commands are saved on
726 the history list, subject to the value of @code{history_save}.
727 @seealso{history_file, history_size, history_timestamp_format_string, history_save}
728 @end deftypefn */)
729 {
731 
732  std::string old_history_control = octave::command_history::histcontrol ();
733 
734  std::string tmp = old_history_control;
735 
736  retval = set_internal_variable (tmp, args, nargout, "history_control");
737 
738  if (tmp != old_history_control)
740 
741  return retval;
742 }
743 
744 DEFUN (history_size, args, nargout,
745  doc: /* -*- texinfo -*-
746 @deftypefn {} {@var{val} =} history_size ()
747 @deftypefnx {} {@var{old_val} =} history_size (@var{new_val})
748 Query or set the internal variable that specifies how many entries
749 to store in the history file.
750 
751 The default value is @code{1000}, but may be overridden by the environment
752 variable @w{@env{OCTAVE_HISTSIZE}}.
753 @seealso{history_file, history_timestamp_format_string, history_save}
754 @end deftypefn */)
755 {
757 
758  int old_history_size = octave::command_history::size ();
759 
760  int tmp = old_history_size;
761 
762  retval = set_internal_variable (tmp, args, nargout,
763  "history_size", -1,
765 
766  if (tmp != old_history_size)
768 
769  return retval;
770 }
771 
772 DEFUN (history_file, args, nargout,
773  doc: /* -*- texinfo -*-
774 @deftypefn {} {@var{val} =} history_file ()
775 @deftypefnx {} {@var{old_val} =} history_file (@var{new_val})
776 Query or set the internal variable that specifies the name of the
777 file used to store command history.
778 
779 The default value is @file{~/.octave_hist}, but may be overridden by the
780 environment variable @w{@env{OCTAVE_HISTFILE}}.
781 @seealso{history_size, history_save, history_timestamp_format_string}
782 @end deftypefn */)
783 {
785 
786  std::string old_history_file = octave::command_history::file ();
787 
788  std::string tmp = old_history_file;
789 
790  retval = set_internal_variable (tmp, args, nargout, "history_file");
791 
792  if (tmp != old_history_file)
794 
795  return retval;
796 }
797 
798 DEFUN (history_timestamp_format_string, args, nargout,
799  doc: /* -*- texinfo -*-
800 @deftypefn {} {@var{val} =} history_timestamp_format_string ()
801 @deftypefnx {} {@var{old_val} =} history_timestamp_format_string (@var{new_val})
802 @deftypefnx {} {} history_timestamp_format_string (@var{new_val}, "local")
803 Query or set the internal variable that specifies the format string
804 for the comment line that is written to the history file when Octave
805 exits.
806 
807 The format string is passed to @code{strftime}. The default value is
808 
809 @example
810 "# Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>"
811 @end example
812 
813 When called from inside a function with the @qcode{"local"} option, the
814 variable is changed locally for the function and any subroutines it calls.
815 The original variable value is restored when exiting the function.
816 @seealso{strftime, history_file, history_size, history_save}
817 @end deftypefn */)
818 {
819  return SET_INTERNAL_VARIABLE (history_timestamp_format_string);
820 }
821 
822 DEFUN (history_save, args, nargout,
823  doc: /* -*- texinfo -*-
824 @deftypefn {} {@var{val} =} history_save ()
825 @deftypefnx {} {@var{old_val} =} history_save (@var{new_val})
826 @deftypefnx {} {} history_save (@var{new_val}, "local")
827 Query or set the internal variable that controls whether commands entered
828 on the command line are saved in the history file.
829 
830 When called from inside a function with the @qcode{"local"} option, the
831 variable is changed locally for the function and any subroutines it calls.
832 The original variable value is restored when exiting the function.
833 @seealso{history_control, history_file, history_size, history_timestamp_format_string}
834 @end deftypefn */)
835 {
837 
838  bool old_history_save = ! octave::command_history::ignoring_entries ();
839 
840  bool tmp = old_history_save;
841 
842  retval = set_internal_variable (tmp, args, nargout, "history_save");
843 
844  if (tmp != old_history_save)
846 
847  return retval;
848 }
static void write(const std::string &="")
Definition: cmd-hist.cc:726
static std::string histcontrol(void)
Definition: cmd-hist.cc:572
option
Definition: sighandlers.cc:767
Definition: Cell.h:37
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
static void read(bool=true)
Definition: cmd-hist.cc:699
fname
Definition: load-save.cc:754
static void clear(void)
Definition: cmd-hist.cc:622
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
octave_idx_type length(void) const
Definition: ovl.h:96
std::string tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:670
octave::sys::time now
Definition: data.cc:6299
bool is_numeric_type(void) const
Definition: ov.h:679
static std::string Vhistory_timestamp_format_string
Definition: oct-hist.cc:121
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:746
static string_vector do_history(const octave_value_list &args, int nargout)
Definition: oct-hist.cc:130
static void unlink_cleanup(const char *file)
Definition: oct-hist.cc:437
void protect_var(T &var)
static void set_size(int)
Definition: cmd-hist.cc:579
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
void error(const char *fmt,...)
Definition: error.cc:570
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:126
static void ignore_entries(bool=true)
Definition: cmd-hist.cc:593
static std::string default_history_timestamp_format(void)
Definition: oct-hist.cc:108
static bool add(const std::string &)
Definition: cmd-hist.cc:607
octave_value arg
Definition: pr-output.cc:3440
static void do_run_history(const octave_value_list &args)
Definition: oct-hist.cc:510
static std::string getenv(const std::string &name)
Definition: oct-env.cc:235
static void edit_history_add_hist(const std::string &line)
Definition: oct-hist.cc:309
void initialize_history(bool read_history_file)
Definition: oct-hist.cc:532
return ovl()
bool swap
Definition: load-save.cc:725
JNIEnv void * args
Definition: ov-java.cc:67
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 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
void add_fcn(void(*fcn)(void))
static std::string get_home_directory(void)
Definition: oct-env.cc:143
static string_vector list(int=-1, bool=false)
Definition: cmd-hist.cc:747
void octave_history_write_timestamp(void)
Definition: oct-hist.cc:543
std::string string_value(bool force=false) const
Definition: ov.h:908
static std::string mk_tmp_hist_file(const octave_value_list &args, bool insert_curr, const char *warn_for)
Definition: oct-hist.cc:346
int octave_unlink_wrapper(const char *nm)
int nargin
Definition: graphics.cc:10115
bool is_string(void) const
Definition: ov.h:578
static std::string get_host_name(void)
Definition: oct-env.cc:185
static std::string get_user_name(void)
Definition: oct-env.cc:178
OCTINTERP_API octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
double tmp
Definition: data.cc:6300
octave_value retval
Definition: data.cc:6294
#define panic_impossible()
Definition: error.h:40
static void read_range(int=-1, int=-1, bool=true)
Definition: cmd-hist.cc:712
interrupt_handler ignore_interrupts(void)
Definition: sighandlers.cc:572
std::string VEDITOR
Definition: defaults.cc:88
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 void initialize(bool, const std::string &, int, const std::string &)
Definition: cmd-hist.cc:530
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:156
#define OCTAVE_VERSION
Definition: main.cc:49
static std::string concat(const std::string &, const std::string &)
Definition: file-ops.cc:375
octave::unwind_protect frame
Definition: graphics.cc:11584
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:228
int Vecho_executing_commands
Definition: input.cc:93
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values text mode reading and writing automatically converts linefeeds to the appropriate line end character for the system(carriage-return linefeed on Windows, carriage-return on Macintosh).The default when no mode is specified is binary mode.Additionally
#define octave_stdout
Definition: pager.h:146
bool input_from_tmp_history_file
Definition: oct-hist.cc:70
static bool get_int_arg(const octave_value &arg, int &val)
Definition: oct-hist.cc:327
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
static void set_file(const std::string &)
Definition: cmd-hist.cc:547
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
Definition: sighandlers.cc:585
static int default_history_size(void)
Definition: oct-hist.cc:90
static bool ignoring_entries(void)
Definition: cmd-hist.cc:600
static std::string default_history_file(void)
Definition: oct-hist.cc:73
static char * edit_history_readline(std::fstream &stream)
Definition: oct-hist.cc:259
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 or any other valid Octave code The number of return their size
Definition: input.cc:871
OCTINTERP_API void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true, const std::string &warn_for="")
static int size(void)
Definition: cmd-hist.cc:586
static void append(const std::string &="")
Definition: cmd-hist.cc:733
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 void do_edit_history(const octave_value_list &args)
Definition: oct-hist.cc:443
static void remove(int)
Definition: cmd-hist.cc:615
static std::string file(void)
Definition: cmd-hist.cc:558
std::string strftime(const std::string &fmt) const
Definition: oct-time.cc:147
static void process_histcontrol(const std::string &)
Definition: cmd-hist.cc:565