mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix getdelim(3) not returning a final line without a delimiter.
This commit is contained in:
parent
6d15ed575f
commit
53592a6e3f
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2012, 2014, 2015 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2011, 2012, 2014, 2015, 2018 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -57,11 +57,12 @@ ssize_t getdelim(char** lineptr, size_t* n, int delim, FILE* fp)
|
|||
}
|
||||
if ( (c = getc_unlocked(fp)) == EOF )
|
||||
{
|
||||
if ( !written || feof_unlocked(fp) )
|
||||
if ( !written || ferror_unlocked(fp) )
|
||||
{
|
||||
funlockfile(fp);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
(*lineptr)[written++] = c;
|
||||
} while ( c != delim );
|
||||
|
|
Loading…
Add table
Reference in a new issue