diff options
author | Christopher Faylor <me@cgf.cx> | 2004-12-20 16:31:18 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2004-12-20 16:31:18 +0000 |
commit | 8d060512a60424a15628acb3bb3a7ede760396f5 (patch) | |
tree | 4ec31b147d598a6a215b33b157fe99819abc89f5 | |
parent | 7ffd6c6f1701e2ef54f8fe5ded590160767b0c6a (diff) | |
download | newlib-8d060512a60424a15628acb3bb3a7ede760396f5.zip newlib-8d060512a60424a15628acb3bb3a7ede760396f5.tar.gz newlib-8d060512a60424a15628acb3bb3a7ede760396f5.tar.bz2 |
* path.cc (normalize_posix_path): Remove unneeded check for dots.
(path_conv::set_normalized_path): Strip trailing dots, similarly to what had
previously been done for the win32 path.
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 27 |
2 files changed, 20 insertions, 13 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5c7d0d9..f65841b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2004-12-20 Christopher Faylor <cgf@timesys.com> + + * path.cc (normalize_posix_path): Remove unneeded check for dots. + (path_conv::set_normalized_path): Strip trailing dots, similarly to + what had previously been done for the win32 path. + 2004-12-18 Christopher Faylor <cgf@timesys.com> * path.cc (normalize_win32_path): Make third arg pass-by reference. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index dad90c3..f1c25c4 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -250,18 +250,7 @@ normalize_posix_path (const char *src, char *dst, char *&tail) break; } else if (src[2] && !isslash (src[2])) - { - if (src[2] == '.') - { - /* Is this a run of dots? That would be an invalid - filename. A bunch of leading dots would be ok, - though. */ - int n = strspn (src, "."); - if (!src[n] || isslash (src[n])) /* just dots... */ - return ENOENT; - } - break; - } + break; else { while (tail > dst && !isslash (*--tail)) @@ -438,7 +427,18 @@ void path_conv::set_normalized_path (const char *path_copy) { char *eopath = strchr (path, '\0'); - size_t n = strlen (path_copy) + 1; + size_t n; + + if (dev.devn != FH_FS || strncmp (path_copy, "//./", 4) == 0) + n = strlen (path_copy) + 1; + else + { + char *p = strchr (path_copy, '\0'); + while (*--p == '.' || *p == ' ') + continue; + p[1] = '\0'; + n = 2 + p - path_copy; + } normalized_path = path + sizeof (path) - n; if (normalized_path > eopath) @@ -448,6 +448,7 @@ path_conv::set_normalized_path (const char *path_copy) normalized_path = (char *) cmalloc (HEAP_STR, n); normalized_path_size = 0; } + memcpy (normalized_path, path_copy, n); } |