# HG changeset patch # User jwe # Date 1146075385 0 # Node ID 246b1fc1e628543d6c38fa36dacd198847d586e9 # Parent 1182d68521727cca6f4584ffa25784fe288bb4e7 [project @ 2006-04-26 18:16:24 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2006-04-26 John W. Eaton + + * pathsearch.cc (dir_path::path_sep_char, dir_path::path_sep_str): + New static data. + * pathsearch.h: Provide decls. + (dir_path::is_path_sep): New function. + 2006-04-18 John W. Eaton * randmtzig.c (randmt, randi53, randi54, randi64, randu32, randu53): diff --git a/liboctave/pathsearch.cc b/liboctave/pathsearch.cc --- a/liboctave/pathsearch.cc +++ b/liboctave/pathsearch.cc @@ -37,6 +37,10 @@ #include "kpse.cc" +char dir_path::path_sep_char = SEPCHAR; + +std::string dir_path::path_sep_str (SEPCHAR_STR); + static bool octave_kpathsea_initialized = false; string_vector diff --git a/liboctave/pathsearch.h b/liboctave/pathsearch.h --- a/liboctave/pathsearch.h +++ b/liboctave/pathsearch.h @@ -82,6 +82,11 @@ init (); } + static bool is_path_sep (char c) { return c == path_sep_char; } + + static char path_sep_char; + static std::string path_sep_str; + private: // The colon separated list that we were given. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2006-04-26 John W. Eaton + + * dirfns.cc (Ffilesep): New function to replace DEFCONST in + symbols_of_dirfns. + (Fpathsep): New function. + + * defaults.cc (set_default_default_exec_path): Use + dir_path::path_sep_str instead of std::string (SEPCHAR_STR). + (set_default_exec_path): Likewise. + (set_default_path): Likewise. + (maybe_add_default_load_path): Likewise. Use dir_path::is_path_sep. + 2006-04-18 John W. Eaton * DLD-FUNCTIONS/regexp.cc: Include , for transform decl. diff --git a/src/defaults.cc b/src/defaults.cc --- a/src/defaults.cc +++ b/src/defaults.cc @@ -264,9 +264,9 @@ set_default_default_exec_path (void) { Vdefault_exec_path - = Vlocal_ver_arch_lib_dir + std::string (SEPCHAR_STR) - + Vlocal_arch_lib_dir + std::string (SEPCHAR_STR) - + Varch_lib_dir + std::string (SEPCHAR_STR) + = Vlocal_ver_arch_lib_dir + dir_path::path_sep_str + + Vlocal_arch_lib_dir + dir_path::path_sep_str + + Varch_lib_dir + dir_path::path_sep_str + Vbin_dir; } @@ -281,7 +281,7 @@ if (! shell_path.empty ()) { - Vexec_path = std::string (SEPCHAR_STR); + Vexec_path = dir_path::path_sep_str; Vexec_path.append (shell_path); } } @@ -296,7 +296,7 @@ std::string oct_path = octave_env::getenv ("OCTAVE_PATH"); - Vload_path = oct_path.empty () ? std::string (SEPCHAR_STR) : oct_path; + Vload_path = oct_path.empty () ? dir_path::path_sep_str : oct_path; update_load_path_dir_path (); } @@ -365,7 +365,7 @@ if (! pathstring.empty ()) { - if (pathstring[0] == SEPCHAR) + if (dir_path::is_path_sep (pathstring[0])) { retval = Vdefault_load_path; retval.append (pathstring); @@ -373,14 +373,13 @@ else retval = pathstring; - if (pathstring[pathstring.length () - 1] == SEPCHAR) + if (dir_path::is_path_sep (pathstring[pathstring.length () - 1])) retval.append (Vdefault_load_path); size_t pos = 0; do { - pos = retval.find (std::string (SEPCHAR_STR) + - std::string (SEPCHAR_STR)); + pos = retval.find (dir_path::path_sep_str + dir_path::path_sep_str); if (pos != NPOS) retval.insert (pos+1, Vdefault_load_path); @@ -588,8 +587,8 @@ // I'm not sure whether this causes more problems that it // solves... // if (! (s[0] == ':' || s[s.length () - 1] == ':' - // || s.find (std::string (SEPCHAR_STR) + - // std::string (SEPCHAR_STR)) != NPOS)) + // || s.find (dir_path::path_sep_str + + // dir_path::path_sep_str) != NPOS)) // warning ("LOADPATH will ignore default load path"); Vload_path = s; diff --git a/src/dirfns.cc b/src/dirfns.cc --- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -45,6 +45,7 @@ #include "file-stat.h" #include "glob-match.h" #include "oct-env.h" +#include "pathsearch.h" #include "str-vec.h" #include "Cell.h" @@ -679,6 +680,41 @@ return retval; } +DEFUN (filesep, args, , + "-*- texinfo -*-\n\ +@detypefn {Built-in Function} {} filesep ()\n\ +Return the system-dependent character used to separate directory names.\n\ +@seealso{pathsep, dir, ls}\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 0) + retval = file_ops::dir_sep_str; + else + print_usage ("filesep"); + + return retval; +} + +DEFUN (pathsep, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} pathsep ()\n\ +Return the system-dependent character used to separate directories in\n\ +a path.\n\ +@seealso{filesep, dir, ls}\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 0) + retval = dir_path::path_sep_str; + else + print_usage ("pathsep"); + + return retval; +} + static int confirm_recursive_rmdir (void) { @@ -695,17 +731,8 @@ @defvr {Built-in Variable} confirm_recursive_rmdir\n\ If the value of @code{confirm_recursive_rmdir} is nonzero, Octave\n\ will ask for confirmation before recursively removing a directory tree.\n\ -The default value is 0.\n\ +The default value is 1.\n\ @end defvr"); - - DEFCONST (filesep, file_ops::dir_sep_str, - "-*- texinfo -*-\n\ -@defvr {Built-in Variable} filesep\n\ -The character used to separate directory names. The value\n\ -of this variable is system dependent.\n\ -@seealso{dir, ls}\n\ -@end defvr"); - } /*