# HG changeset patch # User Bruno Haible # Date 1209653023 -7200 # Node ID 8849272e39e881bb63c0d9bbf0c8609ed8217a56 # Parent 5dbecbd80f2df92128bde1cefdbcdfb7a77e7bc4 Add comments. diff --git a/lib/getndelim2.c b/lib/getndelim2.c --- a/lib/getndelim2.c +++ b/lib/getndelim2.c @@ -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; }