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;
170 = args(++
i).xstring_value (
"history: filename must be a string for %s option",
211 numbered_output =
false;
223 if (sscanf (
option.c_str (),
"%d", &
tmp) == 1)
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);
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";
454 cmd.append (R
"( ")" + name + '"');
462 int status =
system (cmd.c_str ());
468 if (status != EXIT_SUCCESS)
469 error (
"edit_history: text editor command failed");
474 std::fstream
file (
name.c_str (), std::ios::in);
549 if (! timestamp.empty ())
591 if (args.length () > 2)
650 DEFUN (run_history, args, ,
704 if (args.length () > 2)
744 if (
tmp != old_history_control)
766 int tmp = old_history_size;
772 if (
tmp != old_history_size)
798 if (
tmp != old_history_file)
846 bool tmp = old_history_save;
850 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
octave_value editor(const octave_value_list &args, int nargout)
static void read(bool=true)
int int_value(bool req_int=false, bool frc_str_conv=false) const
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
static void do_edit_history(octave::interpreter &interp, const octave_value_list &args)
std::string string_value(bool force=false) const
OCTINTERP_API void print_usage(void)
identity matrix If supplied two scalar respectively For allows like xample val
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 of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the system(carriage-return linefeed on Windows). The default when no mode is specified is binary. Additionally
std::string tempnam(const std::string &dir, const std::string &pfx)
static std::string Vhistory_timestamp_format_string
static string_vector do_history(const octave_value_list &args, int nargout)
static void unlink_cleanup(const char *file)
static void set_size(int)
void add_fcn(void(*fcn)(void))
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
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)
environment & get_environment(void)
static bool add(const std::string &)
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 of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
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)
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 clear_history(void)
std::string concat(const std::string &dir, const std::string &file)
nd deftypefn *std::string name
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)
static std::string get_home_directory(void)
static string_vector list(int=-1, bool=false)
void octave_history_write_timestamp(void)
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)
static std::string get_host_name(void)
static std::string get_user_name(void)
#define panic_impossible()
static void read_range(int=-1, int=-1, bool=true)
interrupt_handler ignore_interrupts(void)
static void initialize(bool, const std::string &, int, const std::string &)
end deftypefn *return set_internal_variable(Vsvd_driver, args, nargout, "svd_driver", driver_names)
void err_wrong_type_arg(const char *name, const char *s)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
bool input_from_tmp_history_file
static bool get_int_arg(const octave_value &arg, int &val)
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)
octave_idx_type length(void) const
static bool ignoring_entries(void)
bool is_string(void) const
static std::string default_history_file(void)
static char * edit_history_readline(std::fstream &stream)
octave_idx_type numel(void) const
Number of elements in the array.
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 std::string file(void)
bool isnumeric(void) const
static void process_histcontrol(const std::string &)