apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1099173 - /apr/apr/branches/1.4.x/file_io/win32/filepath.c
Date Tue, 03 May 2011 18:22:49 GMT
Author: wrowe
Date: Tue May  3 18:22:49 2011
New Revision: 1099173

URL: http://svn.apache.org/viewvc?rev=1099173&view=rev
Log:
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

Modified:
    apr/apr/branches/1.4.x/file_io/win32/filepath.c

Modified: apr/apr/branches/1.4.x/file_io/win32/filepath.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/win32/filepath.c?rev=1099173&r1=1099172&r2=1099173&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/win32/filepath.c (original)
+++ apr/apr/branches/1.4.x/file_io/win32/filepath.c Tue May  3 18:22:49 2011
@@ -327,6 +327,19 @@ APR_DECLARE(apr_status_t) apr_filepath_r
 #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_m
              * 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
                  */



Mime
View raw message