Commit 64402431 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Merge r1719252, r1719254, r1719255, r1720996 from trunk:

Use 'ap_array_str_contains' to simplify code.

Use 'ap_array_str_contains' to simplify code.

Use 'ap_array_str_contains' to simplify code.

Use 'ap_array_str_contains' to simplify code.
Submitted by: jailletc36
Reviewed/backported by: jim


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1725507 13f79535-47bb-0310-9956-ffa450edef68
parent 1f60b338
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -112,17 +112,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
  [ start all new proposals below, under PATCHES PROPOSED. ]

  *) mod_negotiation: Use 'ap_array_str_contains' to simplify code.
     core: likewise
     http: likewise
     trunk patch: http://svn.apache.org/r1719252
                  http://svn.apache.org/r1719254
                  http://svn.apache.org/r1719255
                  http://svn.apache.org/r1720996 (change in ap_method_in_list not
                                                  tested, it is not actually used)
     2.4.x patch: trunk works
     +1: jailletc36, covener, jim

  *) mod_mod_authn_socache: Do not use the magic string "directory". Use the
     corresponding global variable as in all other places of the module.
     trunk patch: http://svn.apache.org/r1719257
+6 −19
Original line number Diff line number Diff line
@@ -1569,8 +1569,6 @@ AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest,
AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method)
{
    int methnum;
    int i;
    char **methods;

    /*
     * If it's one of our known methods, use the shortcut and check the
@@ -1581,18 +1579,13 @@ AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method)
        return !!(l->method_mask & (AP_METHOD_BIT << methnum));
    }
    /*
     * Otherwise, see if the method name is in the array or string names
     * Otherwise, see if the method name is in the array of string names.
     */
    if ((l->method_list == NULL) || (l->method_list->nelts == 0)) {
        return 0;
    }
    methods = (char **)l->method_list->elts;
    for (i = 0; i < l->method_list->nelts; ++i) {
        if (strcmp(method, methods[i]) == 0) {
            return 1;
        }
    }
    return 0;

    return ap_array_str_contains(l->method_list, method);
}

/*
@@ -1601,9 +1594,7 @@ AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method)
AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method)
{
    int methnum;
    int i;
    const char **xmethod;
    char **methods;

    /*
     * If it's one of our known methods, use the shortcut and use the
@@ -1617,14 +1608,10 @@ AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method)
    /*
     * Otherwise, see if the method name is in the array of string names.
     */
    if (l->method_list->nelts != 0) {
        methods = (char **)l->method_list->elts;
        for (i = 0; i < l->method_list->nelts; ++i) {
            if (strcmp(method, methods[i]) == 0) {
    if (ap_array_str_contains(l->method_list, method)) {
        return;
    }
        }
    }

    xmethod = (const char **) apr_array_push(l->method_list);
    *xmethod = method;
}
+3 −9
Original line number Diff line number Diff line
@@ -2238,21 +2238,15 @@ static int is_variant_better(negotiation_state *neg, var_rec *variant,
 */
static int variant_has_language(var_rec *variant, const char *lang)
{
    int j, max;

    /* fast exit */
    if (   !lang
        || !variant->content_languages
        || !(max = variant->content_languages->nelts)) {
        || !variant->content_languages) {
        return 0;
    }

    for (j = 0; j < max; ++j) {
        if (!strcmp(lang,
                    ((char **) (variant->content_languages->elts))[j])) {
    if (ap_array_str_contains(variant->content_languages, lang)) {
        return 1;
    }
    }

    return 0;
}
+1 −11
Original line number Diff line number Diff line
@@ -2603,17 +2603,7 @@ static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)

AP_DECLARE(int) ap_exists_config_define(const char *name)
{
    char **defines;
    int i;

    defines = (char **)ap_server_config_defines->elts;
    for (i = 0; i < ap_server_config_defines->nelts; i++) {
        if (strcmp(defines[i], name) == 0) {
            return 1;
        }
    }

    return 0;
    return ap_array_str_contains(ap_server_config_defines, name);
}

static const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg)
+5 −5
Original line number Diff line number Diff line
@@ -271,14 +271,14 @@ static int ap_expr_eval_comp(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
                const ap_expr_t *arg = e2->node_arg2;
                ap_expr_list_func_t *func = (ap_expr_list_func_t *)info->node_arg1;
                apr_array_header_t *haystack;
                int i = 0;

                AP_DEBUG_ASSERT(func != NULL);
                AP_DEBUG_ASSERT(info->node_op == op_ListFuncInfo);
                haystack = (*func)(ctx, info->node_arg2, ap_expr_eval_word(ctx, arg));
                if (haystack == NULL)
                if (haystack == NULL) {
                    return 0;
                for (; i < haystack->nelts; i++) {
                    if (strcmp(needle, APR_ARRAY_IDX(haystack,i,char *)) == 0)
                }
                if (ap_array_str_contains(haystack, needle)) {
                    return 1;
                }
            }