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 Tue, 26 Aug 2003 17:20:16 GMT
nd          2003/08/26 10:20:16

  Modified:    modules/filters mod_include.c
  Log:
  improve debugging output
  
  Revision  Changes    Path
  1.273     +50 -44    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.272
  retrieving revision 1.273
  diff -u -r1.272 -r1.273
  --- mod_include.c	26 Aug 2003 00:32:03 -0000	1.272
  +++ mod_include.c	26 Aug 2003 17:20:16 -0000	1.273
  @@ -407,6 +407,43 @@
       }                                                                         \
   } while(0)
   
  +#define DEBUG_DUMP_EVAL(ctx, node) do {                                       \
  +    char c = '"';                                                             \
  +    switch ((node)->token.type) {                                             \
  +    case TOKEN_STRING:                                                        \
  +        debug_printf((ctx), "     Evaluate: %s (%s) -> %c\n", (node)->token.s,\
  +                     (node)->token.value, ((node)->value) ? '1':'0');         \
  +        break;                                                                \
  +    case TOKEN_AND:                                                           \
  +    case TOKEN_OR:                                                            \
  +        debug_printf((ctx), "     Evaluate: %s (Left: %s; Right: %s) -> %c\n",\
  +                     (node)->token.s,                                         \
  +                     (((node)->left->done) ? ((node)->left->value ?"1":"0")
  \
  +                                          : "short circuited"),               \
  +                     (((node)->right->done) ? ((node)->right->value?"1":"0")
 \
  +                                          : "short circuited"),               \
  +                     (node)->value ? '1' : '0');                              \
  +        break;                                                                \
  +    case TOKEN_EQ:                                                            \
  +    case TOKEN_NE:                                                            \
  +    case TOKEN_GT:                                                            \
  +    case TOKEN_GE:                                                            \
  +    case TOKEN_LT:                                                            \
  +    case TOKEN_LE:                                                            \
  +        if ((node)->right->token.type == TOKEN_RE) c = '/';                   \
  +        debug_printf((ctx), "     Compare:  %s (\"%s\" with %c%s%c) -> %c\n", \
  +                     (node)->token.s,                                         \
  +                     (node)->left->token.value,                               \
  +                     c, (node)->right->token.value, c,                        \
  +                     (node)->value ? '1' : '0');                              \
  +        break;                                                                \
  +    default:                                                                  \
  +        debug_printf((ctx), "     Evaluate: %s -> %c\n", (node)->token.s,     \
  +                     (node)->value ? '1' : '0');                              \
  +        break;                                                                \
  +    }                                                                         \
  +} while(0)
  +
   #define DEBUG_DUMP_UNMATCHED(ctx, unmatched) do {                        \
       if (unmatched) {                                                     \
           DEBUG_PRINTF(((ctx), "     Unmatched %c\n", (char)(unmatched))); \
  @@ -432,6 +469,7 @@
   #define DEBUG_INIT(ctx, f, bb)
   #define DEBUG_PRINTF(arg)
   #define DEBUG_DUMP_TOKEN(ctx, token)
  +#define DEBUG_DUMP_EVAL(ctx, node)
   #define DEBUG_DUMP_UNMATCHED(ctx, unmatched)
   #define DEBUG_DUMP_COND(ctx, text)
   #define DEBUG_DUMP_TREE(ctx, root)
  @@ -1133,7 +1171,10 @@
   
       /* Create Parse Tree */
       while (1) {
  -        DEBUG_DUMP_TREE(ctx, root);
  +        /* uncomment this to see how the tree a built:
  +         *
  +         * DEBUG_DUMP_TREE(ctx, root);
  +         */
           CREATE_NODE(ctx, new);
   
           was_unmatched = get_ptoken(ctx->dpool, &parse, &new->token);
  @@ -1331,18 +1372,19 @@
           }
       }
   
  +    DEBUG_DUMP_TREE(ctx, root);
  +
       /* Evaluate Parse Tree */
       current = root;
       while (current) {
           switch (current->token.type) {
           case TOKEN_STRING:
  -            DEBUG_PRINTF((ctx, "     Evaluate %s\n", current->token.s));
  -
               buffer = ap_ssi_parse_string(ctx, current->token.value, NULL, 0,
                                            SSI_EXPAND_DROP_NAME);
   
               current->token.value = buffer;
               current->value = !!*current->token.value;
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
  @@ -1356,8 +1398,6 @@
   
           case TOKEN_AND:
           case TOKEN_OR:
  -            DEBUG_PRINTF((ctx, "     Evaluate %s\n", current->token.s));
  -
               if (!current->left || !current->right) {
                   ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                                 "Invalid expression \"%s\" in file %s",
  @@ -1388,10 +1428,6 @@
               if (!current->left->done && !regex &&
                   ((current->token.type == TOKEN_AND && !current->right->value)
||
                   (current->token.type == TOKEN_OR && current->right->value)))
{
  -                DEBUG_PRINTF((ctx, "     Left: short circuited\n"));
  -                DEBUG_PRINTF((ctx, "     Right: %c\n", current->right->value
  -                                                                  ? '1' : '0'));
  -
                   current->value = current->right->value;
               }
               else {
  @@ -1414,11 +1450,6 @@
                       }
                   }
   
  -                DEBUG_PRINTF((ctx, "     Left: %c\n", current->left->value
  -                                                                  ? '1' : '0'));
  -                DEBUG_PRINTF((ctx, "     Right: %c\n", current->right->value
  -                                                                  ? '1' : '0'));
  -
                   if (current->token.type == TOKEN_AND) {
                       current->value = current->left->value &&
                                        current->right->value;
  @@ -1429,16 +1460,13 @@
                   }
               }
   
  -            DEBUG_PRINTF((ctx, "     Returning %c\n", current->value
  -                                                                  ? '1' : '0'));
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
   
           case TOKEN_EQ:
           case TOKEN_NE:
  -            DEBUG_PRINTF((ctx, "     Evaluate %s\n", current->token.s));
  -
               if (!current->left || !current->right ||
                   current->left->token.type != TOKEN_STRING ||
                   (current->right->token.type != TOKEN_STRING &&
  @@ -1459,19 +1487,11 @@
               current->right->token.value = buffer;
   
               if (current->right->token.type == TOKEN_RE) {
  -                DEBUG_PRINTF((ctx, "     Re Compare (%s) with /%s/\n",
  -                              current->left->token.value,
  -                              current->right->token.value));
  -
                   current->value = re_check(ctx, current->left->token.value,
                                             current->right->token.value);
                   --regex;
               }
               else {
  -                DEBUG_PRINTF((ctx, "     Compare (%s) with (%s)\n",
  -                              current->left->token.value,
  -                              current->right->token.value));
  -
                   current->value = !strcmp(current->left->token.value,
                                            current->right->token.value);
               }
  @@ -1480,9 +1500,7 @@
                   current->value = !current->value;
               }
   
  -            DEBUG_PRINTF((ctx, "     Returning %c\n", current->value
  -                                                                  ? '1' : '0'));
  -
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
  @@ -1491,8 +1509,6 @@
           case TOKEN_GT:
           case TOKEN_LE:
           case TOKEN_LT:
  -            DEBUG_PRINTF((ctx, "     Evaluate %s\n", current->token.s));
  -
               if (!current->left || !current->right ||
                   current->left->token.type != TOKEN_STRING ||
                   current->right->token.type != TOKEN_STRING) {
  @@ -1510,10 +1526,6 @@
                                            0, SSI_EXPAND_DROP_NAME);
               current->right->token.value = buffer;
   
  -            DEBUG_PRINTF((ctx, "     Compare (%s) with (%s)\n",
  -                          current->left->token.value,
  -                          current->right->token.value));
  -
               current->value = strcmp(current->left->token.value,
                                       current->right->token.value);
   
  @@ -1533,9 +1545,7 @@
                   current->value = 0;     /* Don't return -1 if unknown token */
               }
   
  -            DEBUG_PRINTF((ctx, "     Returning %c\n", current->value
  -                                                                  ? '1' : '0'));
  -
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
  @@ -1552,9 +1562,7 @@
                   current->value = 0;
               }
   
  -            DEBUG_PRINTF((ctx, "     Evaluate %s: %c\n", current->token.s,
  -                                                   current->value ? '1' : '0'));
  -
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
  @@ -1571,9 +1579,7 @@
                   current->value = 1;
               }
   
  -            DEBUG_PRINTF((ctx, "     Evaluate %s: %c\n", current->token.s,
  -                                                   current->value ? '1' : '0'));
  -
  +            DEBUG_DUMP_EVAL(ctx, current);
               current->done = 1;
               current = current->parent;
               break;
  
  
  

Mime
View raw message