34 #if defined (HAVE_CONFIG_H)
79 if (! env_file.empty ())
96 if (! env_size.empty ())
100 if (sscanf (env_size.c_str (),
"%d", &
val) == 1)
101 size = val > 0 ? val : 0;
132 bool numbered_output = nargout == 0;
164 if (option ==
"-r" || option ==
"-w" || option ==
"-a"
170 =
args(++
i).xstring_value (
"history: filename must be a string for %s option",
182 else if (option ==
"-w")
186 else if (option ==
"-r")
193 else if (option ==
"-n")
205 else if (option ==
"-c")
210 else if (option ==
"-q")
211 numbered_output =
false;
212 else if (option ==
"--")
223 if (sscanf (option.c_str (),
"%d", &
tmp) == 1)
233 if (option.length () > 0 && option[0] ==
'-')
234 error (
"history: unrecognized option '%s'", option.c_str ());
236 error (
"history: bad non-numeric arg '%s'", option.c_str ());
243 int len = hlist.
numel ();
264 char *
line =
new char [line_len];
267 while (stream.get (c))
269 if (lindex + 2 >= line_len)
271 char *tmp_line =
new char [line_len += 128];
272 strcpy (tmp_line, line);
279 line[lindex++] =
'\n';
280 line[lindex++] =
'\0';
293 if (lindex + 2 >= line_len)
295 char *tmp_line =
new char [lindex+3];
296 strcpy (tmp_line, line);
303 line[lindex++] =
'\n';
304 line[lindex++] =
'\0';
315 int len = tmp.length ();
317 if (len > 0 && tmp[len-1] ==
'\n')
318 tmp.resize (len - 1);
335 ok = sscanf (tmp.c_str (),
"%d", &
val) == 1;
347 bool insert_curr,
const char *warn_for)
351 int hist_count = hlist.
numel () - 1;
366 int hist_beg = hist_count;
367 int hist_end = hist_count;
369 bool reverse =
false;
379 error (
"%s: arguments must be integers", warn_for);
382 hist_beg += (hist_count + 1);
386 hist_end += (hist_count + 1);
390 else if (nargin == 1)
393 error (
"%s: argument must be an integer", warn_for);
396 hist_beg += (hist_count + 1);
403 if (hist_beg > hist_count || hist_end > hist_count)
404 error (
"%s: history specification out of range", warn_for);
406 if (hist_end < hist_beg)
414 std::fstream
file (name.c_str (), std::ios::out);
417 error (
"%s: couldn't open temporary file '%s'", warn_for,
422 for (
int i = hist_end;
i >= hist_beg;
i--)
423 file << hlist[
i] <<
"\n";
427 for (
int i = hist_beg;
i <= hist_end;
i++)
428 file << hlist[
i] <<
"\n";
453 cmd.append (
" \"" + name +
"\"");
461 int status =
system (cmd.c_str ());
467 if (status != EXIT_SUCCESS)
468 error (
"edit_history: text editor command failed");
473 std::fstream
file (name.c_str (), std::ios::in);
504 input_from_tmp_history_file =
true;
526 input_from_tmp_history_file =
true;
549 if (! timestamp.empty ())
589 if (
args.length () > 2)
698 if (
args.length () > 2)
738 if (tmp != old_history_control)
760 int tmp = old_history_size;
766 if (tmp != old_history_size)
792 if (tmp != old_history_file)
840 bool tmp = old_history_save;
844 if (tmp != old_history_save)
static void write(const std::string &="")
static std::string histcontrol(void)
For example cd octave end example noindent changes the current working directory to file
static void read(bool=true)
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
identity matrix If supplied two scalar respectively For allows like xample val
octave_idx_type length(void) const
std::string tempnam(const std::string &dir, const std::string &pfx)
bool is_numeric_type(void) const
static std::string Vhistory_timestamp_format_string
int int_value(bool req_int=false, bool frc_str_conv=false) const
static string_vector do_history(const octave_value_list &args, int nargout)
static void unlink_cleanup(const char *file)
static void set_size(int)
#define DEFUN(name, args_name, nargout_name, doc)
static void set_history(const string_vector &hist)
void error(const char *fmt,...)
#define SET_INTERNAL_VARIABLE(NM)
static void ignore_entries(bool=true)
static std::string default_history_timestamp_format(void)
static bool add(const std::string &)
static void do_run_history(const octave_value_list &args)
static std::string getenv(const std::string &name)
static void edit_history_add_hist(const std::string &line)
void initialize_history(bool read_history_file)
static void clear_history(void)
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)
void add_fcn(void(*fcn)(void))
static std::string get_home_directory(void)
static string_vector list(int=-1, bool=false)
void octave_history_write_timestamp(void)
std::string string_value(bool force=false) const
static std::string mk_tmp_hist_file(const octave_value_list &args, bool insert_curr, const char *warn_for)
int octave_unlink_wrapper(const char *nm)
bool is_string(void) const
static std::string get_host_name(void)
static std::string get_user_name(void)
OCTINTERP_API octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
#define panic_impossible()
static void read_range(int=-1, int=-1, bool=true)
interrupt_handler ignore_interrupts(void)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
static void initialize(bool, const std::string &, int, const std::string &)
void err_wrong_type_arg(const char *name, const char *s)
static std::string concat(const std::string &, const std::string &)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
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
bool input_from_tmp_history_file
static bool get_int_arg(const octave_value &arg, int &val)
=val(i)}if ode{val(i)}occurs in table i
static void set_file(const std::string &)
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
static int default_history_size(void)
static bool ignoring_entries(void)
static std::string default_history_file(void)
static char * edit_history_readline(std::fstream &stream)
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 void append(const std::string &="")
static void append_history(const std::string &hist_entry)
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
static void do_edit_history(const octave_value_list &args)
static std::string file(void)
std::string strftime(const std::string &fmt) const
static void process_histcontrol(const std::string &)