httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/filters mod_include.c
Date Thu, 28 Aug 2003 01:13:12 GMT
nd          2003/08/27 18:13:12

  Modified:    modules/filters mod_include.c
  Log:
  cleanup the TOKEN_AND/OR tree generation code.
  - check more exactly whether the previous token is correct
  - flip the tree from left-weighted to right-weighted, which is
    more natural and more efficient, since we don't need to loop
    up to the root, but just until the next and/or token.
  - that way, flip the short circuit evaluation again to cut
    the right side now if possible...
  
  Revision  Changes    Path
  1.281     +49 -45    httpd-2.0/modules/filters/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
  retrieving revision 1.280
  retrieving revision 1.281
  diff -u -r1.280 -r1.281
  --- mod_include.c	27 Aug 2003 23:09:51 -0000	1.280
  +++ mod_include.c	28 Aug 2003 01:13:11 -0000	1.281
  @@ -1239,39 +1239,43 @@
   
           case TOKEN_AND:
           case TOKEN_OR:
  -            /* Percolate upwards */
  -            while (current) {
  -                switch (current->token.type) {
  -                case TOKEN_LBRACE:
  -                    break;
  +            switch (current->token.type) {
  +            case TOKEN_STRING:
  +            case TOKEN_RE:
  +            case TOKEN_GROUP:
  +                current = current->parent;
   
  -                case TOKEN_RBRACE:
  -                    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, error, expr,
  -                                  r->filename);
  -                    *was_error = 1;
  -                    return 0;
  +                while (current) {
  +                    switch (current->token.type) {
  +                    case TOKEN_AND:
  +                    case TOKEN_OR:
  +                    case TOKEN_LBRACE:
  +                        break;
   
  -                default:
  -                    current = current->parent;
  -                    continue;
  +                    default:
  +                        current = current->parent;
  +                        continue;
  +                    }
  +                    break;
                   }
  -                break;
  -            }
   
  -            if (!current) {
  -                new->left = root;
  -                new->left->parent = new;
  -                new->parent = NULL;
  -                root = new;
  -            }
  -            else {
  +                if (!current) {
  +                    new->left = root;
  +                    root->parent = new;
  +                    current = root = new;
  +                    continue;
  +                }
  +            
                   new->left = current->right;
                   new->left->parent = new;
  -                current->right = new;
                   new->parent = current;
  +                current = current->right = new;
  +                continue;
  +
  +            default:
  +                break;
               }
  -            current = new;
  -            continue;
  +            break;
   
           case TOKEN_EQ:
           case TOKEN_NE:
  @@ -1368,43 +1372,43 @@
                   return 0;
               }
   
  -            if (!current->right->done) {
  -                switch (current->right->token.type) {
  +            if (!current->left->done) {
  +                switch (current->left->token.type) {
                   case TOKEN_STRING:
  -                    current->right->token.value =
  -                        ap_ssi_parse_string(ctx, current->right->token.value,
  +                    current->left->token.value =
  +                        ap_ssi_parse_string(ctx, current->left->token.value,
                                               NULL, 0, SSI_EXPAND_DROP_NAME);
  -                    current->right->value = !!*current->right->token.value;
  -                    DEBUG_DUMP_EVAL(ctx, current->right);
  -                    current->right->done = 1;
  +                    current->left->value = !!*current->left->token.value;
  +                    DEBUG_DUMP_EVAL(ctx, current->left);
  +                    current->left->done = 1;
                       break;
   
                   default:
  -                    current = current->right;
  +                    current = current->left;
                       continue;
                   }
               }
   
               /* short circuit evaluation */
  -            if (!current->left->done && !regex &&
  -                ((current->token.type == TOKEN_AND && !current->right->value)
||
  -                (current->token.type == TOKEN_OR && current->right->value)))
{
  -                current->value = current->right->value;
  +            if (!current->right->done && !regex &&
  +                ((current->token.type == TOKEN_AND && !current->left->value)
||
  +                (current->token.type == TOKEN_OR && current->left->value)))
{
  +                current->value = current->left->value;
               }
               else {
  -                if (!current->left->done) {
  -                    switch (current->left->token.type) {
  +                if (!current->right->done) {
  +                    switch (current->right->token.type) {
                       case TOKEN_STRING:
  -                        current->left->token.value =
  -                            ap_ssi_parse_string(ctx, current->left->token.value,
  +                        current->right->token.value =
  +                            ap_ssi_parse_string(ctx,current->right->token.value,
                                                   NULL, 0, SSI_EXPAND_DROP_NAME);
  -                        current->left->value = !!*current->left->token.value;
  -                        DEBUG_DUMP_EVAL(ctx, current->left);
  -                        current->left->done = 1;
  +                        current->right->value = !!*current->right->token.value;
  +                        DEBUG_DUMP_EVAL(ctx, current->right);
  +                        current->right->done = 1;
                           break;
   
                       default:
  -                        current = current->left;
  +                        current = current->right;
                           continue;
                       }
                   }
  
  
  

Mime
View raw message