diff options
Diffstat (limited to 'srclib/apr/file_io/win32/filepath.c')
| -rw-r--r-- | srclib/apr/file_io/win32/filepath.c | 26 | 
1 files changed, 23 insertions, 3 deletions
| diff --git a/srclib/apr/file_io/win32/filepath.c b/srclib/apr/file_io/win32/filepath.c index 766e35f8..559d1b28 100644 --- a/srclib/apr/file_io/win32/filepath.c +++ b/srclib/apr/file_io/win32/filepath.c @@ -327,6 +327,27 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath,  #endif /* ndef(NETWARE) */  } +#if !defined(NETWARE) +static int same_drive(const char *path1, const char *path2) +{ +    char drive1 = path1[0]; +    char drive2 = path2[0]; + +    if (!drive1 || !drive2 || path1[1] != ':' || path2[1] != ':') +        return FALSE; + +    if (drive1 == drive2) +        return TRUE; + +    if (drive1 >= 'a' && drive1 <= 'z') +        drive1 += 'A' - 'a'; + +    if (drive2 >= 'a' && drive2 <= 'z') +        drive2 += 'A' - 'a'; + +    return (drive1 == drive2); +} +#endif  APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath,                                                const char *basepath,  @@ -540,7 +561,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath,               * use the basepath _if_ it matches this drive letter!               * Otherwise we must discard the basepath.               */ -            if (addroot[0] == baseroot[0] && baseroot[1] == ':') { +            if (same_drive(addroot, baseroot)) {  #endif                  /* Base the result path on the basepath                   */ @@ -949,8 +970,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath,          }      } -    *newpath = apr_pmemdup(p, path, pathlen + 1); -    (*newpath)[pathlen] = '\0'; +    *newpath = apr_pstrmemdup(p, path, pathlen);      return APR_SUCCESS;  } | 
