Index: include/ap_buckets.h
===================================================================
RCS file: /home/cvspublic/apr-util/include/ap_buckets.h,v
retrieving revision 1.60
diff -u -r1.60 ap_buckets.h
--- include/ap_buckets.h	2000/12/12 12:18:42	1.60
+++ include/ap_buckets.h	2000/12/12 17:08:55
@@ -589,11 +589,12 @@
  * of bytes from the brigade; the ranges can even overlap.
  * @param b The brigade to partition
  * @param point The offset at which to partition the brigade
- * @return A pointer to the first bucket after the partition;
- *         or NULL in any error condition (including partition past the end)
- * @deffunc ap_bucket *ap_brigade_partition(ap_bucket_brigade *b, apr_off_t point)
+ * @param after_point Returns a pointer to the first bucket after the partition
+ * @deffunc apr_status_t ap_brigade_partition(ap_bucket_brigade *b, apr_off_t point, ap_bucket **after_point)
  */
-APR_DECLARE(ap_bucket *) ap_brigade_partition(ap_bucket_brigade *b, apr_off_t point);
+APR_DECLARE(apr_status_t) ap_brigade_partition(ap_bucket_brigade *b,
+                                               apr_off_t point,
+                                               ap_bucket **after_point);
 
 #if APR_NOT_DONE_YET
 /**
Index: src/buckets/ap_buckets.c
===================================================================
RCS file: /home/cvspublic/apr-util/src/buckets/ap_buckets.c,v
retrieving revision 1.37
diff -u -r1.37 ap_buckets.c
--- src/buckets/ap_buckets.c	2000/12/12 12:18:46	1.37
+++ src/buckets/ap_buckets.c	2000/12/12 17:08:56
@@ -122,48 +122,44 @@
     return a;
 }
 
-APR_DECLARE(ap_bucket *) ap_brigade_partition(ap_bucket_brigade *b, apr_off_t point)
+APR_DECLARE(apr_status_t) ap_brigade_partition(ap_bucket_brigade *b,
+                                               apr_off_t point,
+                                               ap_bucket **after_point)
 {
     ap_bucket *e;
     const char *s;
     apr_size_t len;
+    apr_status_t rv;
 
     if (point < 0)
-        return NULL;
+        return APR_EINVAL;
 
     AP_BRIGADE_FOREACH(e, b) {
         /* bucket is of a known length */
-        if ((point > e->length) && (e->length != -1)) {
-            if (AP_BUCKET_IS_EOS(e))
-                return NULL;
-            point -= e->length;
-        }
-        else if (point == e->length) {
-            return AP_BUCKET_NEXT(e);
-        }
-        else {
+        if (point < e->length) {
             /* try to split the bucket natively */
-            if (ap_bucket_split(e, point) != APR_ENOTIMPL)
-                return AP_BUCKET_NEXT(e);
+            if ((rv = ap_bucket_split(e, point)) != APR_ENOTIMPL) {
+                *after_point = AP_BUCKET_NEXT(e);
+                return rv;
+            }
 
             /* if the bucket cannot be split, we must read from it,
              * changing its type to one that can be split */
-            if (ap_bucket_read(e, &s, &len, AP_BLOCK_READ) != APR_SUCCESS)
-                return NULL;
+            if ((rv=ap_bucket_read(e, &s, &len, AP_BLOCK_READ)) != APR_SUCCESS)
+                return rv;
 
             if (point < len) {
-                if (ap_bucket_split(e, point) == APR_SUCCESS)
-                    return AP_BUCKET_NEXT(e);
-                else
-                    return NULL;
+                *after_point = AP_BUCKET_NEXT(e);
+                return ap_bucket_split(e, point);
             }
-            else if (point == len)
-                return AP_BUCKET_NEXT(e);
-            else
-                point -= len;
         }
+        if (point == e->length) {
+            *after_point = AP_BUCKET_NEXT(e);
+            return APR_SUCCESS;
+        }
+        point -= e->length;
     }
-    return NULL;
+    return APR_EINVAL;
 }
 
 APR_DECLARE(int) ap_brigade_to_iovec(ap_bucket_brigade *b, 
