changeset 4087:a54f61b5d491

[project @ 2002-10-05 03:02:56 by jwe]
author jwe
date Sat, 05 Oct 2002 03:03:45 +0000
parents ddc722b38e87
children 933ac1113625
files liboctave/ChangeLog liboctave/oct-env.cc
diffstat 2 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Oct 03 19:08:45 2002 +0000
+++ b/liboctave/ChangeLog	Sat Oct 05 03:03:45 2002 +0000
@@ -1,3 +1,10 @@
+2002-10-04  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* oct-env.cc (octave_env::do_absolute_pathname): Handle Windows
+	filenames.
+	(octave_env::do_make_absolute): Check for absolute name with
+	do_absolute_path.
+
 2002-10-03  Paul Kienzle <pkienzle@users.sf.net>
 
 	* oct-time.cc (octave_time::stamp): Better resolution for Windows
--- a/liboctave/oct-env.cc	Thu Oct 03 19:08:45 2002 +0000
+++ b/liboctave/oct-env.cc	Sat Oct 05 03:03:45 2002 +0000
@@ -228,25 +228,35 @@
   return retval;
 }
 
-// Return 1 if STRING contains an absolute pathname, else 0.
+#if defined (__CYGWIN__)
+#define IS_DIR_SEP(c) (c == '/' || c == '\\')
+#else
+#define IS_DIR_SEP(c) (c == '/')
+#endif
 
 bool
 octave_env::do_absolute_pathname (const std::string& s) const
 {
-  if (s.empty ())
-    return 0;
+  size_t len = s.length ();
+
+  if (len == 0)
+    return false;
 
   if (s[0] == '/')
     return true;
 
+#if defined (__CYGWIN__)
+  if (len > 2 && isalpha (s[0]) && s[1] == ':' && IS_DIR_SEP (s[2]))
+    return true;
+#endif
+
   if (s[0] == '.')
     {
-      if (s[1] == '\0' || s[1] == '/')
+      if (len == 1 || IS_DIR_SEP (s[1]))
 	return true;
 
-      if (s[1] == '.')
-	if (s[2] == '\0' || s[2] == '/')
-	  return true;
+      if (s[1] == '.' && (len == 2 || IS_DIR_SEP (s[2])))
+	return true;
     }
 
   return false;
@@ -281,7 +291,7 @@
     return s;
 #endif
 
-  if (dot_path.empty () || s[0] == '/' || s.empty ())
+  if (dot_path.empty () || s.empty () || do_absolute_pathname (s))
     return s;
 
   std::string current_path = dot_path;