summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-07-22 13:05:56 -0700
committerJunio C Hamano <gitster@pobox.com>2021-07-22 13:05:56 -0700
commit33309e428bf85a0f06e4d23b448bf5400efe3f17 (patch)
treecf149032b3357104ad7560f637a6cc3ccb771cc5
parentbb3a55f6d32c86a25104097254b6fb8c5c3b7977 (diff)
parent351bca2d1f814e69740ac0b023bdfb7978b5c215 (diff)
downloadgit-33309e428bf85a0f06e4d23b448bf5400efe3f17.tar.xz
Merge branch 'ab/imap-send-read-everything-simplify'
Code simplification. * ab/imap-send-read-everything-simplify: imap-send.c: use less verbose strbuf_fread() idiom
-rw-r--r--imap-send.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/imap-send.c b/imap-send.c
index bb085d66d1..9d06ef7cd2 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1266,18 +1266,6 @@ static void wrap_in_html(struct strbuf *msg)
*msg = buf;
}
-#define CHUNKSIZE 0x1000
-
-static int read_message(FILE *f, struct strbuf *all_msgs)
-{
- do {
- if (strbuf_fread(all_msgs, CHUNKSIZE, f) <= 0)
- break;
- } while (!feof(f));
-
- return ferror(f) ? -1 : 0;
-}
-
static int count_messages(struct strbuf *all_msgs)
{
int count = 0;
@@ -1582,8 +1570,8 @@ int cmd_main(int argc, const char **argv)
}
/* read the messages */
- if (read_message(stdin, &all_msgs)) {
- fprintf(stderr, "error reading input\n");
+ if (strbuf_read(&all_msgs, 0, 0) < 0) {
+ error_errno(_("could not read from stdin"));
return 1;
}