Bug (?) in sprintf family?

Brian Dessent brian@dessent.net
Mon Apr 7 23:39:00 GMT 2008

"Jonathan S. Shapiro" wrote:

> Heck, vsnprintf doesn't have a FILE* to work with, so there isn't any
> fd, so I'm not entirely sure what these routines could possibly be
> getting called *on* in this case. The program makes no other use of
> stdio.

The snprintf family of functions are all implemented in terms of
_vfprintf_r, by constructing a pseudo FILE * to represent the string
buffer whose _flags indicate that it's really a string buffer (__SSTR)
and not a file stream.  This allows for there to be one implementation
of the actual formatted output code instead of having to duplicate it,
so the coupling is deliberate.

I would think that things like calls to isatty() would be guarded by
!(_flags & __SSTR) but in any case if you just stub out everything
needed to link and the string output ones ought to still work.


More information about the Newlib mailing list