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
Macros | Functions | Variables
kpse.cc File Reference
#include <cctype>
#include <cerrno>
#include <cstdlib>
#include <map>
#include <fstream>
#include <iostream>
#include <string>
#include "dir-ops.h"
#include "file-ops.h"
#include "file-stat.h"
#include "kpse.h"
#include "oct-env.h"
#include "oct-passwd.h"
#include "oct-time.h"
#include "pathsearch.h"
#include "unistd-wrappers.h"
Include dependency graph for kpse.cc:

Go to the source code of this file.

Macros

#define brace_whitespace(c)   (! (c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
 
#define DIR_SEP_STRING   octave::sys::file_ops::dir_sep_str ()
 
#define ENV_SEP   octave::directory_path::path_sep_char ()
 
#define ENV_SEP_STRING   octave::directory_path::path_sep_str ()
 
#define IS_DEVICE_SEP(ch)   octave::sys::file_ops::is_dev_sep (ch)
 
#define IS_DIR_SEP(ch)   octave::sys::file_ops::is_dir_sep (ch)
 
#define IS_ENV_SEP(ch)   octave::directory_path::is_path_sep (ch)
 
#define IS_VAR_BEGIN_DELIMITER(c)   ((c) == '{')
 
#define IS_VAR_CHAR(c)   (isalnum (c) || (c) == '_')
 
#define IS_VAR_END_DELIMITER(c)   ((c) == '}')
 
#define IS_VAR_START(c)   ((c) == '$')
 
#define KPSE_DEBUG
 
#define KPSE_DEBUG_EXPAND   1
 
#define KPSE_DEBUG_P(bit)   (kpse_debug & (1 << (bit)))
 
#define KPSE_DEBUG_SEARCH   2
 
#define KPSE_DEBUG_STAT   0
 
#define KPSE_DEBUG_VARS   3
 
#define KPSE_LAST_DEBUG   KPSE_DEBUG_VARS
 
#define NAME_BEGINS_WITH_DEVICE(name)   (name.length () > 0 && IS_DEVICE_SEP ((name)[1]))
 

Functions

static std::list< std::stringabsolute_search (const std::string &name)
 
static std::list< std::stringarray_concat (const std::list< std::string > &arr1, const std::list< std::string > &arr2)
 
static std::list< std::stringbrace_expand (const std::string &)
 
static int brace_gobbler (const std::string &, int &, int)
 
static bool dir_p (const std::string &fn)
 
static std::list< std::stringdir_search (const std::string &dir, const std::string &name, bool search_all)
 
static void expand (std::string &expansion, const std::string &var)
 
static std::list< std::stringexpand_amble (const std::string &)
 
static void expanding (const std::string &var, bool xp)
 
static bool expanding_p (const std::string &var)
 
static std::list< std::stringfind_first_of (const std::string &path, const std::list< std::string > &names, bool all)
 
static bool kpse_absolute_p (const std::string &filename, int relative_ok)
 
std::list< std::stringkpse_all_path_find_first_of (const std::string &path, const std::list< std::string > &names)
 
std::list< std::stringkpse_all_path_search (const std::string &path, const std::string &name)
 
static std::string kpse_brace_expand (const std::string &path)
 
static std::string kpse_brace_expand_element (const std::string &elt)
 
std::string kpse_element_dir (const std::string &elt)
 
static std::string kpse_expand (const std::string &s)
 
std::string kpse_expand_default (const std::string &path, const std::string &fallback)
 
static std::string kpse_expand_kpse_dot (const std::string &path)
 
std::string kpse_path_expand (const std::string &path)
 
std::string kpse_path_find_first_of (const std::string &path, const std::list< std::string > &names)
 
std::string kpse_path_search (const std::string &path, const std::string &name)
 
static std::string kpse_readable_file (const std::string &name)
 
static std::string kpse_tilde_expand (const std::string &name)
 
static std::string kpse_truncate_filename (const std::string &name)
 
static std::string kpse_var_expand (const std::string &src)
 
static void log_search (const std::list< std::string > &filenames)
 
std::list< std::stringpath_find_first_of (const std::string &path, const std::list< std::string > &names, bool all)
 
static std::list< std::stringpath_search (const std::string &path, const std::string &name, bool all)
 
static bool READABLE (const std::string &fn)
 
static std::list< std::stringsearch (const std::string &path, const std::string &original_name, bool all)
 

Variables

static int brace_arg_separator = ','
 
