]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add IgnoreCase keyword for case-insensitve directory listing
authorKen Coar <coar@apache.org>
Wed, 6 Feb 2002 15:53:37 +0000 (15:53 +0000)
committerKen Coar <coar@apache.org>
Wed, 6 Feb 2002 15:53:37 +0000 (15:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@93290 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/modules/standard/mod_autoindex.c

index f72b92965b134dcf2261d35e5586ce3e3e1dc6ee..83705c2ed143cd2113eaf61578720ca5031e401f 100644 (file)
@@ -1,8 +1,14 @@
 Changes with Apache 1.3.24
 
+  *) Add 'IgnoreCase' keyword to the DirectoryIndex directive;
+     if active, upper- and lower-case letters are insignificant
+     in ordering.  In other words, all A* and a* files will be
+     listed together, rather than the a* ones after all the [A-Z]*
+     ones.  [Tullio Andreatta <tullio@logicom.it>]
+
   *) NetWare: Implemented the real ap_os_case_canonical_filename()
-      function that retrieves the accurately cased path and file
-      name from the file system. [Brad Nicholes bnicholes@novell.com]
+     function that retrieves the accurately cased path and file
+     name from the file system. [Brad Nicholes bnicholes@novell.com]
 
   *) Fix the longstanding bug that errors (returned by src/Configure)
      would not be noticed by the top level configure script.
index 607b5280f02ea88412ef9ede06ae1f0425eab1c4..8c25dfcb5e8f137d48052802d7c44b21fcc0ada4 100644 (file)
@@ -98,6 +98,7 @@ module MODULE_VAR_EXPORT autoindex_module;
 #define NO_OPTIONS 256
 #define FOLDERS_FIRST 512
 #define TRACK_MODIFIED 1024
+#define SORT_NOCASE 2048
 
 #define K_PAD 1
 #define K_NOPAD 0
@@ -411,6 +412,9 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr)
        else if (!strcasecmp(w, "TrackModified")) {
             option = TRACK_MODIFIED;
        }
+       else if (!strcasecmp(w, "IgnoreCase")) {
+            option = SORT_NOCASE;
+       }
         else if (!strcasecmp(w, "None")) {
            if (action != '\0') {
                return "Cannot combine '+' or '-' with 'None' keyword";
@@ -732,6 +736,7 @@ struct ent {
     int ascending;
     int isdir;
     int checkdir;
+    int ignorecase;
     char key;
 };
 
@@ -1222,6 +1227,7 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
      * rather than CPU.
      */
     p->checkdir = ((d->opts & FOLDERS_FIRST) != 0);
+    p->ignorecase = ((d->opts & SORT_NOCASE) != 0);
     p->key = ap_toupper(keyid);
     p->ascending = (ap_toupper(direction) == D_ASCENDING);
 
@@ -1536,6 +1542,7 @@ static int dsortf(struct ent **e1, struct ent **e2)
     struct ent *c1;
     struct ent *c2;
     int result = 0;
+    int ignorecase;
 
     /*
      * First, see if either of the entries is for the parent directory.
@@ -1592,7 +1599,25 @@ static int dsortf(struct ent **e1, struct ent **e2)
         }
         break;
     }
-    return strcmp(c1->name, c2->name);
+
+    ignorecase = c1->ignorecase;
+    if (ignorecase) {
+        result = strcasecmp(c1->name, c2->name);
+        if (result == 0) {
+            /*
+             * They're identical when treated case-insensitively, so
+             * pretend they weren't and let strcmp() put them in a
+             * deterministic order.  This means that 'ABC' and 'abc'
+             * will always appear in the same order, rather than
+             * unpredictably 'ABC abc' or 'abc ABC'.
+             */
+            ignorecase = 0;
+        }
+    }
+    if (! ignorecase) {
+        result = strcmp(c1->name, c2->name);
+    }
+    return result;
 }