X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=convert.c;h=491e7141b4ea29b3cf754cbaf2656a0c3ca8c46c;hb=b7eb912b0d3352d43a11c79fab97cd7f92f0646e;hp=352b69d4ceeec411a81469a6146e023aa1d6b338;hpb=afce435000030e3ad076ef1dd413e0fa314cdcbb;p=git.git diff --git a/convert.c b/convert.c index 352b69d4c..491e7141b 100644 --- a/convert.c +++ b/convert.c @@ -61,6 +61,10 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat * else stats->printable++; } + + /* If file ends with EOF then don't count this EOF as non-printable. */ + if (size >= 1 && buf[size-1] == '\032') + stats->nonprintable--; } /* @@ -263,7 +267,7 @@ static int filter_buffer(int fd, void *data) status = finish_command(&child_process); if (status) - error("external filter %s failed %d", params->cmd, -status); + error("external filter %s failed %d", params->cmd, status); return (write_err || status); } @@ -277,7 +281,7 @@ static int apply_filter(const char *path, const char *src, size_t len, * (child --> cmd) --> us */ int ret = 1; - struct strbuf nbuf; + struct strbuf nbuf = STRBUF_INIT; struct async async; struct filter_params params; @@ -295,7 +299,6 @@ static int apply_filter(const char *path, const char *src, size_t len, if (start_async(&async)) return 0; /* error was already reported */ - strbuf_init(&nbuf, 0); if (strbuf_read(&nbuf, async.out, len) < 0) { error("read from external filter %s failed", cmd); ret = 0;