diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-03 18:22:49 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-03 18:22:49 +0000 |
commit | 851c6a9e91008ddef4da79bfb09f087878961dde (patch) | |
tree | e2d39cd0f382917960f27222b0dd6fc060f62ec4 | |
parent | 0e8785fafda408234f84e13af6ac8ae74d491457 (diff) | |
download | libapr-851c6a9e91008ddef4da79bfb09f087878961dde.tar.gz |
Remove assumption that drive letters are always uppercase.
* file_io/win32/filepath.c:
(same_drive): new helper function
(apr_filepath_merge): use helper rather than a simple comparison
* test/testnames.c:
(merge_lowercasedrive): do some tests with lowercase drive names
Patch by: Bert Huijben <bert {at} qqmail.nl>
Backports: r960665
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1099173 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | file_io/win32/filepath.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/file_io/win32/filepath.c b/file_io/win32/filepath.c index e44a81f8f..1c6fe1430 100644 --- a/file_io/win32/filepath.c +++ b/file_io/win32/filepath.c @@ -327,6 +327,19 @@ 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) +{ + /* Alpha-colon pattern test, assumes an ASCII character set mapping */ + if ((path1[0] < 'A' || (path1[0] > 'Z' && path1[0] < 'a') || path1[0] > 'z') + || (path2[0] < 'A' || (path2[0] > 'Z' && path2[0] < 'a') || path2[0] > 'z') + || path1[1] != ':' || path2[1] != ':') + return 0; + + /* Once in the domain of ASCII alpha, compare these case insensitive */ + return ((path1[0] & 0x1f) == (path2[0] & 0x1f)); +} +#endif APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, const char *basepath, @@ -540,7 +553,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 */ |