diff options
author | peter <peter@FreeBSD.org> | 1996-10-01 04:56:59 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-10-01 04:56:59 +0000 |
commit | dd85f245b6e7876ed97bebc7cadc0447fc827f3c (patch) | |
tree | 0ca3158373cad424977be40a7fd42b15837e24a9 /usr.bin | |
parent | 117f14cc949233d70b63d061809f9fd4c521b9c7 (diff) | |
download | FreeBSD-src-dd85f245b6e7876ed97bebc7cadc0447fc827f3c.zip FreeBSD-src-dd85f245b6e7876ed97bebc7cadc0447fc827f3c.tar.gz |
When used as a shell builtin, this program decoded a subset of arguments
known to printf(3) and then used printf() to format it... The only
problem what the #define printf out1fmt. The code was behaving differently
when run as a shell builtin since out1fmt() isn't printf(3).
Simple hack. Print to a buffer and fputs (also #defined for sh) the
result. This should fix the printf builtin problem in PR#1673, rather
than leaving the call commented out. (printf.o was being statically linked
in anyway, we might as well use it)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/printf/printf.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index d370d98..90e8c45 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -58,15 +58,20 @@ static char sccsid[] = "@(#)printf.c 8.1 (Berkeley) 7/20/93"; #endif #define PF(f, func) { \ + char *b = NULL; \ if (fieldwidth) \ if (precision) \ - (void)printf(f, fieldwidth, precision, func); \ + (void)asprintf(&b, f, fieldwidth, precision, func); \ else \ - (void)printf(f, fieldwidth, func); \ + (void)asprintf(&b, f, fieldwidth, func); \ else if (precision) \ - (void)printf(f, precision, func); \ + (void)asprintf(&b, f, precision, func); \ else \ - (void)printf(f, func); \ + (void)asprintf(&b, f, func); \ + if (b) { \ + (void)fputs(b, stdout); \ + free(b); \ + } \ } static int asciicode __P((void)); |