diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-07-09 01:01:37 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-07-09 04:40:16 +0400 |
commit | 2fc78e700cc4684c1e5899d7a4a619da1e3e3679 (patch) | |
tree | d279604bbf713973972fccb3f4ce0db97ac97676 /src/unix | |
parent | d483a911b89eaecb3af603efe2dceeb402cbf3ae (diff) |
posix: Portable `vsnprintf`
Our good, lovely folks at Microsoft decided that there was no good
reason to make `vsnprintf` compilant with the C standard, so that
function in Windows returns -1 on overflow, instead of returning the
actual byte count needed to write the full string.
We now handle this situation more gracefully with the POSIX
compatibility layer, by returning the needed byte size using an
auxiliary method instead of blindly resizing the target buffer until it
fits.
This means we can now support `printf`s of any size by allocating a
temporary buffer. That's good.
Diffstat (limited to 'src/unix')
-rw-r--r-- | src/unix/posix.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/unix/posix.h b/src/unix/posix.h index d52aa095c..16daf15bd 100644 --- a/src/unix/posix.h +++ b/src/unix/posix.h @@ -12,5 +12,6 @@ #define p_fsync(fd) fsync(fd) #define p_realpath(p, po) realpath(p, po) #define p_fnmatch(p, s, f) fnmatch(p, s, f) +#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) #endif |