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.
This commit is contained in:
mischief 2013-11-06 11:22:15 -08:00
parent 7b36a7e1a9
commit 61269254d0

View file

@ -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