libc: add actual sprintf to sprintf.c

Change-Id: Iba19b587781da3191c7674a6a141c0c4fbf8b344
This commit is contained in:
Skye 2026-05-01 12:30:31 +09:00
parent 25551180ba
commit 7ab521cba6

View file

@ -109,3 +109,21 @@ overflow:
errno = EOVERFLOW;
return -1;
}
int sprintf(char *buf, const char *fmt, ...)
{
int bytes;
struct for_snprintf pr;
va_list ap;
pr.ptr = buf;
pr.rem = INT_MAX;
va_start(ap, fmt);
bytes = vuprintf(sprfunc, &pr, fmt, ap);
va_end(ap);
*pr.ptr = '\0';
return bytes;
}