summaryrefslogtreecommitdiff
path: root/src/configparser.y
diff options
context:
space:
mode:
authorJan Kneschke <jan@kneschke.de>2005-08-08 16:15:57 +0000
committerJan Kneschke <jan@kneschke.de>2005-08-08 16:15:57 +0000
commit6b85d74c2b9aad85c15d827fe5172934ad2c4332 (patch)
treeeb0718e849bbfacf01c84ed9b251c3d06ddea336 /src/configparser.y
parentb663fa76bdd6e2113b01a1b9214a441f1cdaa1ec (diff)
downloadlighttpd-git-6b85d74c2b9aad85c15d827fe5172934ad2c4332.tar.gz
fixed config eval (merged [315])
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@522 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/configparser.y')
-rw-r--r--src/configparser.y24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/configparser.y b/src/configparser.y
index 08f496ba..854527b5 100644
--- a/src/configparser.y
+++ b/src/configparser.y
@@ -29,7 +29,7 @@ static data_config *configparser_pop(config_t *ctx) {
return old;
}
-data_unset *configparser_get_variable(config_t *ctx, buffer *key) {
+static const data_unset *configparser_get_variable(config_t *ctx, buffer *key) {
data_unset *ds, *result;
data_config *dc;
@@ -40,6 +40,7 @@ data_unset *configparser_get_variable(config_t *ctx, buffer *key) {
for (dc = ctx->current; dc && !result; dc = dc->parent) {
#if 0
fprintf(stderr, "get var on block: %s\n", dc->key->ptr);
+ array_print(dc->value, 0);
#endif
ds = array_get_element(dc->value, key->ptr);
if (NULL != ds) {
@@ -148,21 +149,23 @@ varline ::= key(A) ASSIGN expression(B). {
varline ::= key(A) APPEND expression(B). {
array *vars = ctx->current->value;
+ const data_unset *var;
data_unset *du;
- if (NULL == (du = configparser_get_variable(ctx, A))) {
- fprintf(stderr, "Undefined config variable in conditional 1 %s: %s\n",
- ctx->current->key->ptr, A->ptr);
- ctx->ok = 0;
- } else if (NULL != (du = array_get_element(vars, A->ptr))) {
+ if (NULL != (du = array_get_element(vars, A->ptr))) {
/* exists in current block */
du = configparser_merge_data(ctx, du, B);
buffer_copy_string_buffer(du->key, A);
array_replace(vars, du);
- } else {
+ } else if (NULL != (var = configparser_get_variable(ctx, A))) {
+ du = var->copy(var);
du = configparser_merge_data(ctx, du->copy(du), B);
buffer_copy_string_buffer(du->key, A);
array_insert_unique(ctx->current->value, du);
+ } else {
+ fprintf(stderr, "Undefined config variable in conditional 1 %s: %s\n",
+ ctx->current->key->ptr, A->ptr);
+ ctx->ok = 0;
}
buffer_free(A);
A = NULL;
@@ -194,8 +197,11 @@ expression(A) ::= value(B). {
}
value(A) ::= key(B). {
- A = configparser_get_variable(ctx, B);
- if (!A) {
+ const data_unset *var = configparser_get_variable(ctx, B);
+ if (var) {
+ A = var->copy(var);
+ }
+ else {
/* make a dummy so it won't crash */
A = (data_unset *)data_string_init();
}