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)
This commit is contained in:
parent
3e19bb8220
commit
d72f654c65
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user