From 9dc527adbc013b67cd85cce67bdccc3c10ed4792 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 18 May 2005 23:34:03 -0700 Subject: [PATCH] fix strbuf take #2 I just remembered why I placed that bogus "sb->len ==0 implies sb->eof" condition there. We need at least something like this to catch the normal EOF (that is, line termination immediately followed by EOF) case. "if (feof(fp))" fires when we have already read the eof, not when we are about read it. Signed-off-by: Junio C Hamano Signed-off-by: Linus Torvalds diff --git a/strbuf.c b/strbuf.c index 6543308..672a1e4 100644 --- a/strbuf.c +++ b/strbuf.c @@ -37,6 +37,8 @@ void read_line(struct strbuf *sb, FILE *fp, int term) { break; strbuf_add(sb, ch); } + if (ch == EOF && sb->len == 0) + sb->eof = 1; strbuf_end(sb); } -- cgit v0.10.2-6-g49f6