]> granicus.if.org Git - apache/commitdiff
readability improvement. Handle the case of the current token being the
authorAndré Malo <nd@apache.org>
Mon, 25 Aug 2003 22:06:45 +0000 (22:06 +0000)
committerAndré Malo <nd@apache.org>
Mon, 25 Aug 2003 22:06:45 +0000 (22:06 +0000)
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

index 177a26bfc7fcd353c7930b3b67de9b165f3422ba..957a1c7ab8b5a088558f739c709e6fc9b1b77924 100644 (file)
@@ -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: