Skip to content

Commit

Permalink
Merge branch 'ab/imap-send-read-everything-simplify'
Browse files Browse the repository at this point in the history
Code simplification.

* ab/imap-send-read-everything-simplify:
  imap-send.c: use less verbose strbuf_fread() idiom
  • Loading branch information
gitster committed Jul 22, 2021
2 parents bb3a55f + 351bca2 commit 33309e4
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions imap-send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 33309e4

Please sign in to comment.