changeset 5777:246b1fc1e628

[project @ 2006-04-26 18:16:24 by jwe]
author jwe
date Wed, 26 Apr 2006 18:16:25 +0000
parents 1182d6852172
children 70f67d85558d
files liboctave/ChangeLog liboctave/pathsearch.cc liboctave/pathsearch.h src/ChangeLog src/defaults.cc src/dirfns.cc
diffstat 6 files changed, 75 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Wed Apr 26 01:23:17 2006 +0000
+++ b/liboctave/ChangeLog	Wed Apr 26 18:16:25 2006 +0000
@@ -1,3 +1,10 @@
+2006-04-26  John W. Eaton  <jwe@octave.org>
+
+	* 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  <jwe@octave.org>
 
 	* randmtzig.c (randmt, randi53, randi54, randi64, randu32, randu53):
--- a/liboctave/pathsearch.cc	Wed Apr 26 01:23:17 2006 +0000
+++ b/liboctave/pathsearch.cc	Wed Apr 26 18:16:25 2006 +0000
@@ -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
--- a/liboctave/pathsearch.h	Wed Apr 26 01:23:17 2006 +0000
+++ b/liboctave/pathsearch.h	Wed Apr 26 18:16:25 2006 +0000
@@ -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.
--- a/src/ChangeLog	Wed Apr 26 01:23:17 2006 +0000
+++ b/src/ChangeLog	Wed Apr 26 18:16:25 2006 +0000
@@ -1,3 +1,15 @@
+2006-04-26  John W. Eaton  <jwe@octave.org>
+
+	* 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  <jwe@octave.org>
 
 	* DLD-FUNCTIONS/regexp.cc: Include <algorithm>, for transform decl.
--- a/src/defaults.cc	Wed Apr 26 01:23:17 2006 +0000
+++ b/src/defaults.cc	Wed Apr 26 18:16:25 2006 +0000
@@ -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;
--- a/src/dirfns.cc	Wed Apr 26 01:23:17 2006 +0000
+++ b/src/dirfns.cc	Wed Apr 26 18:16:25 2006 +0000
@@ -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");
-
 }
 
 /*