]> granicus.if.org Git - apache/commitdiff
TOKEN_GROUP is nothing but an identity operator, it gateways the
authorAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 19:32:35 +0000 (19:32 +0000)
committerAndré Malo <nd@apache.org>
Wed, 27 Aug 2003 19:32:35 +0000 (19:32 +0000)
result of the enclosed expression. Since this expression will never
touched again during the tree-building stage, we can safely strip
TOKEN_GROUP from the tree and later evaluate the child directly.

The only side effect of this change is, that grouped strings on the
left side of EQ/NE/etc are now allowed (was invalid before), which
is acceptable IMHO (e.g. (foo bar baz) = zzzip)

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

modules/filters/mod_include.c

index f79c128cd9afcb9c5277a8c07a2b5da60528a7d7..2b1b3a3ada4007978d4ee27e8c23df4ee909f23a 100644 (file)
@@ -126,7 +126,6 @@ typedef enum {
     TOKEN_NE,
     TOKEN_RBRACE,
     TOKEN_LBRACE,
-    TOKEN_GROUP,
     TOKEN_GE,
     TOKEN_LE,
     TOKEN_GT,
@@ -336,7 +335,6 @@ static void debug_dump_tree(include_ctx_t *ctx, parse_node_t *root)
             continue;
 
         case TOKEN_NOT:
-        case TOKEN_GROUP:
         case TOKEN_RBRACE:
         case TOKEN_LBRACE:
             if (!current->dump_done) {
@@ -1213,8 +1211,7 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
                 break;
 
             case TOKEN_RE:
-            case TOKEN_RBRACE:
-            case TOKEN_GROUP:
+            case TOKEN_RBRACE: /* cannot happen */
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "Invalid expression \"%s\" in file %s",
                               expr, r->filename);
@@ -1333,7 +1330,23 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
                 return retval;
             }
 
-            TYPE_TOKEN(&current->token, TOKEN_GROUP);
+            /* empty groups return TRUE (backwards compat) */
+            if (!current->right) {
+                CREATE_NODE(ctx, current->right);
+                TYPE_TOKEN(&current->right->token, TOKEN_STRING);
+                current->right->token.value = "()";
+            }
+
+            current->right->parent = current->parent;
+            if (!current->parent) {
+                current = root = current->right;
+            }
+            else if (current->parent->left == current) {
+                current = current->parent->left = current->right;
+            }
+            else {
+                current = current->parent->right = current->right;
+            }
             break;
 
         case TOKEN_NOT:
@@ -1341,8 +1354,7 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             switch (current->token.type) {
             case TOKEN_STRING:
             case TOKEN_RE:
-            case TOKEN_RBRACE:
-            case TOKEN_GROUP:
+            case TOKEN_RBRACE: /* cannot happen */
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "Invalid expression \"%s\" in file %s",
                               expr, r->filename);
@@ -1357,9 +1369,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             new->parent = current;
             current = new;
             break;
-
-        default:
-            break;
         }
     }
 
@@ -1560,23 +1569,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             current = current->parent;
             break;
 
-        case TOKEN_GROUP:
-            if (current->right) {
-                if (!current->right->done) {
-                    current = current->right;
-                    continue;
-                }
-                current->value = current->right->value;
-            }
-            else {
-                current->value = 1;
-            }
-
-            DEBUG_DUMP_EVAL(ctx, current);
-            current->done = 1;
-            current = current->parent;
-            break;
-
         case TOKEN_LBRACE:
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "Unmatched '(' in \"%s\" in file %s",
@@ -1584,13 +1576,6 @@ static int parse_expr(include_ctx_t *ctx, const char *expr, int *was_error)
             *was_error = 1;
             return retval;
 
-        case TOKEN_RBRACE:
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                          "Unmatched ')' in \"%s\" in file %s",
-                          expr, r->filename);
-            *was_error = 1;
-            return retval;
-
         default:
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "bad token type (internal parser error)");