diff options
author | jilles <jilles@FreeBSD.org> | 2010-11-14 15:31:59 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-11-14 15:31:59 +0000 |
commit | 808b93da2eb6ef8566357c705d038cf597718cd5 (patch) | |
tree | 960f01c2f76ed659f7b40abffbbabae8e71c6a34 /bin/sh/output.c | |
parent | 3f7f99e32bfd4a62f3516eb46a43d84639f51f92 (diff) | |
download | FreeBSD-src-808b93da2eb6ef8566357c705d038cf597718cd5.zip FreeBSD-src-808b93da2eb6ef8566357c705d038cf597718cd5.tar.gz |
sh: Add binary buffered output for use by the printf builtin.
Diffstat (limited to 'bin/sh/output.c')
-rw-r--r-- | bin/sh/output.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/bin/sh/output.c b/bin/sh/output.c index 9fd8478..d7fc534 100644 --- a/bin/sh/output.c +++ b/bin/sh/output.c @@ -122,8 +122,7 @@ out2qstr(const char *p) void outstr(const char *p, struct output *file) { - while (*p) - outc(*p++, file); + outbin(p, strlen(p), file); } /* Like outstr(), but quote for re-input into the shell. */ @@ -165,6 +164,16 @@ outqstr(const char *p, struct output *file) outc('\'', file); } +void +outbin(const void *data, size_t len, struct output *file) +{ + const char *p; + + p = data; + while (len-- > 0) + outc(*p++, file); +} + static char out_junk[16]; void @@ -285,17 +294,11 @@ static int doformat_wr(void *cookie, const char *buf, int len) { struct output *o; - int origlen; - unsigned char c; o = (struct output *)cookie; - origlen = len; - while (len-- != 0) { - c = (unsigned char)*buf++; - outc(c, o); - } + outbin(buf, len, o); - return (origlen); + return (len); } void |