HomeFreeBSD

printf: Output formatted data directly, instead of via asprintf.

Description

printf: Output formatted data directly, instead of via asprintf.

Long ago, sh used to have its own optimized and restricted string formatting
implementation, which the printf builtin had to bypass via asprintf() to a
temporary buffer. Since sh has used libc's string formatting implementation
for a long time, remove the workaround.

Add a check to keep printf %c '' working the same way (output nothing);
POSIX allows both outputting nothing and outputting a NUL byte.

Also, this change avoids silently discarding format directives for whose
output asprintf() cannot allocate memory.

Details

Provenance
jillesAuthored on
Parents
rS317597: Allow SCTP to use the hostcache.
Branches
Unknown
Tags
Unknown