]> granicus.if.org Git - apache/commitdiff
Modify ap_make_dirstr_prefix, platforms with HAVE_DRIVE_LETTERS or NETWARE
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 12 Oct 2000 19:45:56 +0000 (19:45 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 12 Oct 2000 19:45:56 +0000 (19:45 +0000)
  can request 0 elements, returning the '/' root.
  [William Rowe, Tim Costello]  from 1.3, with documentation

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86571 13f79535-47bb-0310-9956-ffa450edef68

include/httpd.h
server/util.c

index 9f6fe25e90a909a703e77e3160c96e79329f2e49..3c34bb7ea6dcc9e5b3f450dc8ff16c9d2e1d22ac 100644 (file)
@@ -1323,13 +1323,16 @@ API_EXPORT(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s);
  */
 API_EXPORT(int) ap_count_dirs(const char *path);
 /**
- * copy at most n leading directories of s into d d should be at least as 
- * large as s plus 1 extra byte assumes n > 0
+ * Copy at most n leading directories of s into d d should be at least as 
+ * large as s plus 1 extra byte
  * @param d The location to copy to
  * @param s The location to copy from
  * @param n The number of directories to copy
  * @return value is the ever useful pointer to the trailing \0 of d
  * @deffunc char *ap_make_dirstr_prefix(char *d, const char *s, int n)
+ * @tip on platforms with drive letters, n = 0 returns the "/" root, 
+ * whereas n = 1 returns the "d:/" root.  On all other platforms, n = 0
+ * returns the empty string.
  */
 API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
 /**
index 651a0cacecfe1126853e047015018d5638bf067b..dcff682a1d309d382840375b84bc0758696ca897 100644 (file)
@@ -529,7 +529,7 @@ API_EXPORT(void) ap_no2slash(char *name)
 
     s = d = name;
 
-#ifdef WIN32
+#ifdef HAVE_UNC_PATHS
     /* Check for UNC names.  Leave leading two slashes. */
     if (s[0] == '/' && s[1] == '/')
         *d++ = *s++;
@@ -563,6 +563,14 @@ API_EXPORT(void) ap_no2slash(char *name)
  */
 API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n)
 {
+#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE)
+    if (!n) {
+        *d = '/';
+        *++d = '\0';
+        return (d);
+    }
+#endif /* def HAVE_DRIVE_LETTERS || NETWARE */
+
     for (;;) {
        if (*s == '\0' || (*s == '/' && (--n) == 0)) {
            *d = '/';