Index: mod_autoindex.c =================================================================== RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_autoindex.c,v retrieving revision 1.112 diff -u -3 -r1.112 mod_autoindex.c --- mod_autoindex.c 21 Nov 2002 23:53:21 -0000 1.112 +++ mod_autoindex.c 6 Jan 2003 05:40:37 -0000 @@ -94,22 +94,23 @@ * Handling configuration directives... */ -#define NO_OPTIONS 0x0001 /* Indexing options */ -#define ICONS_ARE_LINKS 0x0002 -#define SCAN_HTML_TITLES 0x0004 -#define SUPPRESS_ICON 0x0008 -#define SUPPRESS_LAST_MOD 0x0010 -#define SUPPRESS_SIZE 0x0020 -#define SUPPRESS_DESC 0x0040 -#define SUPPRESS_PREAMBLE 0x0080 -#define SUPPRESS_COLSORT 0x0100 -#define SUPPRESS_RULES 0x0200 -#define FOLDERS_FIRST 0x0400 -#define VERSION_SORT 0x0800 -#define TRACK_MODIFIED 0x1000 -#define FANCY_INDEXING 0x2000 -#define TABLE_INDEXING 0x4000 -#define IGNORE_CLIENT 0x8000 +#define NO_OPTIONS 0x00001 /* Indexing options */ +#define ICONS_ARE_LINKS 0x00002 +#define SCAN_HTML_TITLES 0x00004 +#define SUPPRESS_ICON 0x00008 +#define SUPPRESS_LAST_MOD 0x00010 +#define SUPPRESS_SIZE 0x00020 +#define SUPPRESS_DESC 0x00040 +#define SUPPRESS_PREAMBLE 0x00080 +#define SUPPRESS_COLSORT 0x00100 +#define SUPPRESS_RULES 0x00200 +#define FOLDERS_FIRST 0x00400 +#define VERSION_SORT 0x00800 +#define TRACK_MODIFIED 0x01000 +#define FANCY_INDEXING 0x02000 +#define TABLE_INDEXING 0x04000 +#define IGNORE_CLIENT 0x08000 +#define IGNORE_CASE 0x10000 #define K_NOADJUST 0 #define K_ADJUST 1 @@ -374,6 +375,9 @@ else if (!strcasecmp(w, "IconsAreLinks")) { option = ICONS_ARE_LINKS; } + else if (!strcasecmp(w, "IgnoreCase")) { + option = IGNORE_CASE; + } else if (!strcasecmp(w, "IgnoreClient")) { option = IGNORE_CLIENT; } @@ -724,7 +728,7 @@ apr_off_t size; apr_time_t lm; struct ent *next; - int ascending, version_sort; + int ascending, ignore_case, version_sort; char key; int isdir; }; @@ -1345,6 +1349,7 @@ p->key = apr_toupper(keyid); p->ascending = (apr_toupper(direction) == D_ASCENDING); p->version_sort = !!(autoindex_opts & VERSION_SORT); + p->ignore_case = !!(autoindex_opts & IGNORE_CASE); if (autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) { p->lm = rr->finfo.mtime; @@ -1835,6 +1840,7 @@ struct ent *c1; struct ent *c2; int result = 0; + int ignore_case; /* * First, see if either of the entries is for the parent directory. @@ -1897,12 +1903,32 @@ } break; } - if (c1->version_sort) { - return apr_strnatcmp(c1->name, c2->name); - } - else { - return strcmp(c1->name, c2->name); + + ignore_case = c1->ignore_case; + if (ignore_case) { + 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'. + */ + ignore_case = 0; + } } + + if (c1->version_sort && ignore_case) + return apr_strnatcasecmp (c1->name, c2->name); + + if (c1->version_sort) + return apr_strnatcmp(c1->name, c2->name); + + if (!result) + return strcmp (c1->name, c2->name); + + return result; }