Skip to content

Commit

Permalink
[PATCH] fix strbuf take #2
Browse files Browse the repository at this point in the history
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 <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Junio C Hamano authored and Linus Torvalds committed May 19, 2005
1 parent 9b632be commit 9dc527a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 9dc527a

Please sign in to comment.