GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
utils.cc File Reference
#include <cerrno>
#include <cstring>
#include <fstream>
#include <limits>
#include <ostream>
#include <string>
#include "dir-ops.h"
#include "file-ops.h"
#include "file-stat.h"
#include "lo-mappers.h"
#include "lo-utils.h"
#include "nanosleep-wrapper.h"
#include "oct-cmplx.h"
#include "oct-env.h"
#include "oct-locbuf.h"
#include "oct-string.h"
#include "pathsearch.h"
#include "quit.h"
#include "str-vec.h"
#include "strcase-wrappers.h"
#include "vasprintf-wrapper.h"
#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "errwarn.h"
#include "graphics.h"
#include "interpreter-private.h"
#include "interpreter.h"
#include "lex.h"
#include "load-path.h"
#include "oct-errno.h"
#include "oct-hist.h"
#include "ovl.h"
#include "ov-range.h"
#include "pager.h"
#include "parse.h"
#include "sysdep.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
Include dependency graph for utils.cc:

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)
 
std::string asprintf (const char *fmt,...)
 
void check_dimensions (dim_vector &dim, const char *warnfor)
 
static void check_dimensions (octave_idx_type &nr, octave_idx_type &nc, const char *warnfor)
 
std::string contents_file_in_path (const std::string &dir)
 
octave_idx_type dims_to_numel (const dim_vector &dims, const octave_value_list &idx_arg)
 
octave_value do_simple_cellfun (octave_value_list(*fcn)(const octave_value_list &, int), const char *fcn_name, const octave_value_list &args)
 
octave_value_list do_simple_cellfun (octave_value_list(*fcn)(const octave_value_list &, int), const char *fcn_name, const octave_value_list &args, int nargout)
 
std::string do_string_escapes (const std::string &s)
 
OCTAVE_EXPORT octave_value_list F__make_valid_name__ (const octave_value_list &args, int)
 
std::string fcn_file_in_path (const std::string &name)
 
