httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r157333 - in httpd/apreq/branches/multi-env-unstable: include/apreq_param.h library/param.c library/t/params.c library/util.c
Date Sun, 13 Mar 2005 15:29:27 GMT
Author: joes
Date: Sun Mar 13 07:29:25 2005
New Revision: 157333

URL: http://svn.apache.org/viewcvs?view=rev&rev=157333
Log:
Make apreq_join() and apreq_params_as_string() return an empty
string on n==0.

Submitted by: Max Kellermann
Reviewed by: joes

Note: This patch should complete r157331, which only patched apreq_util.h.

Modified:
    httpd/apreq/branches/multi-env-unstable/include/apreq_param.h
    httpd/apreq/branches/multi-env-unstable/library/param.c
    httpd/apreq/branches/multi-env-unstable/library/t/params.c
    httpd/apreq/branches/multi-env-unstable/library/util.c

Modified: httpd/apreq/branches/multi-env-unstable/include/apreq_param.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/include/apreq_param.h?view=diff&r1=157332&r2=157333
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/include/apreq_param.h (original)
+++ httpd/apreq/branches/multi-env-unstable/include/apreq_param.h Sun Mar 13 07:29:25 2005
@@ -159,14 +159,16 @@
 
 /**
  * Returns a ", " -joined string containing all parameters
- * for the requested key, NULL if none are found.  The key is case-insensitive.
+ * for the requested key, an empty string if none are found.
+ * The key is case-insensitive.
+ *
  * @param p Allocates the return string.
  * @param t the parameter table returned by apreq_args(), apreq_body()
  *    or apreq_params()
  * @param key Null-terminated parameter name, case insensitive.
  *    key==NULL fetches all values.
  * @param mode Join type- see apreq_join().
- * @return the joined string
+ * @return the joined string or NULL on error
  * @remark Also parses the request if necessary.
  */
 APREQ_DECLARE(const char *) apreq_params_as_string(apr_pool_t *p,

Modified: httpd/apreq/branches/multi-env-unstable/library/param.c
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/param.c?view=diff&r1=157332&r2=157333
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/param.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/param.c Sun Mar 13 07:29:25 2005
@@ -199,7 +199,7 @@
     apreq_param_t **elt = (apreq_param_t **)arr->elts;
     apreq_param_t **const end = elt + arr->nelts;
     if (arr->nelts == 0)
-        return NULL;
+        return apr_pstrdup(p, "");
 
     while (elt < end) {
         *(const apreq_value_t **)elt = &(**elt).v;

Modified: httpd/apreq/branches/multi-env-unstable/library/t/params.c
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/t/params.c?view=diff&r1=157332&r2=157333
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/t/params.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/t/params.c Sun Mar 13 07:29:25 2005
@@ -66,6 +66,8 @@
     AT_int_eq(arr->nelts, 2);
     val = apreq_params_as_string(p,args,"a",APREQ_JOIN_AS_IS);
     AT_str_eq(val, "1, 2");
+    val = apreq_params_as_string(p,args,"does_not_exist",APREQ_JOIN_AS_IS);
+    AT_str_eq(val, "");
 }
 
 static void string_decoding_in_place(dAT)
@@ -196,7 +198,7 @@
     at_test_t test_list [] = {
         dT(request_make, 3),
         dT(request_args_get, 8),
-        dT(params_as, 2),
+        dT(params_as, 3),
         dT(string_decoding_in_place, 8),
         dT(header_attributes, 13),
         dT(make_param, 8),

Modified: httpd/apreq/branches/multi-env-unstable/library/util.c
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/util.c?view=diff&r1=157332&r2=157333
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/util.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/util.c Sun Mar 13 07:29:25 2005
@@ -414,7 +414,7 @@
     slen = sep ? strlen(sep) : 0;
 
     if (n == 0)
-        return NULL;
+        return apr_pstrdup(p, "");
 
     for (j=0, len=0; j < n; ++j)
         len += a[j]->dlen + slen + 1;



Mime
View raw message