changeset 10027:8849272e39e8

Add comments.
author Bruno Haible <bruno@clisp.org>
date Thu, 01 May 2008 16:43:43 +0200
parents 5dbecbd80f2d
children bd5f3690f627
files lib/getndelim2.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/getndelim2.c	Thu May 01 10:17:19 2008 +0200
+++ b/lib/getndelim2.c	Thu May 01 16:43:43 2008 +0200
@@ -105,7 +105,8 @@
 
   while (!done)
     {
-      /* Here always ptr + size == read_pos + nbytes_avail.  */
+      /* Here always ptr + size == read_pos + nbytes_avail.
+	 Also nbytes_avail > 0 || size < nmax.  */
 
       int c IF_LINT (= 0);
       const char *buffer;
@@ -171,6 +172,9 @@
 	  read_pos = size - nbytes_avail + ptr;
 	}
 
+      /* Here, if size < nmax, nbytes_avail >= buffer_len + 1.
+	 If size == nmax, nbytes_avail > 0.  */
+
       if (1 < nbytes_avail)
 	{
 	  size_t copy_len = nbytes_avail - 1;
@@ -183,6 +187,9 @@
 	  read_pos += copy_len;
 	  nbytes_avail -= copy_len;
 	}
+
+      /* Here still nbytes_avail > 0.  */
+
       if (buffer && freadseek (stream, buffer_len))
 	goto unlock_done;
     }