OCTAVE_EXPORT octave_value_list Fdir_in_loadpath (octave::interpreter &interp, const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fdo_string_escapes (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Ferrno (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Ferrno_list (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Ffile_in_loadpath (octave::interpreter &interp, const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Ffile_in_path (const octave_value_list &args, int)
 
std::string file_in_path (const std::string &name, const std::string &suffix)
 
std::string find_data_file_in_load_path (const std::string &fcn, const std::string &file, bool require_regular_file)
 
OCTAVE_EXPORT octave_value_list Fis_absolute_filename (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fis_rooted_relative_filename (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fis_same_file (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fisindex (octave::interpreter &interp, const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fisstudent (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fisvarname (const octave_value_list &args, int)
 
FloatMatrix float_identity_matrix (octave_idx_type nr, octave_idx_type nc)
 
OCTAVE_EXPORT octave_value_list Fmake_absolute_filename (const octave_value_list &args, int)
 
std::size_t format (std::ostream &os, const char *fmt,...)
 
OCTAVE_EXPORT octave_value_list Fundo_string_escapes (const octave_value_list &args, int)
 
void get_dimensions (const octave_value &a, const char *warn_for, dim_vector &dim)
 
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 octave_value &b, const char *warn_for, octave_idx_type &nr, octave_idx_type &nc)
 
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)
 
bool make_valid_name (std::string &str, const make_valid_name_options &options)
 Modify str to be a valid variable name. More...
 
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)
 
void sleep (double seconds, bool do_graphics_events)
 
const char * undo_string_escape (char c)
 
std::string undo_string_escapes (const std::string &s)
 
bool valid_identifier (const char *s)
 
bool valid_identifier (const std::string &s)
 
std::string vasprintf (const char *fmt, va_list args)
 
std::size_t vformat (std::ostream &os, const char *fmt, va_list args)
 

Function Documentation

◆ almost_match()

int almost_match ( const std::string &  std,
const std::string &  s,
int  min_match_len,
int  case_sens 
)

Definition at line 408 of file utils.cc.

References octave_strncasecmp(), and strncmp().

Referenced by keyword_almost_match().

◆ asprintf()

std::string asprintf ( const char *  fmt,
  ... 
)

Definition at line 1513 of file utils.cc.

References vasprintf().

◆ check_dimensions() [1/2]

void check_dimensions ( dim_vector dim,
const char *  warnfor 
)

Definition at line 1324 of file utils.cc.

References dim_vector::ndims(), and warning_with_id().

◆ check_dimensions() [2/2]

static void check_dimensions ( octave_idx_type nr,
octave_idx_type nc,
const char *  warnfor 
)
static

Definition at line 1311 of file utils.cc.

References warning_with_id().

Referenced by Fcell(), fill_matrix(), and get_dimensions().

◆ contents_file_in_path()

std::string contents_file_in_path ( const std::string &  dir)

Definition at line 782 of file utils.cc.

References __get_load_path__(), concat(), load_path::find_dir(), and make_absolute().

◆ dims_to_numel()

◆ do_simple_cellfun() [1/2]

octave_value do_simple_cellfun ( octave_value_list(*)(const octave_value_list &, int)  fcn,
const char *  fcn_name,
const octave_value_list args 
)

Definition at line 1731 of file utils.cc.

References do_simple_cellfun(), and octave_value_list::length().

◆ do_simple_cellfun() [2/2]

◆ do_string_escapes()

std::string do_string_escapes ( const std::string &  s)

◆ F__make_valid_name__()

OCTAVE_EXPORT octave_value_list F__make_valid_name__ ( const octave_value_list args,
int   
)

◆ fcn_file_in_path()

std::string fcn_file_in_path ( const std::string &  name)

◆ Fdir_in_loadpath()

OCTAVE_EXPORT octave_value_list Fdir_in_loadpath ( octave::interpreter &  interp,
const octave_value_list args,
int   
)

◆ Fdo_string_escapes()

OCTAVE_EXPORT octave_value_list Fdo_string_escapes ( const octave_value_list args,
int   
)

Definition at line 938 of file utils.cc.

References do_string_escapes(), ovl(), and print_usage().

◆ Ferrno()

OCTAVE_EXPORT octave_value_list Ferrno ( const octave_value_list args,
int   
)

◆ Ferrno_list()

OCTAVE_EXPORT octave_value_list Ferrno_list ( const octave_value_list args,
int   
)

Definition at line 1297 of file utils.cc.

References octave_errno::list(), ovl(), and print_usage().

◆ Ffile_in_loadpath()

OCTAVE_EXPORT octave_value_list Ffile_in_loadpath ( octave::interpreter &  interp,
const octave_value_list args,
int   
)

◆ Ffile_in_path()

OCTAVE_EXPORT octave_value_list Ffile_in_path ( const octave_value_list args,
int   
)

◆ file_in_path()

std::string file_in_path ( const std::string &  name,
const std::string &  suffix 
)

◆ find_data_file_in_load_path()

std::string find_data_file_in_load_path ( const std::string &  fcn,
const std::string &  file,
bool  require_regular_file 
)

◆ Fis_absolute_filename()

OCTAVE_EXPORT octave_value_list Fis_absolute_filename ( const octave_value_list args,
int   
)

Definition at line 1109 of file utils.cc.

References absolute_pathname(), ovl(), and print_usage().

◆ Fis_rooted_relative_filename()

OCTAVE_EXPORT octave_value_list Fis_rooted_relative_filename ( const octave_value_list args,
int   
)

Definition at line 1130 of file utils.cc.

References ovl(), and print_usage().

◆ Fis_same_file()

◆ Fisindex()

OCTAVE_EXPORT octave_value_list Fisindex ( octave::interpreter &  interp,
const octave_value_list args,
int   
)

Definition at line 1620 of file utils.cc.

References idx_vector::extent(), n, and print_usage().

◆ Fisstudent()

OCTAVE_EXPORT octave_value_list Fisstudent ( const octave_value_list args,
int   
)

Definition at line 1751 of file utils.cc.

References ovl(), and print_usage().

◆ Fisvarname()

OCTAVE_EXPORT octave_value_list Fisvarname ( const octave_value_list args,
int   
)

Definition at line 103 of file utils.cc.

References iskeyword(), print_usage(), octave_value::string_value(), and valid_identifier().

◆ float_identity_matrix()

FloatMatrix float_identity_matrix ( octave_idx_type  nr,
octave_idx_type  nc 
)

Definition at line 1458 of file utils.cc.

References m, min(), and n.

◆ Fmake_absolute_filename()

OCTAVE_EXPORT octave_value_list Fmake_absolute_filename ( const octave_value_list args,
int   
)

Definition at line 1155 of file utils.cc.

References make_absolute(), ovl(), and print_usage().

◆ format()

◆ Fundo_string_escapes()

OCTAVE_EXPORT octave_value_list Fundo_string_escapes ( const octave_value_list args,
int   
)

Definition at line 1072 of file utils.cc.

References ovl(), print_usage(), and undo_string_escapes().

◆ get_dimensions() [1/3]

void get_dimensions ( const octave_value a,
const char *  warn_for,
dim_vector dim 
)

◆ get_dimensions() [2/3]

◆ get_dimensions() [3/3]

void get_dimensions ( const octave_value a,
const octave_value b,
const char *  warn_for,
octave_idx_type nr,
octave_idx_type nc 
)

◆ identity_matrix()

Matrix identity_matrix ( octave_idx_type  nr,
octave_idx_type  nc 
)

Definition at line 1443 of file utils.cc.

References m, min(), and n.

◆ keyword_almost_match()

int keyword_almost_match ( const char *const *  std,
int *  min_len,
const std::string &  s,
int  min_toks_to_match,
int  max_toks 
)

◆ make_absolute()

◆ make_valid_name()

bool make_valid_name ( std::string &  str,
const make_valid_name_options options 
)

Modify str to be a valid variable name.

Parameters
strinput string
optionssee also help matlab.lang.makeValidName.
Returns
true, if str was modified.

Definition at line 135 of file utils.cc.

References make_valid_name_options::get_prefix(), make_valid_name_options::get_replacement_style(), iskeyword(), valid_identifier(), and x.

Referenced by F__make_valid_name__().

◆ same_file()

bool same_file ( const std::string &  f,
const std::string &  g 
)

◆ search_path_for_all_files()

string_vector search_path_for_all_files ( const std::string &  path,
const string_vector names 
)

◆ search_path_for_file()

std::string search_path_for_file ( const std::string &  path,
const string_vector names 
)

◆ sleep()

void sleep ( double  seconds,
bool  do_graphics_events 
)

◆ undo_string_escape()

const char* undo_string_escape ( char  c)

Definition at line 986 of file utils.cc.

Referenced by octave_lex(), and undo_string_escapes().

◆ undo_string_escapes()

◆ valid_identifier() [1/2]

◆ valid_identifier() [2/2]

bool valid_identifier ( const std::string &  s)

Definition at line 90 of file utils.cc.

References valid_identifier().

◆ vasprintf()

std::string vasprintf ( const char *  fmt,
va_list  args 
)

Definition at line 1496 of file utils.cc.

References free(), and octave_vasprintf_wrapper().

Referenced by asprintf(), octave_vasprintf_wrapper(), and vformat().

◆ vformat()

std::size_t vformat ( std::ostream &  os,
const char *  fmt,
va_list  args 
)

Definition at line 1487 of file utils.cc.

References vasprintf().

Referenced by format(), format_message(), and mexPrintf().