]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1719252, r1719254, r1719255, r1720996 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 19 Jan 2016 12:56:57 +0000 (12:56 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 19 Jan 2016 12:56:57 +0000 (12:56 +0000)
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

STATUS
modules/http/http_protocol.c
modules/mappers/mod_negotiation.c
server/core.c
server/util_expr_eval.c

diff --git a/STATUS b/STATUS
index 72b99390cd8c8f5ecd088d81f61a5d6921852e44..010bf29dc58740794349d9017c6677e674ac9b57 100644 (file)
--- 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
index 589611b593b2daef80458e06bbec498d325e7ccb..9aa0549b11165ceb8619a1e26de02645c1106355 100644 (file)
@@ -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;
 }
index 891456e9339fd22788e7c62bb1792f9a3803e233..71fc0a95b782aab1ae81c484f6270ef71335c2e5 100644 (file)
@@ -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;
index 7ed6d9cc1bf899e70b739123e3b8fd37d70dc8c7..9ee2638f50aa4fceb55cc941a01c76e3fb73c915 100644 (file)
@@ -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)
index 1038e7aeed9c74c6161aa7d9d56d7cb329b35160..d85706c23ded72c4ba035ad6691d11f20765cb84 100644 (file)
@@ -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;