Mercurial > hg > octave-lyh
diff liboctave/oct-env.cc @ 4087:a54f61b5d491
[project @ 2002-10-05 03:02:56 by jwe]
author | jwe |
---|---|
date | Sat, 05 Oct 2002 03:03:45 +0000 |
parents | 63c75bc3db82 |
children | 933ac1113625 |
line wrap: on
line diff
--- a/liboctave/oct-env.cc +++ b/liboctave/oct-env.cc @@ -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;