Changes with Apache 2.3.6
+ *) Allow the Define directive to undefine a variable by prefixing the
+ argument with a '!'. PR 35350. [Stefan Fritsch]
+
*) Make ap_pregsub(), used by AliasMatch and friends, use the same syntax
for regex backreferences as mod_rewrite and mod_include: Remove the use
of '&' as an alias for '$0' and allow to escape any character with a
<directivesynopsis>
<name>Define</name>
-<description>Define the existence of a variable</description>
-<syntax>Define <var>parameter-name</var></syntax>
+<description>Define or undefine the existence of a variable</description>
+<syntax>Define [!]<var>parameter-name</var></syntax>
<contextlist><context>server config</context></contextlist>
<usage>
<p>This directive can be used to toggle the use of <directive module="core"
type="section">IfDefine</directive> sections without needing to alter
<code>-D</code> arguments in any startup scripts.</p>
+ <p>If the parameter-name is prefixed with a <code>!</code>, the definition
+ of the argument is removed.</p>
</usage>
</directivesynopsis>
static const char *set_define(cmd_parms *cmd, void *dummy,
const char *optarg)
{
- char **newv;
+ int remove = 0;
const char *err = ap_check_cmd_context(cmd,
GLOBAL_ONLY);
return err;
}
- newv = (char **)apr_array_push(ap_server_config_defines);
- *newv = apr_pstrdup(cmd->pool, optarg);
+ if (*optarg == '!') {
+ remove = 1;
+ optarg++;
+ }
+
+ if (remove == 0 && !ap_exists_config_define(optarg)) {
+ char **newv = (char **)apr_array_push(ap_server_config_defines);
+ *newv = apr_pstrdup(cmd->pool, optarg);
+ }
+ else if (remove == 1) {
+ int i;
+ char **defines = (char **)ap_server_config_defines->elts;
+ for (i = 0; i < ap_server_config_defines->nelts; i++) {
+ if (strcmp(defines[i], optarg) == 0) {
+ if (i == ap_server_config_defines->nelts - 1) {
+ apr_array_pop(ap_server_config_defines);
+ break;
+ }
+ else {
+ defines[i] = apr_array_pop(ap_server_config_defines);
+ break;
+ }
+ }
+ }
+ }
return NULL;
}