Author: brane
Date: Wed Jul 30 12:11:14 2014
New Revision: 1614625
URL: http://svn.apache.org/r1614625
Log:
On the authzperf branch: Simplify the constructor semantics, since the authz
parser will not need all the extra bells and whistles. We can still add them
at a later date if we happen to actually need them.
* subversion/include/private/svn_config_private.h
(svn_config__constructor_create): Remove parameters expand_parsed_values,
section_names_case_sensitive and option_names_case_sensitive.
Update the docstring.
(svn_config__default_add_value_fn): Move prototype from here ...
* subversion/libsvn_subr/config_impl.h
(svn_config__default_add_value_fn): ... to here.
* subversion/libsvn_subr/config.c
(svn_config__default_add_value_fn): Move the implementation here
from config_file.c.
(svn_config_parse): Update call to svn_config__parse_stream.
* subversion/libsvn_subr/config_file.c
(svn_config__constructor_t): Remove members expand_values,
ci_section_names, ci_option_names, defaults, options and order.
(svn_config__constructor_create): Update implementation.
(open_section, close_section, add_value): Make these simple wrappers
around the constructor callbacks, and handle loop termination.
(parse_value): Update call to add_value.
(svn_config__parse_file): Update call to svn_config__parse_stream.
(svn_config__default_add_value_fn): Remove implementation.
(svn_config__parse_stream): Update calls to open_section and close_section.
Modified:
subversion/branches/authzperf/subversion/include/private/svn_config_private.h
subversion/branches/authzperf/subversion/libsvn_subr/config.c
subversion/branches/authzperf/subversion/libsvn_subr/config_file.c
subversion/branches/authzperf/subversion/libsvn_subr/config_impl.h
Modified:
subversion/branches/authzperf/subversion/include/private/svn_config_private.h
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/include/private/svn_config_private.h?rev=1614625&r1=1614624&r2=1614625&view=diff
==============================================================================
---
subversion/branches/authzperf/subversion/include/private/svn_config_private.h
(original)
+++
subversion/branches/authzperf/subversion/include/private/svn_config_private.h
Wed Jul 30 12:11:14 2014
@@ -77,34 +77,17 @@ typedef svn_error_t *(*svn_config__add_v
/*
* Create a new constuctor allocated from RESULT_POOL.
* Any of the callback functions may be NULL.
- * SECTION_NAMES_CASE_SENSITIVE and OPTION_NAMES_CASE_SENSITIVE
- * are ignored unless EXPAND_PARSED_VALUES is true, in which
- * case the parser behaviour changes as follows:
- * - the "DEFAULT" section is never reported to the constructor;
- * - values reported to ADD_VALUE_CALLBACK are always fully expanded;
- * - if a section is re-opened, the value expansion for this section
- * does *not* consider the previous contents of the section but
- * only the current set of values, along with whatever is set in
- * the "DEFAULT" section;
- * - changes to the "DEFAULT" section that appear after a section
- * has been parsed do not affect value expansion for that section.
+ * The constructor implementation is responsible for implementing any
+ * case-insensitivity, value expansion, or other features on top of
+ * the basic parser.
*/
svn_config__constructor_t *
svn_config__constructor_create(
- svn_boolean_t expand_parsed_values,
- svn_boolean_t section_names_case_sensitive,
- svn_boolean_t option_names_case_sensitive,
svn_config__open_section_fn open_section_callback,
svn_config__close_section_fn close_section_callback,
svn_config__add_value_fn add_value_callback,
apr_pool_t *result_pool);
-
-/* The default add-value callback, used by the default config parser. */
-svn_error_t *svn_config__default_add_value_fn(
- void *baton, const char *section,
- const char *option, const char *value);
-
/*
* Parse the configuration from STREAM, using CONSTRUCTOR to build the
* in-memory representation of the parsed configuration.
Modified: subversion/branches/authzperf/subversion/libsvn_subr/config.c
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/config.c?rev=1614625&r1=1614624&r2=1614625&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/config.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/config.c Wed Jul 30
12:11:14 2014
@@ -140,6 +140,14 @@ svn_config_read3(svn_config_t **cfgp, co
}
svn_error_t *
+svn_config__default_add_value_fn(void *baton, const char *section,
+ const char *option, const char *value)
+{
+ svn_config_set((svn_config_t *)baton, section, option, value);
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_config_parse(svn_config_t **cfgp, svn_stream_t *stream,
svn_boolean_t section_names_case_sensitive,
svn_boolean_t option_names_case_sensitive,
@@ -157,7 +165,7 @@ svn_config_parse(svn_config_t **cfgp, sv
if (err == SVN_NO_ERROR)
err = svn_config__parse_stream(stream,
svn_config__constructor_create(
- FALSE, FALSE, FALSE, NULL, NULL,
+ NULL, NULL,
svn_config__default_add_value_fn,
scratch_pool),
cfg, scratch_pool);
Modified: subversion/branches/authzperf/subversion/libsvn_subr/config_file.c
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/config_file.c?rev=1614625&r1=1614624&r2=1614625&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/config_file.c
(original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/config_file.c Wed Jul
30 12:11:14 2014
@@ -87,107 +87,103 @@ typedef struct parse_context_t
/* Config representation constructor */
struct svn_config__constructor_t
{
- /* Constructor properties; see docs for svn_config__constructor_create. */
- svn_boolean_t expand_values;
- svn_boolean_t ci_section_names;
- svn_boolean_t ci_option_names;
-
/* Constructor callbacks; see docs for svn_config__constructor_create. */
svn_config__open_section_fn open_section;
svn_config__close_section_fn close_section;
svn_config__add_value_fn add_value;
-
- /* The following members are used only when value expansion is enabled. */
- apr_hash_t *defaults; /* Contents of the "DEFAULT" section */
- apr_hash_t *options; /* Options that are currently being parsed */
- apr_array_header_t *order; /* The order of the keys in OPTIONS */
};
svn_config__constructor_t *
svn_config__constructor_create(
- svn_boolean_t expand_parsed_values,
- svn_boolean_t section_names_case_sensitive,
- svn_boolean_t option_names_case_sensitive,
svn_config__open_section_fn open_section_callback,
svn_config__close_section_fn close_section_callback,
svn_config__add_value_fn add_value_callback,
apr_pool_t *result_pool)
{
svn_config__constructor_t *ctor = apr_palloc(result_pool, sizeof(*ctor));
- ctor->expand_values = expand_parsed_values;
- ctor->ci_section_names = section_names_case_sensitive;
- ctor->ci_option_names = option_names_case_sensitive;
ctor->open_section = open_section_callback;
ctor->close_section = close_section_callback;
ctor->add_value = add_value_callback;
-
- if (expand_parsed_values)
- {
- ctor->defaults = svn_hash__make(result_pool);
- ctor->options = svn_hash__make(result_pool);
- ctor->order = apr_array_make(result_pool, 0, sizeof(const char*));
- }
- else
- {
- ctor->defaults = NULL;
- ctor->options = NULL;
- ctor->order = NULL;
- }
return ctor;
}
/* Called after we've parsed a section name and before we start
parsing any options within that section. */
-static svn_error_t *
-open_section(parse_context_t *ctx)
+static APR_INLINE svn_error_t *
+open_section(parse_context_t *ctx, svn_boolean_t *stop)
{
- svn_error_t *err = SVN_NO_ERROR;
if (ctx->constructor->open_section)
- err = ctx->constructor->open_section(
- ctx->constructor_baton, ctx->section->data);
- if (!err)
- ctx->in_section = TRUE;
- return err;
+ {
+ svn_error_t *err = ctx->constructor->open_section(
+ ctx->constructor_baton, ctx->section->data);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
+ {
+ *stop = TRUE;
+ svn_error_clear(err);
+ return SVN_NO_ERROR;
+ }
+ else
+ return svn_error_trace(err);
+ }
+ }
+
+ *stop = FALSE;
+ ctx->in_section = TRUE;
+ return SVN_NO_ERROR;
}
/* Called after we've parsed all options within a section and before
we start parsing the next section. */
-static svn_error_t *
-close_section(parse_context_t *ctx)
+static APR_INLINE svn_error_t *
+close_section(parse_context_t *ctx, svn_boolean_t *stop)
{
- if (ctx->constructor->expand_values
- && ctx->constructor->add_value)
+ ctx->in_section = FALSE;
+ if (ctx->constructor->close_section)
{
- /* TODO: Implement logic for value expansion. */
- *(volatile long*)0 = 0xdeadbeef;
+ svn_error_t *err = ctx->constructor->close_section(
+ ctx->constructor_baton, ctx->section->data);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
+ {
+ *stop = TRUE;
+ svn_error_clear(err);
+ return SVN_NO_ERROR;
+ }
+ else
+ return svn_error_trace(err);
+ }
}
- ctx->in_section = FALSE;
- if (ctx->constructor->close_section)
- return ctx->constructor->close_section(
- ctx->constructor_baton, ctx->section->data);
+ *stop = FALSE;
return SVN_NO_ERROR;
}
/* Called every tyme we've parsed a complete (option, value) pair. */
-static svn_error_t *
-add_value(parse_context_t *ctx)
+static APR_INLINE svn_error_t *
+add_value(parse_context_t *ctx, svn_boolean_t *stop)
{
- if (!ctx->constructor->add_value)
- return SVN_NO_ERROR;
-
- if (ctx->constructor->expand_values)
+ if (ctx->constructor->add_value)
{
- /* TODO: Implement logic for value expansion. */
- *(volatile long*)0 = 0xdeadbeef;
- }
- else
- {
- return ctx->constructor->add_value(
+ svn_error_t *err = ctx->constructor->add_value(
ctx->constructor_baton, ctx->section->data,
ctx->option->data, ctx->value->data);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
+ {
+ *stop = TRUE;
+ svn_error_clear(err);
+ return SVN_NO_ERROR;
+ }
+ else
+ return svn_error_trace(err);
+ }
}
+ *stop = FALSE;
return SVN_NO_ERROR;
}
@@ -355,7 +351,7 @@ static svn_error_t *
parse_value(int *pch, parse_context_t *ctx)
{
svn_boolean_t end_of_val = FALSE;
- svn_error_t *err;
+ svn_boolean_t stop;
int ch;
/* Read the first line of the value */
@@ -379,17 +375,9 @@ parse_value(int *pch, parse_context_t *c
{
/* At end of file. The value is complete, there can't be
any continuation lines. */
- err = add_value(ctx);
- if (err)
- {
- if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
- {
- svn_error_clear(err);
- return SVN_NO_ERROR;
- }
- else
- return svn_error_trace(err);
- }
+ SVN_ERR(add_value(ctx, &stop));
+ if (stop)
+ return SVN_NO_ERROR;
break;
}
else
@@ -672,7 +660,7 @@ svn_config__parse_file(svn_config_t *cfg
stream = svn_stream_from_aprfile2(apr_file, FALSE, scratch_pool);
err = svn_config__parse_stream(stream,
svn_config__constructor_create(
- FALSE, FALSE, FALSE, NULL, NULL,
+ NULL, NULL,
svn_config__default_add_value_fn,
scratch_pool),
cfg, scratch_pool);
@@ -692,21 +680,13 @@ svn_config__parse_file(svn_config_t *cfg
}
svn_error_t *
-svn_config__default_add_value_fn(void *baton, const char *section,
- const char *option, const char *value)
-{
- svn_config_set((svn_config_t *)baton, section, option, value);
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
svn_config__parse_stream(svn_stream_t *stream,
svn_config__constructor_t *constructor,
void *constructor_baton,
apr_pool_t *scratch_pool)
{
parse_context_t *ctx;
- svn_error_t *err;
+ svn_boolean_t stop;
int ch, count;
ctx = apr_palloc(scratch_pool, sizeof(*ctx));
@@ -741,31 +721,14 @@ svn_config__parse_stream(svn_stream_t *s
/* Close the previous section before starting a new one. */
if (ctx->in_section)
{
- err = close_section(ctx);
- if (err)
- {
- if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
- {
- svn_error_clear(err);
- return SVN_NO_ERROR;
- }
- else
- return svn_error_trace(err);
- }
+ SVN_ERR(close_section(ctx, &stop));
+ if (stop)
+ return SVN_NO_ERROR;
}
-
SVN_ERR(parse_section_name(&ch, ctx, scratch_pool));
- err = open_section(ctx);
- if (err)
- {
- if (err->apr_err == SVN_ERR_CEASE_INVOCATION)
- {
- svn_error_clear(err);
- return SVN_NO_ERROR;
- }
- else
- return svn_error_trace(err);
- }
+ SVN_ERR(open_section(ctx, &stop));
+ if (stop)
+ return SVN_NO_ERROR;
break;
case '#': /* Comment */
@@ -806,16 +769,7 @@ svn_config__parse_stream(svn_stream_t *s
/* Emit the last close-section call to wrap up. */
if (ctx->in_section)
- {
- err = close_section(ctx);
- if (err)
- {
- if (err->apr_err != SVN_ERR_CEASE_INVOCATION)
- return svn_error_trace(err);
- else
- svn_error_clear(err);
- }
- }
+ SVN_ERR(close_section(ctx, &stop));
return SVN_NO_ERROR;
}
Modified: subversion/branches/authzperf/subversion/libsvn_subr/config_impl.h
URL:
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/config_impl.h?rev=1614625&r1=1614624&r2=1614625&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/config_impl.h
(original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/config_impl.h Wed Jul
30 12:11:14 2014
@@ -76,6 +76,12 @@ struct svn_config_t
svn_boolean_t read_only;
};
+/* The default add-value constructor callback, used by the default
+ config parser that populates an svn_config_t. */
+svn_error_t *svn_config__default_add_value_fn(
+ void *baton, const char *section,
+ const char *option, const char *value);
+
/* Read sections and options from a file. */
svn_error_t *svn_config__parse_file(svn_config_t *cfg,
const char *file,