httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ic...@apache.org
Subject svn commit: r1700968 - in /httpd/httpd/trunk: include/httpd.h modules/http2/h2_switch.c server/protocol.c server/util.c
Date Thu, 03 Sep 2015 09:39:59 GMT
Author: icing
Date: Thu Sep  3 09:39:59 2015
New Revision: 1700968

URL: http://svn.apache.org/r1700968
Log:
final final change to the new ap_array_str_* functions after review

Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/modules/http2/h2_switch.c
    httpd/httpd/trunk/server/protocol.c
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1700968&r1=1700967&r2=1700968&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Thu Sep  3 09:39:59 2015
@@ -2407,22 +2407,22 @@ AP_DECLARE(char *) ap_get_exec_line(apr_
  * searching a start. 
  * @param array The array the check
  * @param s The string to find
- * @param start Start index for search. If start is greater or 
-                equal to array length, -1 will be returned.
+ * @param start Start index for search. If start is out of bounds (negative or  
+                equal to array length or greater), -1 will be returned.
  * @return index of string in array or -1
  */
-AP_DECLARE(int) ap_array_index(const apr_array_header_t *array, 
-                               const char *s,
-                               apr_size_t start);
+AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array, 
+                                   const char *s,
+                                   int start);
 
 /**
  * Check if the string is member of the given array by strcmp.
  * @param array The array the check
  * @param s The string to find
- * @return !=0 iff string is member of array
+ * @return !=0 iff string is member of array (via strcmp)
  */
-AP_DECLARE(int) ap_array_contains(const apr_array_header_t *array, 
-                                  const char *s);
+AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array, 
+                                      const char *s);
 
 #ifdef __cplusplus
 }

Modified: httpd/httpd/trunk/modules/http2/h2_switch.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_switch.c?rev=1700968&r1=1700967&r2=1700968&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_switch.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_switch.c Thu Sep  3 09:39:59 2015
@@ -108,7 +108,7 @@ static int h2_protocol_propose(conn_rec
         /* Add all protocols we know (tls or clear) and that
          * are part of the offerings (if there have been any). 
          */
-        if (!offers || ap_array_contains(offers, *protos)) {
+        if (!offers || ap_array_str_contains(offers, *protos)) {
             ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
                           "proposing protocol '%s'", *protos);
             APR_ARRAY_PUSH(proposals, const char*) = *protos;

Modified: httpd/httpd/trunk/server/protocol.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/protocol.c?rev=1700968&r1=1700967&r2=1700968&view=diff
==============================================================================
--- httpd/httpd/trunk/server/protocol.c (original)
+++ httpd/httpd/trunk/server/protocol.c Thu Sep  3 09:39:59 2015
@@ -1956,8 +1956,8 @@ static int protocol_cmp(apr_array_header
                         const char *proto2)
 {
     if (preferences && preferences->nelts > 0) {
-        int index1 = ap_array_index(preferences, proto1, 0);
-        int index2 = ap_array_index(preferences, proto2, 0);
+        int index1 = ap_array_str_index(preferences, proto1, 0);
+        int index2 = ap_array_str_index(preferences, proto2, 0);
         if (index2 > index1) {
             return (index1 >= 0) ? 1 : -1;
         }
@@ -2006,8 +2006,8 @@ AP_DECLARE(const char *) ap_select_proto
         /* If the existing protocol has not been proposed, but is a choice,
          * add it to the proposals implicitly.
          */
-        if (!ap_array_contains(proposals, existing) 
-            && ap_array_contains(choices, existing)) {
+        if (!ap_array_str_contains(proposals, existing) 
+            && ap_array_str_contains(choices, existing)) {
             APR_ARRAY_PUSH(proposals, const char*) = existing;
         }
         
@@ -2021,7 +2021,7 @@ AP_DECLARE(const char *) ap_select_proto
         for (i = 0; i < proposals->nelts; ++i) {
             const char *p = APR_ARRAY_IDX(proposals, i, const char *);
             if (conf->protocols->nelts > 0 
-                && !ap_array_contains(conf->protocols, p)) {
+                && !ap_array_str_contains(conf->protocols, p)) {
                 /* not a permitted protocol here */
                 continue;
             }

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1700968&r1=1700967&r2=1700968&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Thu Sep  3 09:39:59 2015
@@ -3149,23 +3149,27 @@ AP_DECLARE(char *) ap_get_exec_line(apr_
     return apr_pstrndup(p, buf, k);
 }
 
-AP_DECLARE(int) ap_array_index(const apr_array_header_t *array, 
-                               const char *s,
-                               apr_size_t start)
+AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array, 
+                                   const char *s,
+                                   int start)
 {
-    apr_size_t i;
-    for (i = start; i < array->nelts; i++) {
-        const char *p = APR_ARRAY_IDX(array, i, const char *);
-        if (!strcmp(p, s)) {
-            return (int)i;
+    if (start >= 0) {
+        int i;
+        
+        for (i = start; i < array->nelts; i++) {
+            const char *p = APR_ARRAY_IDX(array, i, const char *);
+            if (!strcmp(p, s)) {
+                return i;
+            }
         }
     }
+    
     return -1;
 }
 
-AP_DECLARE(int) ap_array_contains(const apr_array_header_t *array, 
-                                  const char *s)
+AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array, 
+                                      const char *s)
 {
-    return (ap_array_index(array, s, 0) >= 0);
+    return (ap_array_str_index(array, s, 0) >= 0);
 }
 



Mime
View raw message