From: Stefan Fritsch Date: Sat, 30 Jan 2010 19:22:41 +0000 (+0000) Subject: Replace the Define !FOO syntax by a new UnDefine directive. X-Git-Tag: 2.3.6~536 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6856b147a78dafb92de9f19f36c6585e50685e4b;p=apache Replace the Define !FOO syntax by a new UnDefine directive. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@904853 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml index 79e47416c6..19f40a190a 100644 --- a/docs/manual/mod/core.xml +++ b/docs/manual/mod/core.xml @@ -596,8 +596,8 @@ which no other media type configuration could be found. Define -Define or undefine the existence of a variable -Define [!]parameter-name +Define the existence of a variable +Define parameter-name server config @@ -606,8 +606,6 @@ which no other media type configuration could be found.

This directive can be used to toggle the use of IfDefine sections without needing to alter -D arguments in any startup scripts.

-

If the parameter-name is prefixed with a !, the definition - of the argument is removed.

@@ -3400,6 +3398,21 @@ requests + +UnDefine +Undefine the existence of a variable +UnDefine parameter-name +server config + + +

Undoes the effect of a Define or + of passing a -D argument to httpd.

+

This directive can be used to toggle the use of IfDefine sections without needing to alter + -D arguments in any startup scripts.

+
+
+ UseCanonicalName Configures how the server determines its own name and diff --git a/server/core.c b/server/core.c index 8d2e20579e..b33c99e364 100644 --- a/server/core.c +++ b/server/core.c @@ -1102,39 +1102,36 @@ static const char *set_access_name(cmd_parms *cmd, void *dummy, static const char *set_define(cmd_parms *cmd, void *dummy, - const char *optarg) + const char *optarg) { - int remove = 0; - - const char *err = ap_check_cmd_context(cmd, - GLOBAL_ONLY); + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } - if (*optarg == '!') { - remove = 1; - optarg++; - } - - if (remove == 0 && !ap_exists_config_define(optarg)) { + if (!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; +} + +static const char *unset_define(cmd_parms *cmd, void *dummy, + const char *optarg) +{ + int i; + char **defines; + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + + defines = (char **)ap_server_config_defines->elts; + for (i = 0; i < ap_server_config_defines->nelts; i++) { + if (strcmp(defines[i], optarg) == 0) { + defines[i] = apr_array_pop(ap_server_config_defines); + break; } } @@ -3263,6 +3260,8 @@ AP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO, "Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"), AP_INIT_TAKE1("Define", set_define, NULL, RSRC_CONF, "Define the existance of a variable. Same as passing -D to the command line."), +AP_INIT_TAKE1("UnDefine", unset_define, NULL, RSRC_CONF, + "Undefine the existance of a variable. Undo a Define."), AP_INIT_RAW_ARGS("