static std::map< std::string,
bool
expansions
 
static bool first_search = true
 
unsigned int kpse_debug = 0
 

Macro Definition Documentation

#define brace_whitespace (   c)    (! (c) || (c) == ' ' || (c) == '\t' || (c) == '\n')

Definition at line 938 of file kpse.cc.

Referenced by brace_gobbler().

#define DIR_SEP_STRING   octave::sys::file_ops::dir_sep_str ()

Definition at line 64 of file kpse.cc.

Referenced by kpse_element_dir(), and kpse_expand_kpse_dot().

#define ENV_SEP   octave::directory_path::path_sep_char ()

Definition at line 67 of file kpse.cc.

Referenced by expand_amble(), and kpse_path_expand().

#define ENV_SEP_STRING   octave::directory_path::path_sep_str ()
#define IS_DEVICE_SEP (   ch)    octave::sys::file_ops::is_dev_sep (ch)

Definition at line 60 of file kpse.cc.

Referenced by kpse_element_dir(), and kpse_truncate_filename().

#define IS_DIR_SEP (   ch)    octave::sys::file_ops::is_dir_sep (ch)
#define IS_ENV_SEP (   ch)    octave::directory_path::is_path_sep (ch)

Definition at line 69 of file kpse.cc.

Referenced by kpse_expand_default().

#define IS_VAR_BEGIN_DELIMITER (   c)    ((c) == '{')

Definition at line 1294 of file kpse.cc.

Referenced by kpse_var_expand().

#define IS_VAR_CHAR (   c)    (isalnum (c) || (c) == '_')

Definition at line 1289 of file kpse.cc.

Referenced by kpse_var_expand().

#define IS_VAR_END_DELIMITER (   c)    ((c) == '}')

Definition at line 1298 of file kpse.cc.

Referenced by kpse_var_expand().

#define IS_VAR_START (   c)    ((c) == '$')

Definition at line 1284 of file kpse.cc.

Referenced by kpse_var_expand().

#define KPSE_DEBUG

Definition at line 75 of file kpse.cc.

#define KPSE_DEBUG_EXPAND   1

Definition at line 81 of file kpse.cc.

#define KPSE_DEBUG_P (   bit)    (kpse_debug & (1 << (bit)))

Definition at line 78 of file kpse.cc.

Referenced by find_first_of(), log_search(), and search().

#define KPSE_DEBUG_SEARCH   2

Definition at line 82 of file kpse.cc.

Referenced by find_first_of(), log_search(), and search().

#define KPSE_DEBUG_STAT   0

Definition at line 80 of file kpse.cc.

#define KPSE_DEBUG_VARS   3

Definition at line 83 of file kpse.cc.

#define KPSE_LAST_DEBUG   KPSE_DEBUG_VARS

Definition at line 84 of file kpse.cc.

#define NAME_BEGINS_WITH_DEVICE (   name)    (name.length () > 0 && IS_DEVICE_SEP ((name)[1]))

Definition at line 61 of file kpse.cc.

Referenced by kpse_path_expand(), path_find_first_of(), and path_search().

Function Documentation

static std::list<std::string> absolute_search ( const std::string name)
static

Definition at line 309 of file kpse.cc.

References found, kpse_readable_file(), and string.

Referenced by find_first_of(), and search().

static std::list<std::string> array_concat ( const std::list< std::string > &  arr1,
const std::list< std::string > &  arr2 
)
static

Definition at line 955 of file kpse.cc.

References result.

Referenced by brace_expand().

static std::list< std::string > brace_expand ( const std::string text)
static

Definition at line 979 of file kpse.cc.

References array_concat(), brace_gobbler(), c, expand_amble(), result, start, string, and text.

Referenced by expand_amble(), and kpse_brace_expand_element().

static int brace_gobbler ( const std::string text,
int indx,
int  satisfy 
)
static

Definition at line 1060 of file kpse.cc.

References brace_whitespace, and c.

Referenced by brace_expand(), and expand_amble().

static bool dir_p ( const std::string fn)
static

Definition at line 1190 of file kpse.cc.

References fs, and octave::sys::base_file_stat::is_dir().

Referenced by kpse_element_dir().

static std::list<std::string> dir_search ( const std::string dir,
const std::string name,
bool  search_all 
)
static

Definition at line 285 of file kpse.cc.

References kpse_readable_file(), name, string, and tmp.

Referenced by path_find_first_of(), and path_search().

