Support printf %n directive

This commit is contained in:
Justine Tunney 2024-07-28 22:27:06 -07:00
parent c1a0b017e9
commit 01b09bc817
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
8 changed files with 21 additions and 8 deletions

View file

@ -87,7 +87,7 @@ int vfprintf_unlocked(FILE *f, const char *fmt, va_list va) {
st.f = f;
st.n = 0;
st.b.n = 0;
if ((rc = __fmt(out, &st, fmt, va)) != -1) {
if ((rc = __fmt(out, &st, fmt, va, &st.n)) != -1) {
if (!st.b.n) {
rc = st.n;
} else if (fwrite_unlocked(st.b.p, 1, st.b.n, st.f)) {