]> granicus.if.org Git - apache/commitdiff
Remove ap_expr_clone from the API (same day it was added:-)
authorNick Kew <niq@apache.org>
Mon, 31 Mar 2008 22:10:36 +0000 (22:10 +0000)
committerNick Kew <niq@apache.org>
Mon, 31 Mar 2008 22:10:36 +0000 (22:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@643175 13f79535-47bb-0310-9956-ffa450edef68

include/ap_expr.h
modules/filters/mod_filter.c
server/util_expr.c

index 2dcaf3935ee1713fbe6d6dbd3a6ca52f4b5dce14..11dac272a45b1ea81574cdcf7269379bb87975e3 100644 (file)
@@ -102,7 +102,9 @@ AP_DECLARE(int) ap_expr_eval(request_rec *r, ap_parse_node_t *root,
                              int *was_error, backref_t **reptr,
                              string_func_t string_func, opt_func_t eval_func);
 /**
- * Evaluate an expression
+ * Evaluate an expression.  This is functionally equivalent to
+ * ap_expr_parse followed by ap_expr_eval, but faster and more efficient
+ * when an expression only needs to be parsed once and discarded.
  * @param r The current request
  * @param expr The expression to parse
  * @param was_error On return, set to zero if parse successful, nonzero on error
@@ -141,19 +143,6 @@ AP_DECLARE(apr_status_t) ap_expr_init(apr_pool_t *pool);
  */
 AP_DECLARE(const char*) ap_expr_string(request_rec *r, const char *str);
 
-/**
- * Clone a parse tree.  This is required if you create a parse tree
- * using ap_expr_parse, and wish to re-use it many times in ap_expr_eval.
- * It is not required if you need to use it just once.
- * @param pool Pool
- * @param node The parse tree to clone
- * @param parent Parent node (for internal use when recursing - pass in NULL)
- * @return The cloned tree
- */
-AP_DECLARE(ap_parse_node_t*) ap_expr_clone_tree(apr_pool_t *pool,
-                                                ap_parse_node_t *node,
-                                                ap_parse_node_t *parent);
-
 #ifdef __cplusplus
 }
 #endif
index b1bdd0e40eee968d85617a4bff28e2406f437afb..4d6ee7f0e706afd577a869f573e70fd5a565decb 100644 (file)
@@ -141,14 +141,12 @@ static int filter_lookup(ap_filter_t *f, ap_filter_rec_t *filter)
     request_rec *r = f->r;
     harness_ctx *ctx = f->ctx;
     provider_ctx *pctx;
-    ap_parse_node_t *tree;
     mod_filter_ctx *rctx = ap_get_module_config(r->request_config,
                                                 &filter_module);
 
     /* Check registered providers in order */
     for (provider = filter->providers; provider; provider = provider->next) {
-        tree = ap_expr_clone_tree(r->pool, provider->expr, NULL);
-        match = ap_expr_eval(r, tree, &err, NULL, ap_expr_string, NULL);
+        match = ap_expr_eval(r, provider->expr, &err, NULL, ap_expr_string, NULL);
         if (err) {
             /* log error but accept match value ? */
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
index dedde033ebe281ee68f7564e9a92bb2718a5a5ff..fd1fd99424282101541002b9257ed4f6d1dff13b 100644 (file)
@@ -26,7 +26,6 @@
 #include "http_log.h"
 
 #include "ap_expr.h"
-#include <assert.h>
 #if 1
 /*
  * +-------------------------------------------------------+
@@ -670,9 +669,9 @@ AP_DECLARE(ap_parse_node_t*) ap_expr_parse(apr_pool_t* pool, const char *expr,
     return root;
 }
 
-AP_DECLARE(ap_parse_node_t*) ap_expr_clone_tree(apr_pool_t *pool,
-                                                ap_parse_node_t *pnode,
-                                               ap_parse_node_t *parent)
+static ap_parse_node_t *ap_expr_clone_tree(apr_pool_t *pool,
+                                           ap_parse_node_t *pnode,
+                                          ap_parse_node_t *parent)
 {
     ap_parse_node_t *ret;
     ret = apr_pmemdup(pool, pnode, sizeof(ap_parse_node_t));
@@ -687,9 +686,9 @@ AP_DECLARE(ap_parse_node_t*) ap_expr_clone_tree(apr_pool_t *pool,
 }
 
 #define PARSE_STRING(r,s) (string_func ? string_func((r),(s)) : (s))
-AP_DECLARE(int) ap_expr_eval(request_rec *r, ap_parse_node_t *root,
-                             int *was_error, backref_t **reptr,
-                             string_func_t string_func, opt_func_t eval_func)
+static int expr_eval(request_rec *r, ap_parse_node_t *root,
+                     int *was_error, backref_t **reptr,
+                     string_func_t string_func, opt_func_t eval_func)
 {
     ap_parse_node_t *current = root;
     const char *error = NULL;
@@ -868,6 +867,13 @@ AP_DECLARE(int) ap_expr_eval(request_rec *r, ap_parse_node_t *root,
 
     return (root ? root->value : 0);
 }
+AP_DECLARE(int) ap_expr_eval(request_rec *r, ap_parse_node_t *root,
+                             int *was_error, backref_t **reptr,
+                             string_func_t string_func, opt_func_t eval_func)
+{
+    ap_parse_node_t *clone = ap_expr_clone_tree(r->pool, root, NULL);
+    return expr_eval(r, clone, was_error, reptr, string_func, eval_func);
+}
 AP_DECLARE(int) ap_expr_evalstring(request_rec *r, const char *expr,
                                    int *was_error, backref_t **reptr,
                                    string_func_t string_func,
@@ -879,7 +885,7 @@ AP_DECLARE(int) ap_expr_evalstring(request_rec *r, const char *expr,
                       "Error parsing expression in %s", r->filename);   
         return 0;
     }
-    return ap_expr_eval(r, root, was_error, reptr, string_func, eval_func);
+    return expr_eval(r, root, was_error, reptr, string_func, eval_func);
 }
 
 
@@ -888,7 +894,7 @@ AP_DECLARE(const char*) ap_expr_string(request_rec *r, const char *str)
 {
     /* a default string evaluator: support headers and env */
     ap_regmatch_t match[3];
-    assert(isvar != NULL);
+    ap_assert(isvar != NULL);
     if (ap_regexec(isvar, str, 3, match, 0) == 0) {
         apr_table_t *table = NULL;
         int len = match[1].rm_eo-match[1].rm_so;