Made getdelim(3) follow POSIX-2008 a bit more closely.

It now reads lines that aren't delimited, but terminated by EOF.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-07 15:52:07 +01:00
parent 3cc1f7a687
commit d6f9505d3b
1 changed files with 4 additions and 1 deletions

View File

@ -64,7 +64,10 @@ ssize_t getdelim(char** lineptr, size_t* n, int delim, FILE* fp)
int c;
do
{
if ( (c = getc(fp)) == EOF ) { goto cleanup; }
if ( (c = getc(fp)) == EOF )
{
if ( written ) { break; } else { goto cleanup; }
}
if ( bufsize <= (size_t) written + 1UL )
{
size_t newbufsize = 2UL * bufsize;