From: Jim Jagielski Date: Tue, 19 Jan 2016 12:56:57 +0000 (+0000) Subject: Merge r1719252, r1719254, r1719255, r1720996 from trunk: X-Git-Tag: 2.4.19~283 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91fbc87b8a7a8d1c1c645a271442dca27607db8c;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/STATUS b/STATUS index 72b99390cd8..010bf29dc58 100644 --- a/STATUS +++ b/STATUS @@ -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 diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 589611b593b..9aa0549b111 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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) { - return; - } - } + if (ap_array_str_contains(l->method_list, method)) { + return; } + xmethod = (const char **) apr_array_push(l->method_list); *xmethod = method; } diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index 891456e9339..71fc0a95b78 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -2238,20 +2238,14 @@ 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])) { - return 1; - } + if (ap_array_str_contains(variant->content_languages, lang)) { + return 1; } return 0; diff --git a/server/core.c b/server/core.c index 7ed6d9cc1bf..9ee2638f50a 100644 --- a/server/core.c +++ b/server/core.c @@ -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) diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 1038e7aeed9..d85706c23de 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -271,15 +271,15 @@ 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) - return 1; + } + if (ap_array_str_contains(haystack, needle)) { + return 1; } } return 0;