#include <cerrno>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include "vasnprintf.h"
#include "quit.h"
#include "dir-ops.h"
#include "file-ops.h"
#include "file-stat.h"
#include "lo-mappers.h"
#include "lo-utils.h"
#include "oct-cmplx.h"
#include "oct-env.h"
#include "pathsearch.h"
#include "str-vec.h"
#include "Cell.h"
#include <defaults.h>
#include "defun.h"
#include "dirfns.h"
#include "error.h"
#include "gripes.h"
#include "input.h"
#include "lex.h"
#include "load-path.h"
#include "oct-errno.h"
#include "oct-hist.h"
#include "oct-obj.h"
#include "ov-range.h"
#include "pager.h"
#include "parse.h"
#include "sysdep.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
Go to the source code of this file.
Functions | |
int | almost_match (const std::string &std, const std::string &s, int min_match_len, int case_sens) |
static void | check_dimensions (octave_idx_type &nr, octave_idx_type &nc, const char *warnfor) |
void | check_dimensions (dim_vector &dim, const char *warnfor) |
std::string | contents_file_in_path (const std::string &dir) |
DEFUN (isvarname, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isvarname (@var{name})\n\ Return true if @var{name} is a valid variable name.\n\ @seealso{iskeyword, exist, who}\n\ @end deftypefn") | |
DEFUN (do_string_escapes, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} do_string_escapes (@var{string})\n\ Convert special characters in @var{string} to their escaped forms.\n\ @end deftypefn") | |
DEFUN (file_in_loadpath, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} file_in_loadpath (@var{file})\n\ @deftypefnx {Built-in Function} {} file_in_loadpath (@var{file}, \"all\")\n\ \n\ Return the absolute name of @var{file} if it can be found in\n\ the list of directories specified by @code{path}.\n\ If no file is found, return an empty character string.\n\ \n\ If the first argument is a cell array of strings, search each\n\ directory of the loadpath for element of the cell array and return\n\ the first that matches.\n\ \n\ If the second optional argument @code{\"all\"} is supplied, return\n\ a cell array containing the list of all files that have the same\n\ name in the path. If no files are found, return an empty cell array.\n\ @seealso{file_in_path, path}\n\ @end deftypefn") | |
DEFUN (isindex, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isindex (@var{ind})\n\ @deftypefnx {Built-in Function} {} isindex (@var{ind}, @var{n})\n\ Return true if @var{ind} is a valid index. Valid indices are\n\ either positive integers (although possibly of real data type), or logical\n\ arrays. If present, @var{n} specifies the maximum extent of the dimension\n\ to be indexed. When possible the internal result is cached so that\n\ subsequent indexing using @var{ind} will not perform the check again.\n\ @end deftypefn") | |
DEFUN (undo_string_escapes, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} undo_string_escapes (@var{s})\n\ Convert special characters in strings back to their escaped forms. For\n\ example, the expression\n\ \n\ @example\n\ bell = \"\\a\";\n\ @end example\n\ \n\ @noindent\n\ assigns the value of the alert character (control-g, ASCII code 7) to\n\ the string variable @code{bell}. If this string is printed, the\n\ system will ring the terminal bell (if it is possible). This is\n\ normally the desired outcome. However, sometimes it is useful to be\n\ able to print the original representation of the string, with the\n\ special characters replaced by their escape sequences. For example,\n\ \n\ @example\n\ @group\n\ octave:13> undo_string_escapes (bell)\n\ ans = \\a\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ replaces the unprintable alert character with its printable\n\ representation.\n\ @end deftypefn") | |
DEFUN (is_absolute_filename, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} is_absolute_filename (@var{file})\n\ Return true if @var{file} is an absolute filename.\n\ @seealso{is_rooted_relative_filename, make_absolute_filename, isdir}\n\ @end deftypefn") | |
DEFUN (is_rooted_relative_filename, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} is_rooted_relative_filename (@var{file})\n\ Return true if @var{file} is a rooted-relative filename.\n\ @seealso{is_absolute_filename, make_absolute_filename, isdir}\n\ @end deftypefn") | |
DEFUN (make_absolute_filename, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} make_absolute_filename (@var{file})\n\ Return the full name of @var{file}, relative to the current directory.\n\ @seealso{is_absolute_filename, is_rooted_relative_filename, isdir}\n\ @end deftypefn") | |
DEFUN (find_dir_in_path, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} find_dir_in_path (@var{dir})\n\ @deftypefnx {Built-in Function} {} find_dir_in_path (@var{dir}, \"all\")\n\ Return the full name of the path element matching @var{dir}. The\n\ match is performed at the end of each path element. For example, if\n\ @var{dir} is @code{\"foo/bar\"}, it matches the path element\n\ @code{\"/some/dir/foo/bar\"}, but not @code{\"/some/dir/foo/bar/baz\"}\n\ or @code{\"/some/dir/allfoo/bar\"}.\n\ \n\ The second argument is optional. If it is supplied, return a cell array\n\ containing all name matches rather than just the first.\n\ @end deftypefn") | |
DEFUN (file_in_path, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} file_in_path (@var{path}, @var{file})\n\ @deftypefnx {Built-in Function} {} file_in_path (@var{path}, @var{file}, \"all\")\n\ Return the absolute name of @var{file} if it can be found in\n\ @var{path}. The value of @var{path} should be a colon-separated list of\n\ directories in the format described for @code{path}. If no file\n\ is found, return an empty character string. For example:\n\ \n\ @example\n\ @group\n\ file_in_path (EXEC_PATH, \"sh\")\n\ @result{} \"/bin/sh\"\n\ @end group\n\ @end example\n\ \n\ If the second argument is a cell array of strings, search each\n\ directory of the path for element of the cell array and return\n\ the first that matches.\n\ \n\ If the third optional argument @code{\"all\"} is supplied, return\n\ a cell array containing the list of all files that have the same\n\ name in the path. If no files are found, return an empty cell array.\n\ @seealso{file_in_loadpath}\n\ @end deftypefn") | |
DEFUN (errno_list, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} errno_list ()\n\ Return a structure containing the system-dependent errno values.\n\ @end deftypefn") | |
DEFUNX ("errno", Ferrno, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{err} =} errno ()\n\ @deftypefnx {Built-in Function} {@var{err} =} errno (@var{val})\n\ @deftypefnx {Built-in Function} {@var{err} =} errno (@var{name})\n\ Return the current value of the system-dependent variable errno,\n\ set its value to @var{val} and return the previous value, or return\n\ the named error code given @var{name} as a character string, or -1\n\ if @var{name} is not found.\n\ @end deftypefn") | |
octave_idx_type | dims_to_numel (const dim_vector &dims, const octave_value_list &idx) |
octave_value_list | do_simple_cellfun (octave_value_list(*fun)(const octave_value_list &, int), const char *fun_name, const octave_value_list &args, int nargout) |
octave_value | do_simple_cellfun (octave_value_list(*fun)(const octave_value_list &, int), const char *fun_name, const octave_value_list &args) |
std::string | do_string_escapes (const std::string &s) |
int | empty_arg (const char *, octave_idx_type nr, octave_idx_type nc) |
std::string | fcn_file_in_path (const std::string &name) |
std::string | file_in_path (const std::string &name, const std::string &suffix) |
FloatMatrix | float_identity_matrix (octave_idx_type nr, octave_idx_type nc) |
void | get_dimensions (const octave_value &a, const octave_value &b, const char *warn_for, octave_idx_type &nr, octave_idx_type &nc) |
void | get_dimensions (const octave_value &a, const char *warn_for, octave_idx_type &nr, octave_idx_type &nc) |
void | get_dimensions (const octave_value &a, const char *warn_for, dim_vector &dim) |
Matrix | identity_matrix (octave_idx_type nr, octave_idx_type nc) |
int | keyword_almost_match (const char *const *std, int *min_len, const std::string &s, int min_toks_to_match, int max_toks) |
static string_vector | make_absolute (const string_vector &sv) |
std::string | mex_file_in_path (const std::string &name) |
std::string | oct_file_in_path (const std::string &name) |
std::string | octave_asprintf (const char *fmt,...) |
size_t | octave_format (std::ostream &os, const char *fmt,...) |
void | octave_sleep (double seconds) |
std::string | octave_vasprintf (const char *fmt, va_list args) |
size_t | octave_vformat (std::ostream &os, const char *fmt, va_list args) |
bool | same_file (const std::string &f, const std::string &g) |
string_vector | search_path_for_all_files (const std::string &path, const string_vector &names) |
std::string | search_path_for_file (const std::string &path, const string_vector &names) |
const char * | undo_string_escape (char c) |
std::string | undo_string_escapes (const std::string &s) |
bool | valid_identifier (const std::string &s) |
bool | valid_identifier (const char *s) |
int almost_match | ( | const std::string & | std, | |
const std::string & | s, | |||
int | min_match_len, | |||
int | case_sens | |||
) |
Definition at line 139 of file utils.cc.
References octave_strncasecmp().
Referenced by keyword_almost_match().
static void check_dimensions | ( | octave_idx_type & | nr, | |
octave_idx_type & | nc, | |||
const char * | warnfor | |||
) | [static] |
Definition at line 1022 of file utils.cc.
References warning_with_id().
Referenced by DEFUN(), fill_matrix(), and get_dimensions().
void check_dimensions | ( | dim_vector & | dim, | |
const char * | warnfor | |||
) |
Definition at line 1035 of file utils.cc.
References dim_vector::length(), and warning_with_id().
std::string contents_file_in_path | ( | const std::string & | dir | ) |
Definition at line 493 of file utils.cc.
References file_ops::concat(), base_file_stat::exists(), load_path::find_dir(), and octave_env::make_absolute().
DEFUN | ( | isvarname | , | |
args | ||||
) |
Definition at line 95 of file utils.cc.
References error_state, is_keyword(), print_usage(), and valid_identifier().
DEFUN | ( | do_string_escapes | , | |
args | ||||
) |
Definition at line 653 of file utils.cc.
References do_string_escapes(), error(), and print_usage().
DEFUN | ( | file_in_loadpath | , | |
args | ||||
) |
Definition at line 290 of file utils.cc.
References error(), error_state, load_path::find_all_first_of(), load_path::find_first_of(), Array< T >::length(), make_absolute(), octave_env::make_absolute(), names(), and print_usage().
DEFUN | ( | isindex | , | |
args | ||||
) |
Definition at line 1279 of file utils.cc.
References discard_error_messages, error_state, idx_vector::extent(), print_usage(), unwind_protect::protect_var(), and Vallow_noninteger_range_as_index.
DEFUN | ( | undo_string_escapes | , | |
args | ||||
) |
Definition at line 751 of file utils.cc.
References error(), print_usage(), and undo_string_escapes().
DEFUN | ( | is_absolute_filename | , | |
args | ||||
) |
Definition at line 812 of file utils.cc.
References octave_env::absolute_pathname(), and print_usage().
DEFUN | ( | is_rooted_relative_filename | , | |
args | ||||
) |
Definition at line 837 of file utils.cc.
References print_usage(), and octave_env::rooted_relative_pathname().
DEFUN | ( | make_absolute_filename | , | |
args | ||||
) |
Definition at line 862 of file utils.cc.
References error(), error_state, octave_env::make_absolute(), and print_usage().
DEFUN | ( | find_dir_in_path | , | |
args | ||||
) |
Definition at line 893 of file utils.cc.
References error(), error_state, load_path::find_dir(), load_path::find_matching_dirs(), and print_usage().
DEFUN | ( | file_in_path | , | |
args | ||||
) |
Definition at line 359 of file utils.cc.
References error(), error_state, Array< T >::length(), make_absolute(), names(), print_usage(), search_path_for_all_files(), and search_path_for_file().
DEFUN | ( | errno_list | , | |
args | ||||
) |
Definition at line 999 of file utils.cc.
References octave_errno::list(), and print_usage().
DEFUNX | ( | "errno" | , | |
Ferrno | , | |||
args | ||||
) |
Definition at line 940 of file utils.cc.
References error(), error_state, octave_errno::get(), octave_errno::lookup(), print_usage(), and octave_errno::set().
octave_idx_type dims_to_numel | ( | const dim_vector & | dims, | |
const octave_value_list & | idx | |||
) |
Definition at line 1135 of file utils.cc.
References error_state, octave_value::index_vector(), octave_value::is_magic_colon(), octave_value::is_numeric_type(), idx_vector::length(), octave_value_list::length(), octave_value::numel(), dim_vector::numel(), and dim_vector::redim().
Referenced by DEFUN(), and octave_base_value::numel().
octave_value_list do_simple_cellfun | ( | octave_value_list(*)(const octave_value_list &, int) | fun, | |
const char * | fun_name, | |||
const octave_value_list & | args, | |||
int | nargout | |||
) |
Definition at line 1342 of file utils.cc.
References arg(), octave_value::cell_value(), clear(), Array< T >::dims(), error(), error_state, octave_value::is_cell(), octave_value_list::length(), Array< T >::numel(), and OCTAVE_LOCAL_BUFFER.
Referenced by DEFUN_DLD(), and do_simple_cellfun().
octave_value do_simple_cellfun | ( | octave_value_list(*)(const octave_value_list &, int) | fun, | |
const char * | fun_name, | |||
const octave_value_list & | args | |||
) |
Definition at line 1422 of file utils.cc.
References do_simple_cellfun(), and octave_value_list::length().
std::string do_string_escapes | ( | const std::string & | s | ) |
Definition at line 572 of file utils.cc.
References warning().
Referenced by DEFUN(), DEFUN_DLD(), octave_stream::oscanf(), octave_stream::printf(), and octave_stream::scanf().
int empty_arg | ( | const char * | , | |
octave_idx_type | nr, | |||
octave_idx_type | nc | |||
) |
Definition at line 245 of file utils.cc.
Referenced by DEFUN_DLD().
std::string fcn_file_in_path | ( | const std::string & | name | ) |
Definition at line 458 of file utils.cc.
References octave_env::absolute_pathname(), base_file_stat::exists(), load_path::find_fcn_file(), and Vfilemarker.
Referenced by do_dbtype(), and octave_user_function::mark_as_system_fcn_file().
std::string file_in_path | ( | const std::string & | name, | |
const std::string & | suffix | |||
) |
Definition at line 444 of file utils.cc.
References load_path::find_file(), and octave_env::make_absolute().
Referenced by symbol_exist().
FloatMatrix float_identity_matrix | ( | octave_idx_type | nr, | |
octave_idx_type | nc | |||
) |
void get_dimensions | ( | const octave_value & | a, | |
const octave_value & | b, | |||
const char * | warn_for, | |||
octave_idx_type & | nr, | |||
octave_idx_type & | nc | |||
) |
Definition at line 1122 of file utils.cc.
References check_dimensions(), error(), error_state, octave_value::int_value(), and octave_value::is_empty().
void get_dimensions | ( | const octave_value & | a, | |
const char * | warn_for, | |||
octave_idx_type & | nr, | |||
octave_idx_type & | nc | |||
) |
Definition at line 1091 of file utils.cc.
References check_dimensions(), octave_value::columns(), error(), error_state, fix(), octave_value::int_value(), octave_value::is_scalar_type(), octave_value::rows(), and octave_value::vector_value().
void get_dimensions | ( | const octave_value & | a, | |
const char * | warn_for, | |||
dim_vector & | dim | |||
) |
Definition at line 1055 of file utils.cc.
References check_dimensions(), octave_value::columns(), error(), error_state, fix(), octave_value::int_value(), octave_value::is_scalar_type(), Array< T >::length(), dim_vector::resize(), octave_value::rows(), and octave_value::vector_value().
Referenced by DEFUN(), and fill_matrix().
Matrix identity_matrix | ( | octave_idx_type | nr, | |
octave_idx_type | nc | |||
) |
int keyword_almost_match | ( | const char *const * | std, | |
int * | min_len, | |||
const std::string & | s, | |||
int | min_toks_to_match, | |||
int | max_toks | |||
) |
Definition at line 155 of file utils.cc.
References almost_match(), and strsave().
static string_vector make_absolute | ( | const string_vector & | sv | ) | [static] |
Definition at line 278 of file utils.cc.
References Array< T >::length(), and octave_env::make_absolute().
std::string mex_file_in_path | ( | const std::string & | name | ) |
Definition at line 544 of file utils.cc.
References octave_env::absolute_pathname(), base_file_stat::exists(), and load_path::find_mex_file().
std::string oct_file_in_path | ( | const std::string & | name | ) |
Definition at line 515 of file utils.cc.
References octave_env::absolute_pathname(), base_file_stat::exists(), and load_path::find_oct_file().
std::string octave_asprintf | ( | const char * | fmt, | |
... | ||||
) |
Definition at line 1243 of file utils.cc.
References octave_vasprintf().
size_t octave_format | ( | std::ostream & | os, | |
const char * | fmt, | |||
... | ||||
) |
Definition at line 1200 of file utils.cc.
References octave_vformat().
Referenced by do_printf_conv().
void octave_sleep | ( | double | seconds | ) |
Definition at line 1258 of file utils.cc.
References octave_sleep(), and octave_usleep().
std::string octave_vasprintf | ( | const char * | fmt, | |
va_list | args | |||
) |
Definition at line 1225 of file utils.cc.
Referenced by octave_asprintf(), and octave_vformat().
size_t octave_vformat | ( | std::ostream & | os, | |
const char * | fmt, | |||
va_list | args | |||
) |
Definition at line 1215 of file utils.cc.
References octave_vasprintf().
Referenced by mexPrintf(), octave_format(), verror(), and vwarning().
bool same_file | ( | const std::string & | f, | |
const std::string & | g | |||
) |
Definition at line 133 of file utils.cc.
References same_file_internal().
Referenced by execute_startup_files(), and out_of_date_check().
string_vector search_path_for_all_files | ( | const std::string & | path, | |
const string_vector & | names | |||
) |
Definition at line 263 of file utils.cc.
References dir_path::find_all_first_of(), Array< T >::length(), and octave_env::make_absolute().
Referenced by DEFUN().
std::string search_path_for_file | ( | const std::string & | path, | |
const string_vector & | names | |||
) |
Definition at line 253 of file utils.cc.
References dir_path::find_first_of(), and octave_env::make_absolute().
Referenced by DEFUN().
Definition at line 693 of file utils.cc.
Referenced by undo_string_escapes().
std::string undo_string_escapes | ( | const std::string & | s | ) |
Definition at line 741 of file utils.cc.
References undo_string_escape().
Referenced by DEFUN(), octave_print_internal(), printf_format_list::printme(), and scanf_format_list::printme().
bool valid_identifier | ( | const std::string & | s | ) |
Definition at line 90 of file utils.cc.
References valid_identifier().
Definition at line 77 of file utils.cc.
Referenced by DEFUN(), DEFUN_DLD(), get_fcn_files(), load_path::dir_info::get_file_list(), tree_index_expression::get_struct_index(), read_ascii_data(), read_mat_ascii_data(), and valid_identifier().