]> granicus.if.org Git - apache/commitdiff
* server/protocol.c (ap_rgetline_core): Re-indent function after being
authorJoe Orton <jorton@apache.org>
Mon, 26 Jan 2004 20:58:12 +0000 (20:58 +0000)
committerJoe Orton <jorton@apache.org>
Mon, 26 Jan 2004 20:58:12 +0000 (20:58 +0000)
skewed by CAN-2003-0132 fix: no functional change.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102413 13f79535-47bb-0310-9956-ffa450edef68

server/protocol.c

index 67c7a56eec7a096e309fe8a42e45c661bff487df..cd3be724ad97ef7337a75338c5886d69b488681a 100644 (file)
@@ -253,89 +253,87 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
     int do_alloc = (*s == NULL), saw_eos = 0;
 
     for (;;) {
-    apr_brigade_cleanup(bb);
-    rv = ap_get_brigade(r->input_filters, bb, AP_MODE_GETLINE,
-                        APR_BLOCK_READ, 0);
-
-    if (rv != APR_SUCCESS) {
-        return rv;
-    }
-
-    /* Something horribly wrong happened.  Someone didn't block! */
-    if (APR_BRIGADE_EMPTY(bb)) {
-        return APR_EGENERAL;
-    }
-
-    for (e = APR_BRIGADE_FIRST(bb);
-         e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
-    {
-        const char *str;
-        apr_size_t len;
-
-        /* If we see an EOS, don't bother doing anything more. */
-        if (APR_BUCKET_IS_EOS(e)) {
-            saw_eos = 1;
-            break;
-        }
-
-        rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
-
+        apr_brigade_cleanup(bb);
+        rv = ap_get_brigade(r->input_filters, bb, AP_MODE_GETLINE,
+                            APR_BLOCK_READ, 0);
         if (rv != APR_SUCCESS) {
             return rv;
         }
-
-        if (len == 0) {
-            /* no use attempting a zero-byte alloc (hurts when
-             * using --with-efence --enable-pool-debug) or
-             * doing any of the other logic either
-             */
-            continue;
-        }
-
-        /* Would this overrun our buffer?  If so, we'll die. */
-        if (n < bytes_handled + len) {
-            *read = bytes_handled;
-            return APR_ENOSPC;
+        
+        /* Something horribly wrong happened.  Someone didn't block! */
+        if (APR_BRIGADE_EMPTY(bb)) {
+            return APR_EGENERAL;
         }
-
-        /* Do we have to handle the allocation ourselves? */
-        if (do_alloc) {
-            /* We'll assume the common case where one bucket is enough. */
-            if (!*s) {
-                current_alloc = len;
-                if (current_alloc < MIN_LINE_ALLOC) {
-                    current_alloc = MIN_LINE_ALLOC;
-                }
-                *s = apr_palloc(r->pool, current_alloc);
+        
+        for (e = APR_BRIGADE_FIRST(bb);
+             e != APR_BRIGADE_SENTINEL(bb);
+             e = APR_BUCKET_NEXT(e))
+        {
+            const char *str;
+            apr_size_t len;
+            
+            /* If we see an EOS, don't bother doing anything more. */
+            if (APR_BUCKET_IS_EOS(e)) {
+                saw_eos = 1;
+                break;
             }
-            else if (bytes_handled + len > current_alloc) {
-                /* Increase the buffer size */
-                apr_size_t new_size = current_alloc * 2;
-                char *new_buffer;
-
-                if (bytes_handled + len > new_size) {
-                    new_size = (bytes_handled + len) * 2;
+            
+            rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
+            if (rv != APR_SUCCESS) {
+                return rv;
+            }
+            
+            if (len == 0) {
+                /* no use attempting a zero-byte alloc (hurts when
+                 * using --with-efence --enable-pool-debug) or
+                 * doing any of the other logic either
+                 */
+                continue;
+            }
+            
+            /* Would this overrun our buffer?  If so, we'll die. */
+            if (n < bytes_handled + len) {
+                *read = bytes_handled;
+                return APR_ENOSPC;
+            }
+            
+            /* Do we have to handle the allocation ourselves? */
+            if (do_alloc) {
+                /* We'll assume the common case where one bucket is enough. */
+                if (!*s) {
+                    current_alloc = len;
+                    if (current_alloc < MIN_LINE_ALLOC) {
+                        current_alloc = MIN_LINE_ALLOC;
+                    }
+                    *s = apr_palloc(r->pool, current_alloc);
+                }
+                else if (bytes_handled + len > current_alloc) {
+                    /* Increase the buffer size */
+                    apr_size_t new_size = current_alloc * 2;
+                    char *new_buffer;
+                    
+                    if (bytes_handled + len > new_size) {
+                        new_size = (bytes_handled + len) * 2;
+                    }
+                    
+                    new_buffer = apr_palloc(r->pool, new_size);
+                    
+                    /* Copy what we already had. */
+                    memcpy(new_buffer, *s, bytes_handled);
+                    current_alloc = new_size;
+                    *s = new_buffer;
                 }
-
-                new_buffer = apr_palloc(r->pool, new_size);
-
-                /* Copy what we already had. */
-                memcpy(new_buffer, *s, bytes_handled);
-                current_alloc = new_size;
-                *s = new_buffer;
             }
-        }
-
-        /* Just copy the rest of the data to the end of the old buffer. */
-        pos = *s + bytes_handled;
-        memcpy(pos, str, len);
-        last_char = pos + len - 1;
-
-        /* We've now processed that new data - update accordingly. */
-        bytes_handled += len;
-    }
 
+            /* Just copy the rest of the data to the end of the old buffer. */
+            pos = *s + bytes_handled;
+            memcpy(pos, str, len);
+            last_char = pos + len - 1;
+            
+            /* We've now processed that new data - update accordingly. */
+            bytes_handled += len;
+        }
+        
         /* If we got a full line of input, stop reading */
         if (last_char && (*last_char == APR_ASCII_LF)) {
             break;
@@ -378,96 +376,93 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
      */
     if (fold && bytes_handled && !saw_eos) {
         for (;;) {
-        const char *str;
-        apr_size_t len;
-        char c;
-
-        /* Clear the temp brigade for this filter read. */
-        apr_brigade_cleanup(bb);
-
-        /* We only care about the first byte. */
-        rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE,
-                            APR_BLOCK_READ, 1);
-
-        if (rv != APR_SUCCESS) {
-            return rv;
-        }
-
-        if (APR_BRIGADE_EMPTY(bb)) {
+            const char *str;
+            apr_size_t len;
+            char c;
+            
+            /* Clear the temp brigade for this filter read. */
+            apr_brigade_cleanup(bb);
+            
+            /* We only care about the first byte. */
+            rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE,
+                                APR_BLOCK_READ, 1);
+            if (rv != APR_SUCCESS) {
+                return rv;
+            }
+            
+            if (APR_BRIGADE_EMPTY(bb)) {
                 break;
-        }
-
-        e = APR_BRIGADE_FIRST(bb);
-
-        /* If we see an EOS, don't bother doing anything more. */
-        if (APR_BUCKET_IS_EOS(e)) {
+            }
+            
+            e = APR_BRIGADE_FIRST(bb);
+            
+            /* If we see an EOS, don't bother doing anything more. */
+            if (APR_BUCKET_IS_EOS(e)) {
                 break;
-        }
-
-        rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
-
-        if (rv != APR_SUCCESS) {
+            }
+            
+            rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
+            if (rv != APR_SUCCESS) {
                 apr_brigade_cleanup(bb);
-            return rv;
-        }
-
-        /* Found one, so call ourselves again to get the next line.
-         *
-         * FIXME: If the folding line is completely blank, should we
-         * stop folding?  Does that require also looking at the next
-         * char?
-         */
+                return rv;
+            }
+            
+            /* Found one, so call ourselves again to get the next line.
+             *
+             * FIXME: If the folding line is completely blank, should we
+             * stop folding?  Does that require also looking at the next
+             * char?
+             */
             /* When we call destroy, the buckets are deleted, so save that
              * one character we need.  This simplifies our execution paths
              * at the cost of one character read.
              */
             c = *str;
-        if (c == APR_ASCII_BLANK || c == APR_ASCII_TAB) {
-            /* Do we have enough space? We may be full now. */
+            if (c == APR_ASCII_BLANK || c == APR_ASCII_TAB) {
+                /* Do we have enough space? We may be full now. */
                 if (bytes_handled >= n) {
                     *read = n;
                     return APR_ENOSPC;
                 }
                 else {
-                apr_size_t next_size, next_len;
-                char *tmp;
-
-                /* If we're doing the allocations for them, we have to
-                 * give ourselves a NULL and copy it on return.
-                 */
-                if (do_alloc) {
-                    tmp = NULL;
-                } else {
-                    /* We're null terminated. */
-                    tmp = last_char;
-                }
-
-                next_size = n - bytes_handled;
-
+                    apr_size_t next_size, next_len;
+                    char *tmp;
+                    
+                    /* If we're doing the allocations for them, we have to
+                     * give ourselves a NULL and copy it on return.
+                     */
+                    if (do_alloc) {
+                        tmp = NULL;
+                    } else {
+                        /* We're null terminated. */
+                        tmp = last_char;
+                    }
+                    
+                    next_size = n - bytes_handled;
+                    
                     rv = ap_rgetline_core(&tmp, next_size,
                                           &next_len, r, 0, bb);
-
-                if (rv != APR_SUCCESS) {
-                    return rv;
-                }
-
-                if (do_alloc && next_len > 0) {
-                    char *new_buffer;
-                    apr_size_t new_size = bytes_handled + next_len + 1;
-
-                    /* we need to alloc an extra byte for a null */
-                    new_buffer = apr_palloc(r->pool, new_size);
-
-                    /* Copy what we already had. */
-                    memcpy(new_buffer, *s, bytes_handled);
-
-                    /* copy the new line, including the trailing null */
-                    memcpy(new_buffer + bytes_handled, tmp, next_len + 1);
-                    *s = new_buffer;
-                }
+                    if (rv != APR_SUCCESS) {
+                        return rv;
+                    }
+                    
+                    if (do_alloc && next_len > 0) {
+                        char *new_buffer;
+                        apr_size_t new_size = bytes_handled + next_len + 1;
+                        
+                        /* we need to alloc an extra byte for a null */
+                        new_buffer = apr_palloc(r->pool, new_size);
+
+                        /* Copy what we already had. */
+                        memcpy(new_buffer, *s, bytes_handled);
+                        
+                        /* copy the new line, including the trailing null */
+                        memcpy(new_buffer + bytes_handled, tmp, next_len + 1);
+                        *s = new_buffer;
+                    }
 
                     bytes_handled += next_len;
-            }
+                }
             }
             else { /* next character is not tab or space */
                 break;