Mercurial > hg > octave-lyh
comparison 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 |
comparison
equal
deleted
inserted
replaced
4086:ddc722b38e87 | 4087:a54f61b5d491 |
---|---|
226 retval = name; | 226 retval = name; |
227 | 227 |
228 return retval; | 228 return retval; |
229 } | 229 } |
230 | 230 |
231 // Return 1 if STRING contains an absolute pathname, else 0. | 231 #if defined (__CYGWIN__) |
232 #define IS_DIR_SEP(c) (c == '/' || c == '\\') | |
233 #else | |
234 #define IS_DIR_SEP(c) (c == '/') | |
235 #endif | |
232 | 236 |
233 bool | 237 bool |
234 octave_env::do_absolute_pathname (const std::string& s) const | 238 octave_env::do_absolute_pathname (const std::string& s) const |
235 { | 239 { |
236 if (s.empty ()) | 240 size_t len = s.length (); |
237 return 0; | 241 |
242 if (len == 0) | |
243 return false; | |
238 | 244 |
239 if (s[0] == '/') | 245 if (s[0] == '/') |
240 return true; | 246 return true; |
241 | 247 |
248 #if defined (__CYGWIN__) | |
249 if (len > 2 && isalpha (s[0]) && s[1] == ':' && IS_DIR_SEP (s[2])) | |
250 return true; | |
251 #endif | |
252 | |
242 if (s[0] == '.') | 253 if (s[0] == '.') |
243 { | 254 { |
244 if (s[1] == '\0' || s[1] == '/') | 255 if (len == 1 || IS_DIR_SEP (s[1])) |
245 return true; | 256 return true; |
246 | 257 |
247 if (s[1] == '.') | 258 if (s[1] == '.' && (len == 2 || IS_DIR_SEP (s[2]))) |
248 if (s[2] == '\0' || s[2] == '/') | 259 return true; |
249 return true; | |
250 } | 260 } |
251 | 261 |
252 return false; | 262 return false; |
253 } | 263 } |
254 | 264 |
279 #if defined (__EMX__) | 289 #if defined (__EMX__) |
280 if (s.length () > 1 && s[1] == ':') | 290 if (s.length () > 1 && s[1] == ':') |
281 return s; | 291 return s; |
282 #endif | 292 #endif |
283 | 293 |
284 if (dot_path.empty () || s[0] == '/' || s.empty ()) | 294 if (dot_path.empty () || s.empty () || do_absolute_pathname (s)) |
285 return s; | 295 return s; |
286 | 296 |
287 std::string current_path = dot_path; | 297 std::string current_path = dot_path; |
288 | 298 |
289 if (current_path.empty ()) | 299 if (current_path.empty ()) |