diff options
author | mischief <mischief@offblast.org> | 2013-11-06 11:22:15 -0800 |
---|---|---|
committer | mischief <mischief@offblast.org> | 2013-11-06 11:22:15 -0800 |
commit | 61269254d0d5cc8e8e425cfb47774ec830dec2a3 (patch) | |
tree | 099a059991dd1c69f4414d93fee3bba7e6f6951e /sys/src/ape | |
parent | 7b36a7e1a9056bc8046d161c81aee008854daadf (diff) |
synchronize ape's vfprintf with libstdio
in ape's vfprintf we don't check if the file we're writing is actually a string buffer, resulting in a return of -1, when we should actually return the number of bytes that would be written.
Diffstat (limited to 'sys/src/ape')
-rw-r--r-- | sys/src/ape/lib/ap/stdio/vfprintf.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/src/ape/lib/ap/stdio/vfprintf.c b/sys/src/ape/lib/ap/stdio/vfprintf.c index dc8c406ff..2df322421 100644 --- a/sys/src/ape/lib/ap/stdio/vfprintf.c +++ b/sys/src/ape/lib/ap/stdio/vfprintf.c @@ -202,7 +202,15 @@ vfprintf(FILE *f, const char *s, va_list args) nprint++; } } - return ferror(f)? -1: nprint;; + + if(ferror(f)){ + if((f->flags&STRING) && f->wp==f->rp && f->wp>f->buf){ + *(f->wp-1) = '\0'; + return nprint; + } + return -1; + } + return nprint; } static int |