httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r643175 - in /httpd/httpd/trunk: include/ap_expr.h modules/filters/mod_filter.c server/util_expr.c
Date Mon, 31 Mar 2008 22:10:38 GMT
Author: niq
Date: Mon Mar 31 15:10:36 2008
New Revision: 643175

URL: http://svn.apache.org/viewvc?rev=643175&view=rev
Log:
Remove ap_expr_clone from the API (same day it was added:-)

Modified:
    httpd/httpd/trunk/include/ap_expr.h
    httpd/httpd/trunk/modules/filters/mod_filter.c
    httpd/httpd/trunk/server/util_expr.c

Modified: httpd/httpd/trunk/include/ap_expr.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_expr.h?rev=643175&r1=643174&r2=643175&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_expr.h (original)
+++ httpd/httpd/trunk/include/ap_expr.h Mon Mar 31 15:10:36 2008
@@ -102,7 +102,9 @@
                              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
@@ -140,19 +142,6 @@
  * @return The evaluated string
  */
 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
 }

Modified: httpd/httpd/trunk/modules/filters/mod_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_filter.c?rev=643175&r1=643174&r2=643175&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_filter.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_filter.c Mon Mar 31 15:10:36 2008
@@ -141,14 +141,12 @@
     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,

Modified: httpd/httpd/trunk/server/util_expr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr.c?rev=643175&r1=643174&r2=643175&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr.c (original)
+++ httpd/httpd/trunk/server/util_expr.c Mon Mar 31 15:10:36 2008
@@ -26,7 +26,6 @@
 #include "http_log.h"
 
 #include "ap_expr.h"
-#include <assert.h>
 #if 1
 /*
  * +-------------------------------------------------------+
@@ -670,9 +669,9 @@
     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 @@
 }
 
 #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 @@
 
     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 @@
                       "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 @@
 {
     /* 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;



Mime
View raw message