Mercurial > hg > octave-nkf > gnulib-hg
changeset 6188:665f4d41d10b
2005-08-31 Derek Price <derek@ximbiot.com>
* getdelim.c (getdelim): Return EOF on EOF.
Reported by Larry Jones <lawrence.jones@ugs.com>.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Thu, 01 Sep 2005 11:09:14 +0000 |
parents | 6fb0d3a30d33 |
children | 9d1ed82c5d14 |
files | lib/ChangeLog lib/getdelim.c |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2005-08-31 Derek Price <derek@ximbiot.com> + + * getdelim.c (getdelim): Return EOF on EOF. + Reported by Larry Jones <lawrence.jones@ugs.com>. + 2005-08-31 Paul Eggert <eggert@cs.ucla.edu> * regex_internal.c (re_string_reconstruct): Don't assume buffer
--- a/lib/getdelim.c +++ b/lib/getdelim.c @@ -46,7 +46,7 @@ ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) { - int result; + int result = 0; ssize_t cur_len = 0; ssize_t len; @@ -76,7 +76,10 @@ i = getc (fp); if (i == EOF) + { + result = -1; break; + } /* Make enough space for len+1 (for final NUL) bytes. */ if (cur_len + 1 >= *n) @@ -108,7 +111,7 @@ break; } (*lineptr)[cur_len] = '\0'; - result = cur_len; + result = cur_len ? cur_len : result; unlock_return: funlockfile (fp);