static void expand ( std::string expansion,
const std::string var 
)
static

Definition at line 1255 of file kpse.cc.

References expanding(), expanding_p(), octave::sys::env::getenv(), kpse_var_expand(), string, tmp, and value().

Referenced by kpse_var_expand().

static std::list< std::string > expand_amble ( const std::string text)
static

Definition at line 1025 of file kpse.cc.

References brace_expand(), brace_gobbler(), c, ENV_SEP, result, start, and string.

Referenced by brace_expand().

static void expanding ( const std::string var,
bool  xp 
)
static

Definition at line 1237 of file kpse.cc.

References var.

Referenced by expand().

static bool expanding_p ( const std::string var)
static

Definition at line 1245 of file kpse.cc.

Referenced by expand().

static std::list<std::string> find_first_of ( const std::string path,
const std::list< std::string > &  names,
bool  all 
)
static
static bool kpse_absolute_p ( const std::string filename,
int  relative_ok 
)
static
std::list<std::string> kpse_all_path_find_first_of ( const std::string path,
const std::list< std::string > &  names 
)

Definition at line 644 of file kpse.cc.

References find_first_of().

Referenced by octave::directory_path::find_all_first_of().

std::list< std::string > kpse_all_path_search ( const std::string path,
const std::string name 
)

Definition at line 467 of file kpse.cc.

References search().

Referenced by octave::directory_path::find_all().

static std::string kpse_brace_expand ( const std::string path)
static
static std::string kpse_brace_expand_element ( const std::string elt)
static

Definition at line 798 of file kpse.cc.

References brace_expand(), ENV_SEP_STRING, expansions, kpse_expand(), string, and x.

Referenced by kpse_brace_expand().

std::string kpse_element_dir ( const std::string elt)
static std::string kpse_expand ( const std::string s)
static

Definition at line 746 of file kpse.cc.

References kpse_tilde_expand(), kpse_var_expand(), and string.

Referenced by kpse_brace_expand_element(), and search().

std::string kpse_expand_default ( const std::string path,
const std::string fallback 
)

Definition at line 1138 of file kpse.cc.

References IS_ENV_SEP, and string.

Referenced by octave::directory_path::init().

static std::string kpse_expand_kpse_dot ( const std::string path)
static
std::string kpse_path_expand ( const std::string path)
std::string kpse_path_find_first_of ( const std::string path,
const std::list< std::string > &  names 
)

Definition at line 628 of file kpse.cc.

References find_first_of().

Referenced by octave::directory_path::find_first_of().

std::string kpse_path_search ( const std::string path,
const std::string name 
)

Definition at line 456 of file kpse.cc.

References search().

Referenced by octave::directory_path::find_first().

static std::string kpse_readable_file ( const std::string name)
static

Definition at line 203 of file kpse.cc.

References kpse_truncate_filename(), name, READABLE(), and string.

Referenced by absolute_search(), and dir_search().

static std::string kpse_tilde_expand ( const std::string name)
static
static std::string kpse_truncate_filename ( const std::string name)
static
static std::string kpse_var_expand ( const std::string src)
static
static void log_search ( const std::list< std::string > &  filenames)
static

Definition at line 262 of file kpse.cc.

References filename, KPSE_DEBUG_P, KPSE_DEBUG_SEARCH, now, and octave::sys::time::unix_time().

Referenced by find_first_of(), and search().

std::list<std::string> path_find_first_of ( const std::string path,
const std::list< std::string > &  names,
bool  all 
)
static std::list<std::string> path_search ( const std::string path,
const std::string name,
bool  all 
)
static

Definition at line 325 of file kpse.cc.

References dir_search(), done, found, IS_DIR_SEP, kpse_element_dir(), NAME_BEGINS_WITH_DEVICE, octave::math::pi, and string.

Referenced by search().

static bool READABLE ( const std::string fn)
inlinestatic
static std::list<std::string> search ( const std::string path,
const std::string original_name,
bool  all 
)
static

Variable Documentation

int brace_arg_separator = ','
static

Definition at line 1018 of file kpse.cc.

std::map<std::string, bool> expansions
static

Definition at line 1234 of file kpse.cc.

Referenced by kpse_brace_expand_element().

bool first_search = true
static

Definition at line 257 of file kpse.cc.

unsigned int kpse_debug = 0

Definition at line 88 of file kpse.cc.

Referenced by octave::directory_path::init().