On Wed, Nov 27, 2002 at 11:29:36AM -0600, William A. Rowe, Jr. wrote:
> Francis, to the extent you don't want to reinvent the wheel;
>
> http://cvs.apache.org/viewcvs/apache-1.3/src/modules/standard/mod_autoindex.c
>
> should help you find that patch. Because 2.0 split before the feature
> was added, we 'missed' the new feature.
Cheers, the 1.3 code was the "heavy inspiration" for this patch.
Attached is a patch to introduce "IgnoreCase" as an allowable
"IndexOption", restoring a function from the late 1.3 series.
It's a fairly straightforward patch, but with one gotcha that
might be the reason why it hasn't been included prior to now:
this addition forces the 17th bit of the options to be used.
It works fine on my 32-bit-int system, but may have an impact
on a 16-bit-int system. The value was apr_int32_t already, but
was referred to as an int in some places. I think I've switched
them all (both) to apr_int32_t, although it'd be worth someone
with access to a 16-bit-int system letting their compiler verify
that.
The suggested docs patch is "strongly reminiscent" of the 1.3.27
docs. This is not a coincidence.
Built and tested against the released 2.0.43 code, the patches
apply (with a line offset) to the current CVS versions.
As usual, criticisms and suggested improvements welcome.
f
--
Francis Daly [EMAIL PROTECTED]
--- modules/generators/mod_autoindex.c Wed Nov 27 20:44:33 2002
+++ modules/generators/mod_autoindex.c Wed Nov 27 21:59:51 2002
@@ -110,6 +110,7 @@
#define FANCY_INDEXING 0x2000
#define TABLE_INDEXING 0x4000
#define IGNORE_CLIENT 0x8000
+#define SORT_NOCASE 0x10000
#define K_NOADJUST 0
#define K_ADJUST 1
@@ -353,7 +354,7 @@
opts_add = d_cfg->incremented_opts;
opts_remove = d_cfg->decremented_opts;
while (optstr[0]) {
- int option = 0;
+ apr_int32_t option = 0;
w = ap_getword_conf(cmd->pool, &optstr);
if ((*w == '+') || (*w == '-')) {
@@ -407,6 +408,9 @@
else if (!strcasecmp(w, "VersionSort")) {
option = VERSION_SORT;
}
+ else if (!strcasecmp(w, "IgnoreCase")) {
+ option = SORT_NOCASE;
+ }
else if (!strcasecmp(w, "None")) {
if (action != '\0') {
return "Cannot combine '+' or '-' with 'None' keyword";
@@ -727,6 +731,7 @@
int ascending, version_sort;
char key;
int isdir;
+ int ignore_case;
};
static char *find_item(request_rec *r, apr_array_header_t *list, int path_only)
@@ -1274,7 +1279,7 @@
}
static struct ent *make_autoindex_entry(const apr_finfo_t *dirent,
- int autoindex_opts,
+ apr_int32_t autoindex_opts,
autoindex_config_rec *d,
request_rec *r, char keyid,
char direction,
@@ -1337,6 +1342,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 & SORT_NOCASE);
if (autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) {
p->lm = rr->finfo.mtime;
@@ -1888,6 +1894,17 @@
return result;
}
break;
+ }
+ if (c1->ignore_case) {
+ if (c1->version_sort) {
+ result = apr_strnatcasecmp(c1->name, c2->name);
+ }
+ else {
+ result = strcasecmp(c1->name, c2->name);
+ }
+ if (result) {
+ return result;
+ }
}
if (c1->version_sort) {
return apr_strnatcmp(c1->name, c2->name);
--- manual/mod/mod_autoindex.xml Thu Nov 21 01:39:04 2002
+++ manual/mod/mod_autoindex.xml Wed Nov 27 23:57:13 2002
@@ -73,6 +73,10 @@
option below may be added to any request for the directory
resource.</p>
+ <p>After Apache 2.0.44, the sorting by file name
+ can be case-sensitive or not, according to <code><a
+ href="#indexoptions:ignorecase">IndexOptions IgnoreCase</a></code>
+
<ul>
<li><code>C=N</code> sorts the directory by file name</li>
@@ -592,6 +596,19 @@
loaded. If no value is given for the option, it defaults to
the standard width of the icons supplied with the Apache
software.</dd>
+
+ <dt><a name="indexoptions:ignorecase"
+ id="indexoptions:ignorecase">IgnoreCase</a> (<em>Apache
+ 2.0.44 and later</em>)</dt>
+
+ <dd> If this option is enabled, names are sorted in
+ case-insensitive manner. For instance, if the sort order is
+ ascending by name, and <code>IgnoreCase</code> is enabled, file
+ <code>Zeta</code> will be listed after file <code>alpha</code>
+ (Note: file <code>GAMMA</code> will always be listed before file
+ <code>gamma</code>). <b>This option only has an effect if <a
+ href="#indexoptions:fancyindexing"><code>FancyIndexing</code></a>
+ is also enabled.</b></dd>
<dt><a name="indexoptions:ignoreclient"
id="indexoptions:ignoreclient">IgnoreClient</a></dt>