1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

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

View file

@ -64,7 +64,10 @@ ssize_t getdelim(char** lineptr, size_t* n, int delim, FILE* fp)
int c; int c;
do 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 ) if ( bufsize <= (size_t) written + 1UL )
{ {
size_t newbufsize = 2UL * bufsize; size_t newbufsize = 2UL * bufsize;