libc: add actual sprintf to sprintf.c

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Tue, 12 May 2026 10:19:57 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 7ab521cba681f16fdf6112929e4b3c6ed3185ad0
Author: Skye <[email protected]>
Date:   Fri May 1 12:30:31 2026 +0900

    libc: add actual sprintf to sprintf.c
    
    Change-Id: Iba19b587781da3191c7674a6a141c0c4fbf8b344

diff --git a/firmware/libc/sprintf.c b/firmware/libc/sprintf.c
index a56f454c34..a78b5ed665 100644
--- a/firmware/libc/sprintf.c
+++ b/firmware/libc/sprintf.c
@@ -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;
+}
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs