diff --git a/doc/configuration.txt b/doc/configuration.txt index 017c0d11..66194973 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -75,8 +75,8 @@ Most options can be configured conditionally by using the following syntax ... nesting: match only when parent match } } - | { - ... else if + else { + ... the "else if" block } where is one of one of the following: diff --git a/src/configfile.c b/src/configfile.c index 747e14df..012e4bfa 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -654,12 +654,6 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer * } break; - case '|': - t->offset++; - tid = TK_OR; - buffer_copy_string(token, "|"); - break; - case '{': t->offset++; @@ -753,6 +747,8 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer * if (strcmp(token->ptr, "include") == 0) { tid = TK_INCLUDE; + } else if (strcmp(token->ptr, "else") == 0) { + tid = TK_ELSE; } else { tid = TK_LKEY; } @@ -775,9 +771,10 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer * if (tid) { *token_id = tid; #if 0 - log_error_write(srv, __FILE__, __LINE__, "sbsdsdb", + log_error_write(srv, __FILE__, __LINE__, "sbsdsdbdd", "file:", t->file, - "line:", t->line, "pos:", t->line_pos, token); + "line:", t->line, "pos:", t->line_pos, + token, token->used - 1, tid); #endif return 1; diff --git a/src/configparser.y b/src/configparser.y index 854527b5..57ede869 100644 --- a/src/configparser.y +++ b/src/configparser.y @@ -268,7 +268,7 @@ aelement(A) ::= STRING(B) ARRAY_ASSIGN expression(C). { eols ::= EOL. eols ::= . -condlines(A) ::= condlines(B) eols OR condline(C). { +condlines(A) ::= condlines(B) eols ELSE condline(C). { assert(B->context_ndx < C->context_ndx); C->prev = B; B->next = C; diff --git a/tests/condition.conf b/tests/condition.conf index 7e34e493..67eaeaf2 100644 --- a/tests/condition.conf +++ b/tests/condition.conf @@ -33,13 +33,13 @@ $HTTP["host"] == "www.example.org" { server.name = "www.example.org" url.redirect = ("^" => "/match_1") } -| $HTTP["host"] == "test1.example.org" { +else $HTTP["host"] == "test1.example.org" { server.document-root = "/tmp/lighttpd/servers/www.example.org/pages/" server.name = "test1.example.org" url.redirect = ("^" => "/match_2") } # comments -| $HTTP["host"] == "test2.example.org" { +else $HTTP["host"] == "test2.example.org" { server.document-root = "/tmp/lighttpd/servers/www.example.org/pages/" server.name = "test2.example.org" url.redirect = ("^" => "/match_3") @@ -47,7 +47,7 @@ $HTTP["host"] == "www.example.org" { # comments -| $HTTP["host"] == "test3.example.org" { +else $HTTP["host"] == "test3.example.org" { server.document-root = "/tmp/lighttpd/servers/www.example.org/pages/" server.name = "test3.example.org" url.redirect = ("^" => "/match_4")