threads / patch / 656

patchfix strbuf take #2

Subject: [PATCH] fix strbuf take #2

## tl;dr

One message between May 19, 2005 and May 19, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· May 19, 2005, 06:34 UTC · lore

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>
---
git-diff-cache -r -z 0 | ./git-diff-helper -z
Show changes to strbuf.c +2 −0
diff --git a/strbuf.c b/strbuf.c
--- a/strbuf.c
+++ b/strbuf.c
@@ -37,6 +37,8 @@ void read_line(struct strbuf *sb, FILE *
 			break;
 		strbuf_add(sb, ch);
 	}
+	if (ch == EOF && sb->len == 0)
+		sb->eof = 1;
 	strbuf_end(sb);
 }
 

← back to recent threads