From: Ken Coar Date: Wed, 6 Feb 2002 15:53:37 +0000 (+0000) Subject: Add IgnoreCase keyword for case-insensitve directory listing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc19c1086393871a37e4a207e7d0bb2169808ff5;p=thirdparty%2Fapache%2Fhttpd.git Add IgnoreCase keyword for case-insensitve directory listing git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@93290 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index f72b92965b1..83705c2ed14 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -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 ] + *) 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. diff --git a/src/modules/standard/mod_autoindex.c b/src/modules/standard/mod_autoindex.c index 607b5280f02..8c25dfcb5e8 100644 --- a/src/modules/standard/mod_autoindex.c +++ b/src/modules/standard/mod_autoindex.c @@ -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; }