In message <199807052032(_dot_)QAA13583(_at_)bobbi-harlow(_dot_)mit(_dot_)edu>,
Dan Winship writes:
I wasn't on nmh-workers in May, so I didn't see that one... is this
any better?
/*
* Portable working snprintf().
* Created by Sal Valente <svalente(_at_)mit(_dot_)edu> 11/29/97
* Public domain.
*
* Wow, this is a bad idea.
* snprintf() should be implemented as part of stdio, not on top of it.
* Oh well, at least this works and it's secure.
*
* Idea: Write all the data into a pipe, then read as much as can
* fit from the pipe into the buffer.
I question "working" above...
This code will *deadlock* whenever the result of the vfprintf (i.e. the
formatted output) is larger than the maximum amount of data in a pipe. On many
OSes, this limit is still 4096 bytes, not impossible to imagine.
--
Harald Koch <chk(_at_)utcc(_dot_)utoronto(_dot_)ca>