Index: path.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.198 diff -u -3 -p -u -p -a -r1.198 path.cc --- path.cc 2002/02/22 19:33:41 1.198 +++ path.cc 2002/03/07 00:35:35 @@ -3204,21 +3236,24 @@ chdir (const char *in_dir) } - /* Look for trailing path component consisting entirely of dots. This + /* Look for path component consisting entirely of dots. This is needed only in case of chdir since Windows simply ignores count of dots > 2 here instead of returning an error code. Counts of dots <= 2 are already eliminated by normalize_posix_path. */ - const char *p = strrchr (dir, '/'); - if (!p) - p = dir; - else - p++; - - size_t len = strlen (p); - if (len > 2 && strspn (p, ".") == len) + const char *p, *last_slash = dir, *end = dir + strlen (dir); + while (last_slash < end) { - set_errno (ENOENT); - return -1; + p = strchr (last_slash, '/'); + if (!p) + p = end; + + size_t len = p - last_slash; + if (len > 2 && strspn (last_slash, ".") == len) + { + set_errno (ENOENT); + return -1; + } + last_slash = p + 1; } const char *native_dir = path.get_win32 ();