From c509a2b8ed7bd08f36542173a5155c71fb16b57d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Malo?= Date: Mon, 25 Aug 2003 22:06:45 +0000 Subject: [PATCH] readability improvement. Handle the case of the current token being the first parsed explicitly. There's probably also a minor performance improvement on invalid expressions ... ;-) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101102 13f79535-47bb-0310-9956-ffa450edef68 --- modules/filters/mod_include.c | 50 ++++++++++++----------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index 177a26bfc7..957a1c7ab8 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -1144,13 +1144,26 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) DEBUG_DUMP_UNMATCHED(ctx, was_unmatched); DEBUG_DUMP_TOKEN(ctx, &new->token); - switch (new->token.type) { - case TOKEN_STRING: - if (!current) { + if (!current) { + switch (new->token.type) { + case TOKEN_STRING: + case TOKEN_RE: + case TOKEN_NOT: + case TOKEN_LBRACE: root = current = new; - break; + continue; + + default: + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "Invalid expression \"%s\" in file %s", + expr, r->filename); + *was_error = 1; + return retval; } + } + switch (new->token.type) { + case TOKEN_STRING: switch (current->token.type) { case TOKEN_STRING: current->token.value = @@ -1176,11 +1189,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) break; case TOKEN_RE: - if (!current) { - root = current = new; - break; - } - switch (current->token.type) { case TOKEN_EQ: case TOKEN_NE: @@ -1204,13 +1212,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) case TOKEN_AND: case TOKEN_OR: - if (!current) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "Invalid expression \"%s\" in file %s", - expr, r->filename); - *was_error = 1; - return retval; - } /* Percolate upwards */ while (current) { switch (current->token.type) { @@ -1247,11 +1248,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) break; case TOKEN_NOT: - if (!current) { - root = current = new; - break; - } - switch (current->token.type) { case TOKEN_STRING: case TOKEN_RE: @@ -1277,13 +1273,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) case TOKEN_GT: case TOKEN_LE: case TOKEN_LT: - if (!current) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "Invalid expression \"%s\" in file %s", - expr, r->filename); - *was_error = 1; - return retval; - } /* Percolate upwards */ while (current) { switch (current->token.type) { @@ -1341,11 +1330,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error) break; case TOKEN_LBRACE: - if (!current) { - root = current = new; - break; - } - switch (current->token.type) { case TOKEN_STRING: case TOKEN_RE: -- 2.50.1