On Mon, 30 Jan 2006, jerenkrantz@tigris.org wrote:
...
> +static const char *
> +find_attr(const char **attrs, const char *attr_name)
> +{
> + const char *attr_val = NULL;
> + const char **tmp_attrs = attrs;
> +
> + while (*tmp_attrs)
> + {
> + if (strcmp(*tmp_attrs, attr_name) == 0)
> + {
> + attr_val = attrs[1];
> + }
> + tmp_attrs += 2;
> + }
> +
> + return attr_val;
> +}
Is it correct to continue to overwrite ATTR_VAL (always with the first
value from ATTRS) until ATTR_NAME is no longer found in ATTRS (which I
assume is a list of name/value pairs), rather than stopping looking
after the first instance of ATTR_NAME is encountered, or at least
taking the new value for ATTR_NAME? Answers would be useful in the
doc string.
A couple of uses of the function follow (to provide some context).
...
> @@ -1245,16 +1327,8 @@
> if (!ctx->state && strcmp(prop_name.name, "open-directory") == 0)
> {
> const char *rev = NULL;
> - const char **tmp_attrs = attrs;
>
> - while (*tmp_attrs)
> - {
> - if (strcmp(*tmp_attrs, "rev") == 0)
> - {
> - rev = attrs[1];
> - }
> - tmp_attrs += 2;
> - }
> + rev = find_attr(attrs, "rev");
>
> if (!rev)
> {
...
> + else if (ctx->state &&
> + (ctx->state->state == OPEN_DIR || ctx->state->state == ADD_DIR) &&
> + strcmp(prop_name.name, "add-directory") == 0)
> + {
> + const char *dir_name = NULL;
> + report_dir_t *dir_info;
> +
> + dir_name = find_attr(attrs, "name");
> +
> + push_state(ctx, ADD_DIR);
...
- application/pgp-signature attachment: stored
Received on Tue Jan 31 21:21:03 2006