dgaudet 98/02/02 11:46:55
Modified: src/main http_core.c
src/include http_core.h
Log:
Aha. This is the way to fix the options + / options - problems such as:
Options -indexes
<VirtualHost 127.0.0.1>
Options +indexes
</VirtualHost>
No longer do -'ves have priority over +'ves. We just record the last
change to each bit.
Revision Changes Path
1.155 +17 -6 apache-1.3/src/main/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -r1.154 -r1.155
--- http_core.c 1998/02/01 22:05:36 1.154
+++ http_core.c 1998/02/02 19:46:53 1.155
@@ -160,13 +160,21 @@
conf->d_components = new->d_components;
conf->r = new->r;
- if (!(new->opts & OPT_UNSET)) conf->opts = new->opts;
- if (new->opts_add) {
- conf->opts |= new->opts_add;
- conf->opts &= ~OPT_UNSET;
+ if (new->opts & OPT_UNSET) {
+ /* there was no explicit setting of new->opts, so we merge
+ * preserve the invariant (opts_add & opts_remove) == 0
+ */
+ conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
+ conf->opts_remove = (conf->opts_remove & ~new->opts_add) |
new->opts_remove;
+ conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
}
- if (new->opts_remove) {
- conf->opts &= ~(new->opts_remove | OPT_UNSET);
+ else {
+ /* otherwise we just copy, because an explicit opts setting
+ * overrides all earlier +/- modifiers
+ */
+ conf->opts = new->opts;
+ conf->opts_add = new->opts_add;
+ conf->opts_remove = new->opts_remove;
}
if (!(new->override & OR_UNSET)) conf->override = new->override;
@@ -801,12 +809,15 @@
else
return pstrcat (cmd->pool, "Illegal option ", w, NULL);
+ /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
if (action == '-') {
d->opts_remove |= opt;
+ d->opts_add &= ~opt;
d->opts &= ~opt;
}
else if (action == '+') {
d->opts_add |= opt;
+ d->opts_remove &= ~opt;
d->opts |= opt;
}
else {
1.35 +7 -0 apache-1.3/src/include/http_core.h
Index: http_core.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/http_core.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- http_core.h 1998/02/01 22:05:34 1.34
+++ http_core.h 1998/02/02 19:46:55 1.35
@@ -145,6 +145,13 @@
/* the number of slashes in d */
unsigned d_components;
+ /* If (opts & OPT_UNSET) then no absolute assignment to options has
+ * been made.
+ * invariant: (opts_add & opts_remove) == 0
+ * Which said another way means that the last relative (options + or -)
+ * assignment made to each bit is recorded in exactly one of opts_add
+ * or opts_remove.
+ */
allow_options_t opts;
allow_options_t opts_add;
allow_options_t opts_remove;