summaryrefslogtreecommitdiff
path: root/gl/getdelim.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2005-09-02 14:59:24 +0000
committerSimon Josefsson <simon@josefsson.org>2005-09-02 14:59:24 +0000
commitedd9cbef6f019a34631547a27f81379494b262eb (patch)
tree333421ff1c9d33d2b1405c792aa166cdfeea5429 /gl/getdelim.c
parentd7ed3f39d8c0a437801b86a3d692ab0210df4c6c (diff)
downloadgnutls-edd9cbef6f019a34631547a27f81379494b262eb.tar.gz
Update gnulib.
Diffstat (limited to 'gl/getdelim.c')
-rw-r--r--gl/getdelim.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gl/getdelim.c b/gl/getdelim.c
index aa57afdcf6..597b2a25ef 100644
--- a/gl/getdelim.c
+++ b/gl/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 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
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 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
break;
}
(*lineptr)[cur_len] = '\0';
- result = cur_len;
+ result = cur_len ? cur_len : result;
unlock_return:
funlockfile (fp);