Author: stefan2
Date: Tue Jul 29 17:46:51 2014
New Revision: 1614434
URL: http://svn.apache.org/r1614434
Log:
On the authzperf branch: Add support for variable number of
full segment pattern "**".
Since all the ground work has been done in previous commits,
this is a simple addition.
* BRANCH-README
(TODO, DONE): Another wildcard feature done.
* subversion/libsvn_repos/authz.c
(node_pattern_t): Variable length segments are just another
sub-segment pattern. However, add the
REPEAT flag we need during traversal.
(insert_path): Add "**" pattern.
(finalize_tree): One more sub-node to visit.
(lookup): Check another sub-node and do the repeated application
of "**" nodes.
Modified:
subversion/branches/authzperf/BRANCH-README
subversion/branches/authzperf/subversion/libsvn_repos/authz.c
Modified: subversion/branches/authzperf/BRANCH-README
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/BRANCH-README?rev=1614434&r1=1614433&r2=1614434&view=diff
==============================================================================
--- subversion/branches/authzperf/BRANCH-README (original)
+++ subversion/branches/authzperf/BRANCH-README Tue Jul 29 17:46:51 2014
@@ -9,7 +9,6 @@ TODO:
* implement an authz-specific constructor for the config parser
* implement precedence rules
-* add support for variable length full-segment wildcards ("/**/")
* add support for prefix segment patterns ("/foo*/")
* add support for suffix segment patterns ("/*foo/")
* add support for arbitrary patterns ("/foo*bar*baz/" etc.)
@@ -24,3 +23,4 @@ DONE:
* implement evaluation shortcuts
* parametrize in-memory representation constructor in the config parser
* add support for full-segment wildcards ("/*/")
+* add support for variable length full-segment wildcards ("/**/")
Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.c
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.c?rev=1614434&r1=1614433&r2=1614434&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.c Tue Jul 29
17:46:51 2014
@@ -295,6 +295,13 @@ typedef struct node_pattern_t
{
/* If not NULL, this represents the "*" follow-segment. */
struct node_t *any;
+
+ /* If not NULL, this represents the "**" follow-segment. */
+ struct node_t *any_var;
+
+ /* This node itself is a "**" segment and must therefore itself be added
+ * to the matching node list for the next level. */
+ svn_boolean_t repeat;
} node_pattern_t;
/* The pattern tree. All relevant path rules are being folded into this
@@ -492,6 +499,14 @@ insert_path(node_t *node,
sub_node = ensure_node(&node->pattern_sub_nodes->any, segment,
result_pool);
+ /* One or more full wildcard segments? */
+ else if (strcmp(segment, "**") == 0)
+ {
+ sub_node = ensure_node(&node->pattern_sub_nodes->any_var, segment,
+ result_pool);
+ ensure_pattern_sub_nodes(sub_node, result_pool)->repeat = TRUE;
+ }
+
/* More cases to be added here later.
* There will be no error condition to be checked for. */
}
@@ -629,6 +644,9 @@ finalize_tree(node_t *parent,
if (node->pattern_sub_nodes->any)
finalize_tree(node, access, node->pattern_sub_nodes->any,
scratch_pool);
+ if (node->pattern_sub_nodes->any_var)
+ finalize_tree(node, access, node->pattern_sub_nodes->any_var,
+ scratch_pool);
}
/* Add our min / max info to the parent's info.
@@ -911,6 +929,12 @@ lookup(lookup_state_t *state,
if (node->pattern_sub_nodes)
{
add_next_node(state, node->pattern_sub_nodes->any);
+ add_next_node(state, node->pattern_sub_nodes->any_var);
+
+ /* If the current node represents a "**" pattern, it matches
+ * to all levels. So, add it to the list for the NEXT level. */
+ if (node->pattern_sub_nodes->repeat)
+ add_next_node(state, node);
}
}