Don't support DOS paths for Cygwin.

From: David Rothenberger <daveroth@acm.org>

* But do support a little UNC.
---
 subversion/libsvn_subr/dirent_uri.c            |   55 +++++---
 subversion/tests/libsvn_subr/dirent_uri-test.c |  158 +++++++++++++++++++++---
 subversion/tests/libsvn_subr/path-test.c       |   10 +-
 3 files changed, 181 insertions(+), 42 deletions(-)

diff --git a/subversion/libsvn_subr/dirent_uri.c b/subversion/libsvn_subr/dirent_uri.c
index 059734c..38e4afb 100644
--- a/subversion/libsvn_subr/dirent_uri.c
+++ b/subversion/libsvn_subr/dirent_uri.c
@@ -56,7 +56,7 @@
 
 /* This check must match the check on top of dirent_uri-tests.c and
    path-tests.c */
-#if defined(WIN32) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(WIN32) || defined(__OS2__)
 #define SVN_USE_DOS_PATHS
 #endif
 
@@ -125,6 +125,7 @@ canonicalize_to_upper(char c)
 static apr_size_t
 dirent_root_length(const char *dirent, apr_size_t len)
 {
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
 #ifdef SVN_USE_DOS_PATHS
   if (len >= 2 && dirent[1] == ':' &&
       ((dirent[0] >= 'A' && dirent[0] <= 'Z') ||
@@ -132,6 +133,7 @@ dirent_root_length(const char *dirent, apr_size_t len)
     {
       return (len > 2 && dirent[2] == '/') ? 3 : 2;
     }
+#endif
 
   if (len > 2 && dirent[0] == '/' && dirent[1] == '/')
     {
@@ -141,7 +143,7 @@ dirent_root_length(const char *dirent, apr_size_t len)
         i++;
 
       if (i == len)
-        return len; /* Cygwin drive alias, invalid path on WIN32 */
+        return 1;
 
       i++; /* Skip '/' */
 
@@ -449,7 +451,7 @@ canonicalize(const char **canonical_path,
         {
           *(dst++) = *(src++);
 
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
           /* On Windows permit two leading separator characters which means an
            * UNC path. */
           if ((type == type_dirent) && *src == '/')
@@ -551,7 +553,7 @@ canonicalize(const char **canonical_path,
 
   *dst = '\0';
 
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
   /* Skip leading double slashes when there are less than 2
    * canon segments. UNC paths *MUST* have two segments. */
   if ((type == type_dirent) && canon[0] == '/' && canon[1] == '/')
@@ -689,7 +691,7 @@ get_longest_ancestor_length(path_type_t types,
   apr_size_t path1_len, path2_len;
   apr_size_t i = 0;
   apr_size_t last_dirsep = 0;
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
   svn_boolean_t unc = FALSE;
 #endif
 
@@ -722,7 +724,7 @@ get_longest_ancestor_length(path_type_t types,
     return 0;
 
   /* Handle some windows specific cases */
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
   if (types == type_dirent)
     {
       /* don't count the '//' from UNC paths */
@@ -732,6 +734,7 @@ get_longest_ancestor_length(path_type_t types,
           unc = TRUE;
         }
 
+#ifdef SVN_USE_DOS_PATHS
       /* X:/ and X:/foo */
       if (i == 3 && path1[2] == '/' && path1[1] == ':')
         return i;
@@ -749,8 +752,9 @@ get_longest_ancestor_length(path_type_t types,
       /* X: and X:foo */
       if (path1[i - 1] == ':' || path2[i - 1] == ':')
           return i;
-    }
 #endif /* SVN_USE_DOS_PATHS */
+    }
+#endif /* defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__) */
 
   /* last_dirsep is now the offset of the last directory separator we
      crossed before reaching a non-matching byte.  i is the offset of
@@ -765,18 +769,20 @@ get_longest_ancestor_length(path_type_t types,
     {
       /* Nothing in common but the root folder '/' or 'X:/' for Windows
          dirents. */
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
       if (! unc)
         {
+#ifdef SVN_USE_DOS_PATHS
           /* X:/foo and X:/bar returns X:/ */
           if ((types == type_dirent) &&
               last_dirsep == 2 && path1[1] == ':' && path1[2] == '/'
                                && path2[1] == ':' && path2[2] == '/')
             return 3;
 #endif /* SVN_USE_DOS_PATHS */
+#endif /* defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__) */
           if (last_dirsep == 0 && path1[0] == '/' && path2[0] == '/')
             return 1;
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
         }
 #endif
     }
@@ -952,7 +958,8 @@ svn_relpath__make_internal(const char **internal_style_relpath,
 svn_boolean_t
 svn_dirent_is_root(const char *dirent, apr_size_t len)
 {
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
+#ifndef __CYGWIN__
   /* On Windows and Cygwin, 'H:' or 'H:/' (where 'H' is any letter)
      are also root directories */
   if ((len == 2 || ((len == 3) && (dirent[2] == '/'))) &&
@@ -960,9 +967,9 @@ svn_dirent_is_root(const char *dirent, apr_size_t len)
       ((dirent[0] >= 'A' && dirent[0] <= 'Z') ||
        (dirent[0] >= 'a' && dirent[0] <= 'z')))
     return TRUE;
+#endif
 
-  /* On Windows and Cygwin //server/share is a root directory,
-     and on Cygwin //drive is a drive alias */
+  /* On Windows and Cygwin //server/share is a root directory */
   if (len >= 2 && dirent[0] == '/' && dirent[1] == '/'
       && dirent[len - 1] != '/')
     {
@@ -977,11 +984,7 @@ svn_dirent_is_root(const char *dirent, apr_size_t len)
                 return FALSE;
             }
         }
-#ifdef __CYGWIN__
-      return (segments <= 1);
-#else
       return (segments == 1); /* //drive is invalid on plain Windows */
-#endif
     }
 #endif
 
@@ -1822,7 +1825,7 @@ svn_dirent_is_canonical(const char *dirent, apr_pool_t *scratch_pool)
   if (*ptr == '/')
     {
       ptr++;
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
       /* Check for UNC paths */
       if (*ptr == '/')
         {
@@ -2509,7 +2512,7 @@ svn_uri_get_dirent_from_file_url(const char **dirent,
 
   /* Duplicate the URL, starting at the top of the path.
      At the same time, we URI-decode the path. */
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
   /* On Windows, we'll typically have to skip the leading / if the
      path starts with a drive letter.  Like most Web browsers, We
      support two variants of this scheme:
@@ -2526,10 +2529,11 @@ svn_uri_get_dirent_from_file_url(const char **dirent,
     even if the path looks like it starts with a drive letter.
   */
   {
-    static const char valid_drive_letters[] =
-      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     /* Casting away const! */
     char *dup_path = (char *)svn_path_uri_decode(path, pool);
+#ifdef SVN_USE_DOS_PATHS
+    static const char valid_drive_letters[] =
+      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
     /* This check assumes ':' and '|' are already decoded! */
     if (!hostname && dup_path[1] && strchr(valid_drive_letters, dup_path[1])
@@ -2562,6 +2566,7 @@ svn_uri_get_dirent_from_file_url(const char **dirent,
               dup_path[2] = '/'; /* Ensure not relative for '\' after drive! */
           }
       }
+#endif    
     if (hostname)
       {
         if (dup_path[0] == '/' && dup_path[1] == '\0')
@@ -2575,7 +2580,7 @@ svn_uri_get_dirent_from_file_url(const char **dirent,
     else
       *dirent = dup_path;
   }
-#else /* !SVN_USE_DOS_PATHS */
+#else /* !(defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)) */
   /* Currently, the only hostnames we are allowing on non-Win32 platforms
      are the empty string and 'localhost'. */
   if (hostname)
@@ -2603,7 +2608,15 @@ svn_uri_get_file_url_from_dirent(const char **url,
   if (dirent[0] == '/' && dirent[1] == '\0')
     dirent = NULL; /* "file://" is the canonical form of "file:///" */
 
+#ifdef __CYGWIN__
+  if (dirent != NULL && dirent[0] == '/' && dirent[1] == '/')
+      /* Handle UNC paths //server/share -> file://server/share */
+      *url = apr_pstrcat(pool, "file:", dirent, NULL);
+  else
+      *url = apr_pstrcat(pool, "file://", dirent, (char *)NULL);
+#else
   *url = apr_pstrcat(pool, "file://", dirent, SVN_VA_NULL);
+#endif
 #else
   if (dirent[0] == '/')
     {
diff --git a/subversion/tests/libsvn_subr/dirent_uri-test.c b/subversion/tests/libsvn_subr/dirent_uri-test.c
index 9afc5b6..a679344 100644
--- a/subversion/tests/libsvn_subr/dirent_uri-test.c
+++ b/subversion/tests/libsvn_subr/dirent_uri-test.c
@@ -45,7 +45,7 @@
 #define SVN_EMPTY_PATH ""
 
 /* This check must match the check on top of dirent_uri.c and path-tests.c */
-#if defined(WIN32) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(WIN32) || defined(__OS2__)
 #define SVN_USE_DOS_PATHS
 #endif
 
@@ -65,7 +65,7 @@ test_dirent_is_root(apr_pool_t *pool)
     { "/foo/bar",      FALSE },
     { "/foo",          FALSE },
     { "",              FALSE },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/foo",        FALSE },
     { "X:/",           TRUE },
     { "X:foo",         FALSE }, /* Based on non absolute root */
@@ -74,6 +74,14 @@ test_dirent_is_root(apr_pool_t *pool)
     { "//srv/shr/fld", FALSE },
     { "//srv/s r",     TRUE },
     { "//srv/s r/fld", FALSE },
+#elif defined(__CYGWIN__)
+    { "/",             TRUE },
+    { "/X:foo",        FALSE },
+    { "/X:",           FALSE },
+    { "//srv/shr",     TRUE },
+    { "//srv/shr/fld", FALSE },
+    { "//srv/s r",     TRUE },
+    { "//srv/s r/fld", FALSE },
 #else /* !SVN_USE_DOS_PATHS */
     { "/",             TRUE },
     { "/X:foo",        FALSE },
@@ -145,7 +153,7 @@ test_dirent_is_absolute(apr_pool_t *pool)
     { "foo/bar",       FALSE },
     { "foo",           FALSE },
     { "",              FALSE },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "/foo/bar",      FALSE },
     { "/foo",          FALSE },
     { "/",             FALSE },
@@ -157,6 +165,18 @@ test_dirent_is_absolute(apr_pool_t *pool)
     { "//srv/shr/fld", TRUE },
     { "//srv/s r",     TRUE },
     { "//srv/s r/fld", TRUE },
+#elif defined(__CYGWIN__)
+    { "/foo/bar",      TRUE },
+    { "/foo",          TRUE },
+    { "/",             TRUE },
+    { "C:/foo",        FALSE },
+    { "C:/",           FALSE },
+    { "c:/",           FALSE },
+    { "c:/foo",        FALSE },
+    { "//srv/shr",     TRUE },
+    { "//srv/shr/fld", TRUE },
+    { "//srv/s r",     TRUE },
+    { "//srv/s r/fld", TRUE },
 #else /* !SVN_USE_DOS_PATHS */
     { "/foo/bar",      TRUE },
     { "/foo",          TRUE },
@@ -228,7 +248,7 @@ test_dirent_join(apr_pool_t *pool)
     { SVN_EMPTY_PATH, "/abc", "/abc" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "/", "/", "/" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/", SVN_EMPTY_PATH, "X:/" },
     { "X:/", "abc", "X:/abc" },
     { "X:/", "/def", "X:/def" },
@@ -251,6 +271,14 @@ test_dirent_join(apr_pool_t *pool)
     { "aa", "A:", "A:" },
     { "aa", "A:file", "A:file"},
     { "A:", "/", "A:/" },
+#elif defined(__CYGWIN__)
+    { "X:abc", "X:/def", "X:abc/X:/def" },
+    { "X:","abc", "X:/abc" },
+    { "X:/abc", "X:/def", "X:/abc/X:/def" },
+    { "//srv/shr",     "fld",     "//srv/shr/fld" },
+    { "//srv/shr/fld", "subfld",  "//srv/shr/fld/subfld" },
+    { "//srv/shr/fld", "//srv/shr", "//srv/shr" },
+    { "//srv/s r",     "fld",     "//srv/s r/fld" },
 #else /* !SVN_USE_DOS_PATHS */
     { "X:abc", "X:/def", "X:abc/X:/def" },
     { "X:","abc", "X:/abc" },
@@ -319,7 +347,7 @@ test_dirent_join(apr_pool_t *pool)
   TEST_MANY((pool, SVN_EMPTY_PATH, "/", SVN_EMPTY_PATH, SVN_VA_NULL), "/");
   TEST_MANY((pool, SVN_EMPTY_PATH, SVN_EMPTY_PATH, "/", SVN_VA_NULL), "/");
 
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
   TEST_MANY((pool, "X:/", "def", "ghi", SVN_VA_NULL), "X:/def/ghi");
   TEST_MANY((pool, "abc", "X:/", "ghi", SVN_VA_NULL), "X:/ghi");
   TEST_MANY((pool, "abc", "def", "X:/", SVN_VA_NULL), "X:/");
@@ -348,6 +376,17 @@ test_dirent_join(apr_pool_t *pool)
   TEST_MANY((pool, "abcd", "/dir", "A:", "file", SVN_VA_NULL), "A:file");
   TEST_MANY((pool, "abcd", "A:", "/dir", "file", SVN_VA_NULL), "A:/dir/file");
 
+#elif defined(__CYGWIN__)
+  TEST_MANY((pool, "X:", "def", "ghi", SVN_VA_NULL), "X:/def/ghi");
+  TEST_MANY((pool, "X:", SVN_EMPTY_PATH, "ghi", SVN_VA_NULL), "X:/ghi");
+  TEST_MANY((pool, "X:", "def", SVN_EMPTY_PATH, SVN_VA_NULL), "X:/def");
+  TEST_MANY((pool, SVN_EMPTY_PATH, "X:", "ghi", SVN_VA_NULL), "X:/ghi");
+  TEST_MANY((pool, "//srv/shr", "def", "ghi", SVN_VA_NULL), "//srv/shr/def/ghi");
+  TEST_MANY((pool, "//srv/shr/fld", "def", "ghi", SVN_VA_NULL), "//srv/shr/fld/def/ghi");
+  TEST_MANY((pool, "//srv/shr/fld", "def", "//srv/shr", SVN_VA_NULL), "//srv/shr");
+  TEST_MANY((pool, "//srv/s r/fld", "def", "//srv/s r", SVN_VA_NULL), "//srv/s r");
+  TEST_MANY((pool, SVN_EMPTY_PATH, "//srv/shr/fld", "def", "ghi", SVN_VA_NULL), "//srv/shr/fld/def/ghi");
+  TEST_MANY((pool, SVN_EMPTY_PATH, "//srv/shr/fld", "def", "//srv/shr", SVN_VA_NULL), "//srv/shr");
 #else /* !SVN_USE_DOS_PATHS */
   TEST_MANY((pool, "X:", "def", "ghi", SVN_VA_NULL), "X:/def/ghi");
   TEST_MANY((pool, "X:", SVN_EMPTY_PATH, "ghi", SVN_VA_NULL), "X:/ghi");
@@ -423,7 +462,7 @@ test_dirent_basename(apr_pool_t *pool)
     { "/", "" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "X:/abc", "abc" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:", "" },
     { "X:/", "" },
     { "X:abc", "abc" },
@@ -431,6 +470,13 @@ test_dirent_basename(apr_pool_t *pool)
     { "//srv/shr/fld", "fld" },
     { "//srv/shr/fld/subfld", "subfld" },
     { "//srv/s r/fld", "fld" },
+#elif defined(__CYGWIN__)
+    { "X:", "X:" },
+    { "X:abc", "X:abc" },
+    { "//srv/shr", "" },
+    { "//srv/shr/fld", "fld" },
+    { "//srv/shr/fld/subfld", "subfld" },
+    { "//srv/s r/fld", "fld" },
 #else /* !SVN_USE_DOS_PATHS */
     { "X:", "X:" },
     { "X:abc", "X:abc" },
@@ -540,7 +586,7 @@ test_dirent_dirname(apr_pool_t *pool)
     { "/", "/" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "X:abc/def", "X:abc" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/", "X:/" },
     { "X:/abc", "X:/" },
     { "X:abc", "X:" },
@@ -549,6 +595,14 @@ test_dirent_dirname(apr_pool_t *pool)
     { "//srv/shr/fld",  "//srv/shr" },
     { "//srv/shr/fld/subfld", "//srv/shr/fld" },
     { "//srv/s r/fld",  "//srv/s r" },
+#elif defined(__CYGWIN__)
+    /* on non-Windows platforms, ':' is allowed in pathnames */
+    { "X:", "" },
+    { "X:abc", "" },
+    { "//srv/shr",      "//srv/shr" },
+    { "//srv/shr/fld",  "//srv/shr" },
+    { "//srv/shr/fld/subfld", "//srv/shr/fld" },
+    { "//srv/s r/fld",  "//srv/s r" },
 #else /* !SVN_USE_DOS_PATHS */
     /* on non-Windows platforms, ':' is allowed in pathnames */
     { "X:", "" },
@@ -695,7 +749,9 @@ test_dirent_canonicalize(apr_pool_t *pool)
     { "x:/",                  "X:/" },
     { "x:",                   "X:" },
     { "x:AAAAA",              "X:AAAAA" },
-    /* We permit UNC dirents on Windows.  By definition UNC
+#endif /* SVN_USE_DOS_PATHS */
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
+    /* We permit UNC dirents on Windows and Cygwin.  By definition UNC
      * dirents must have two components so we should remove the
      * double slash if there is only one component. */
     { "//hst/foo",            "//hst/foo" },
@@ -706,7 +762,7 @@ test_dirent_canonicalize(apr_pool_t *pool)
     { "//SERVER/SHare/",      "//server/SHare" },
     { "//srv/s r",            "//srv/s r" },
     { "//srv/s r/qq",         "//srv/s r/qq" },
-#endif /* SVN_USE_DOS_PATHS */
+#endif /* defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__) */
   };
 
   for (t = tests; t < tests + COUNT_OF(tests); t++)
@@ -1077,7 +1133,7 @@ test_dirent_is_canonical(apr_pool_t *pool)
     { "X:foo",                 TRUE },
     { "X:foo/",                FALSE },
     { "file with spaces",      TRUE },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/",                   TRUE },
     { "X:/foo",                TRUE },
     { "X:",                    TRUE },
@@ -1096,6 +1152,22 @@ test_dirent_is_canonical(apr_pool_t *pool)
     { "//server/SHare",        TRUE },
     { "//SERVER/SHare",        FALSE },
     { "//srv/SH RE",           TRUE },
+#elif defined(__CYGWIN__)
+    { "X:/",                   FALSE },
+    /* Some people use colons in their filenames. */
+    { ":", TRUE },
+    { ".:", TRUE },
+    { "foo/.:", TRUE },
+    /* We permit UNC dirents on Cygwin.  By definition UNC
+     * dirents must have two components so we should remove the
+     * double slash if there is only one component. */
+    { "//hst",                 FALSE },
+    { "//hst/./",              FALSE },
+    { "//server/share/",       FALSE },
+    { "//server/share",        TRUE },
+    { "//server/SHare",        TRUE },
+    { "//SERVER/SHare",        FALSE },
+    { "//srv/SH RE",           TRUE },
 #else /* !SVN_USE_DOS_PATHS */
     { "X:/",                   FALSE },
     /* Some people use colons in their filenames. */
@@ -1279,13 +1351,18 @@ test_dirent_split(apr_pool_t *pool)
     { "/",               "/",             "" },
     { "X:/foo/bar",      "X:/foo",        "bar" },
     { "X:foo/bar",       "X:foo",         "bar" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/",             "X:/",           "" },
     { "X:/foo",          "X:/",           "foo" },
     { "X:foo",           "X:",            "foo" },
     { "//srv/shr",       "//srv/shr",     "" },
     { "//srv/shr/fld",   "//srv/shr",     "fld" },
     { "//srv/s r",       "//srv/s r",     "" },
+#elif defined(__CYGWIN__)
+    { "X:foo",           SVN_EMPTY_PATH,  "X:foo" },
+    { "//srv/shr",       "//srv/shr",     "" },
+    { "//srv/shr/fld",   "//srv/shr",     "fld" },
+    { "//srv/s r",       "//srv/s r",     "" },
 #else /* !SVN_USE_DOS_PATHS */
     { "X:foo",           SVN_EMPTY_PATH,  "X:foo" },
 #endif /* SVN_USE_DOS_PATHS */
@@ -1425,7 +1502,7 @@ static const testcase_ancestor_t dirent_ancestor_tests[] =
     { "/foo/bar/zig",   "/foo",             NULL },
     { "/foo/bar/zig",   "/foo/ba",          NULL },
     { "/foo/bar/zig",   "/foo/bar/zi",      NULL },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "",               "C:",               NULL },
     { "",               "C:foo",            NULL },
     { "",               "C:/",              NULL },
@@ -1459,6 +1536,21 @@ static const testcase_ancestor_t dirent_ancestor_tests[] =
     { "//srv/shr/fld",  "//srv2/shr/fld",   NULL },
     { "//srv/shr/fld",  "//srv/shr/f",      NULL },
     { "/",              "//srv/share",      NULL },
+#elif defined(__CYGWIN__)
+    { "",               "C:",               "C:" },
+    { "",               "C:/foo",           "C:/foo" },
+    { "X:",             "X:foo",            NULL },
+    { "//srv",          "//srv/share",      NULL },
+    { "//srv",          "//srv/shr/fld",    NULL },
+    { "//srv/shr",      "//srv",            NULL },
+    { "//srv/share",    "//vrs/share",      NULL },
+    { "//srv/share",    "//srv/share/foo",  "foo" },
+    { "//srv/shr",      "//srv/shr/fld",    "fld" },
+    { "//srv/s r",      "//srv/s r/fld",    "fld" },
+    { "//srv/shr/fld",  "//srv/shr",        NULL },
+    { "//srv/shr/fld",  "//srv2/shr/fld",   NULL },
+    { "//srv/shr/fld",  "//srv/shr/f",      NULL },
+    { "/",              "//srv/share",      NULL },
 #else /* !SVN_USE_DOS_PATHS */
     { "",               "C:",               "C:" },
     { "",               "C:/foo",           "C:/foo" },
@@ -1646,7 +1738,7 @@ test_dirent_get_longest_ancestor(apr_pool_t *pool)
     { "/",              "/",               "/"},
     { "X:foo",          "Y:foo",           SVN_EMPTY_PATH},
     { "X:/folder1",     "Y:/folder2",      SVN_EMPTY_PATH},
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "X:/",            "X:/",             "X:/"},
     { "X:/foo/bar/A/D/H/psi", "X:/foo/bar/A/B", "X:/foo/bar/A" },
     { "X:/foo/bar/boo", "X:/foo/bar/baz/boz", "X:/foo/bar"},
@@ -1660,6 +1752,14 @@ test_dirent_get_longest_ancestor(apr_pool_t *pool)
     { "X:",             "X:foo",           "X:"},
     { "X:",             "X:/",             SVN_EMPTY_PATH},
     { "X:foo",          "X:bar",           "X:"},
+#elif defined(__CYGWIN__)
+    { "X:/foo",         "X:",              "X:"},
+    { "X:/folder1",     "X:/folder2",      "X:"},
+    { "X:",             "X:foo",           SVN_EMPTY_PATH},
+    { "X:foo",          "X:bar",           SVN_EMPTY_PATH},
+    { "//srv/shr",      "//srv/shr/fld",   "//srv/shr" },
+    { "//srv/shr/fld",  "//srv/shr",       "//srv/shr" },
+    { "//srv/shr/fld",  "//srv2/shr/fld",  SVN_EMPTY_PATH },
 #else /* !SVN_USE_DOS_PATHS */
     { "X:/foo",         "X:",              "X:"},
     { "X:/folder1",     "X:/folder2",      "X:"},
@@ -1805,11 +1905,13 @@ test_dirent_is_child(apr_pool_t *pool)
     ".foo",
     "/",
     "foo2",
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
     "//srv",
     "//srv2",
     "//srv/shr",
     "//srv/shr/fld",
+#endif
+#ifdef SVN_USE_DOS_PATHS
     "H:/foo/bar",
     "H:/foo/baz",
     "H:/foo/bar/baz",
@@ -1851,7 +1953,7 @@ test_dirent_is_child(apr_pool_t *pool)
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
     /* //srv paths */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, "shr", "shr/fld", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -1861,6 +1963,8 @@ test_dirent_is_child(apr_pool_t *pool)
       0, 0, 0, "fld", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+#endif
+#ifdef SVN_USE_DOS_PATHS
     /* H:/ paths */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, "baz", 0, "baz/bing/boom", 0, 0, 0, 0, 0 },
@@ -2229,13 +2333,19 @@ test_dirent_local_style(apr_pool_t *pool)
   } tests[] = {
     { "",                     "." },
     { ".",                    "." },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "A:/",                 "A:\\" },
     { "A:/file",             "A:\\file" },
     { "dir/file",            "dir\\file" },
     { "/",                   "\\" },
     { "//server/share/dir",  "\\\\server\\share\\dir" },
     { "//server/sh re/dir",  "\\\\server\\sh re\\dir" },
+#elif defined(__CYGWIN__)
+    { "a:/file",             "a:/file" },
+    { "dir/file",            "dir/file" },
+    { "/",                   "/" },
+    { "//server/share/dir",  "//server/share/dir" },
+    { "//server/sh re/dir",  "//server/sh re/dir" },
 #else
     { "a:/file",             "a:/file" },
     { "dir/file",            "dir/file" },
@@ -2271,7 +2381,7 @@ test_dirent_internal_style(apr_pool_t *pool)
     { "file",                "file" },
     { "dir/file",            "dir/file" },
     { "dir/file/./.",        "dir/file" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "A:\\",                "A:/" },
     { "A:\\file",            "A:/file" },
     { "A:file",              "A:file" },
@@ -2286,6 +2396,14 @@ test_dirent_internal_style(apr_pool_t *pool)
     { "//srv/shr",           "//srv/shr" },
     { "//srv/s r",           "//srv/s r" },
     { "//srv/s r",           "//srv/s r" },
+#elif defined(__CYGWIN__)
+    { "a:/",                 "a:" }, /* Wrong but expected for svn_path_*() */
+    { "a:/file",             "a:/file" },
+    { "dir/file",            "dir/file" },
+    { "/",                   "/" },
+    { "//srv/shr",           "//srv/shr" },
+    { "//srv/s r",           "//srv/s r" },
+    { "//srv/s r",           "//srv/s r" },
 #else
     { "a:/",                 "a:" }, /* Wrong but expected for svn_path_*() */
     { "a:/file",             "a:/file" },
@@ -2358,9 +2476,11 @@ test_dirent_from_file_url(apr_pool_t *pool)
     { "file://localhost",          "/" },
     { "file://localhost/dir",      "/dir" },
     { "file://localhost/dir/path", "/dir/path" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__)
     { "file://server/share",       "//server/share" },
     { "file://server/share/dir",   "//server/share/dir" },
+#endif
+#ifdef SVN_USE_DOS_PATHS
     { "file:///A:",                "A:/" },
     { "file:///A:/dir",            "A:/dir" },
     { "file:///A:dir",             "A:dir" },
@@ -2418,7 +2538,7 @@ test_dirent_from_file_url_errors(apr_pool_t *pool)
     /* error if scheme is not "file" */
     "http://localhost/dir",
     "file+ssh://localhost/dir",
-#ifndef SVN_USE_DOS_PATHS
+#if !(defined(SVN_USE_DOS_PATHS) || defined(__CYGWIN__))
     "file://localhostwrongname/dir",  /* error if host name not "localhost" */
 #endif
   };
diff --git a/subversion/tests/libsvn_subr/path-test.c b/subversion/tests/libsvn_subr/path-test.c
index 6f0a996..3a8e2fb 100644
--- a/subversion/tests/libsvn_subr/path-test.c
+++ b/subversion/tests/libsvn_subr/path-test.c
@@ -53,7 +53,7 @@
 
 /* This check must match the check on top of dirent_uri.c and
    dirent_uri-tests.c */
-#if defined(WIN32) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(WIN32) || defined(__OS2__)
 #define SVN_USE_DOS_PATHS
 #endif
 
@@ -1438,12 +1438,18 @@ test_path_internal_style(apr_pool_t *pool)
     { ".",                    "" },
     { "http://host/dir",      "http://host/dir" },
     { "/",                    "/" },
-#ifdef SVN_USE_DOS_PATHS
+#if defined(SVN_USE_DOS_PATHS)
     { "a:\\",                 "A:/" },
     { "a:\\file",             "A:/file" },
     { "dir\\file",            "dir/file" },
     { "\\",                   "/" },
     { "\\\\server/share/dir",  "//server/share/dir" },
+#elif defined(__CYGWIN__)
+    { "a:/",                 "a:" },
+    { "a:/file",             "a:/file" },
+    { "dir/file",            "dir/file" },
+    { "/",                   "/" },
+    { "//server/share/dir",  "//server/share/dir" },
 #else
     { "a:/",                 "a:" },
     { "a:/file",             "a:/file" },
