diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-08 14:18:25 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-02-08 14:18:25 +0000 |
commit | 88b95232237d4cc43cc49a4371931ea1b7a8a2b7 (patch) | |
tree | bacd8c3c740bc67d5b5257c924220c45bb509ecd | |
parent | 689db9610e36f7e8c2035447b4d05d29906f4945 (diff) | |
download | mailutils-88b95232237d4cc43cc49a4371931ea1b7a8a2b7.tar.gz mailutils-88b95232237d4cc43cc49a4371931ea1b7a8a2b7.tar.bz2 |
(act_getline): Bugfix. Do not return eof on an empty line. Reported by Damon Harper.
-rw-r--r-- | comsat/action.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/comsat/action.c b/comsat/action.c index 2b4dba3e1..727870c83 100644 --- a/comsat/action.c +++ b/comsat/action.c @@ -48,17 +48,20 @@ act_getline (FILE *fp, char **sptr, size_t *size) size_t used = 0; unsigned lines = 0; + if (feof (fp)) + return 0; + while (cont && fgets (buf, sizeof buf, fp)) { int len = strlen (buf); if (buf[len-1] == '\n') { + lines++; buf[--len] = 0; if (buf[len-1] == '\\') { buf[--len] = 0; cont = 1; - lines++; } else cont = 0; @@ -80,8 +83,6 @@ act_getline (FILE *fp, char **sptr, size_t *size) if (*sptr) (*sptr)[used] = 0; - if (used && !feof (fp)) - lines++; return lines; } |