summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb7a653)
raw | patch | inline | side by side (parent: fb7a653)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 2 Apr 2006 20:31:54 +0000 (13:31 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 2 Apr 2006 20:46:27 +0000 (13:46 -0700) |
This is the "letter of the law" version of using fgets() properly in the
face of incredibly broken stdio implementations. We can work around the
Solaris breakage with SA_RESTART, but in case anybody else is ever that
stupid, here's the "safe" (read: "insanely anal") way to use fgets.
It probably goes without saying that I'm not terribly impressed by
Solaris libc.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
face of incredibly broken stdio implementations. We can work around the
Solaris breakage with SA_RESTART, but in case anybody else is ever that
stupid, here's the "safe" (read: "insanely anal") way to use fgets.
It probably goes without saying that I'm not terribly impressed by
Solaris libc.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
pack-objects.c | patch | blob | history |
diff --git a/pack-objects.c b/pack-objects.c
index cde4afa798e093922f3e25738a65b6cc8f400fea..084c2006a987c79dfbd2f70c616d46eac23ed50d 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
setup_progress_signal();
}
- while (fgets(line, sizeof(line), stdin) != NULL) {
+ for (;;) {
unsigned int hash;
char *p;
unsigned char sha1[20];
+ if (!fgets(line, sizeof(line), stdin)) {
+ if (feof(stdin))
+ break;
+ if (!ferror(stdin))
+ die("fgets returned NULL, not EOF, not error!");
+ if (errno == EINTR)
+ continue;
+ die("fgets: %s", strerror(errno));
+ }
+
if (progress_update) {
fprintf(stderr, "Counting objects...%d\r", nr_objects);
progress_update = 0;