You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2010/01/30 20:22:42 UTC
svn commit: r904853 - in /httpd/httpd/trunk: docs/manual/mod/core.xml
server/core.c
Author: sf
Date: Sat Jan 30 19:22:41 2010
New Revision: 904853
URL: http://svn.apache.org/viewvc?rev=904853&view=rev
Log:
Replace the Define !FOO syntax by a new UnDefine directive.
Modified:
httpd/httpd/trunk/docs/manual/mod/core.xml
httpd/httpd/trunk/server/core.c
Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=904853&r1=904852&r2=904853&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/core.xml Sat Jan 30 19:22:41 2010
@@ -596,8 +596,8 @@
<directivesynopsis>
<name>Define</name>
-<description>Define or undefine the existence of a variable</description>
-<syntax>Define [!]<var>parameter-name</var></syntax>
+<description>Define the existence of a variable</description>
+<syntax>Define <var>parameter-name</var></syntax>
<contextlist><context>server config</context></contextlist>
<usage>
@@ -606,8 +606,6 @@
<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>
@@ -3401,6 +3399,21 @@
</directivesynopsis>
<directivesynopsis>
+<name>UnDefine</name>
+<description>Undefine the existence of a variable</description>
+<syntax>UnDefine <var>parameter-name</var></syntax>
+<contextlist><context>server config</context></contextlist>
+
+<usage>
+ <p>Undoes the effect of a <directive module="core">Define</directive> or
+ of passing a <code>-D</code> argument to <program>httpd</program>.</p>
+ <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>
+</usage>
+</directivesynopsis>
+
+<directivesynopsis>
<name>UseCanonicalName</name>
<description>Configures how the server determines its own name and
port</description>
Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=904853&r1=904852&r2=904853&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Sat Jan 30 19:22:41 2010
@@ -1102,39 +1102,36 @@
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 @@
"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("<If", ifsection, NULL, OR_ALL,
"Container for directives to be conditionally applied"),