]> granicus.if.org Git - apache/commitdiff
cleanup TOKEN_EQ, NE, LT & co tree generator:
authorAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 18:00:47 +0000 (18:00 +0000)
committerAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 18:00:47 +0000 (18:00 +0000)
- the left side of such an operator can *only* be a string
- get a rid of the while-loop and re-organize the code
  to better reflect what we're actually doing there

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101113 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_include.c

index 824b7936529f30e5d588e5778fb6a0eaf5aa9135..f79c128cd9afcb9c5277a8c07a2b5da60528a7d7 100644 (file)
@@ -1289,44 +1289,36 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
         case TOKEN_GT:
         case TOKEN_LE:
         case TOKEN_LT:
-            /* Percolate upwards */
-            while (current) {
-                switch (current->token.type) {
-                case TOKEN_STRING:
-                case TOKEN_RE:
-                case TOKEN_GROUP:
-                    current = current->parent;
+            if (current->token.type == TOKEN_STRING) {
+                current = current->parent;
+
+                if (!current) {
+                    new->left = root;
+                    root->parent = new;
+                    current = root = new;
                     continue;
+                }
 
+                switch (current->token.type) {
                 case TOKEN_LBRACE:
                 case TOKEN_AND:
                 case TOKEN_OR:
-                    break;
+                    new->left = current->right;
+                    new->left->parent = new;
+                    new->parent = current;
+                    current = current->right = new;
+                    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;
+                    break;
                 }
-                break;
             }
 
-            if (!current) {
-                new->left = root;
-                new->left->parent = new;
-                new->parent = NULL;
-                root = new;
-            }
-            else {
-                new->left = current->right;
-                new->left->parent = new;
-                current->right = new;
-                new->parent = current;
-            }
-            current = new;
-            break;
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "Invalid expression \"%s\" in file %s",
+                          expr, r->filename);
+            *was_error = 1;
+            return retval;
 
         case TOKEN_RBRACE:
             while (current && current->token.type != TOKEN_LBRACE) {