j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: laurent Date: 2009-11-22 10:50:54 +0100 (Sun, 22 Nov 2009) New Revision: 628
Modified: trunk/openbios-devel/include/libc/vsprintf.h trunk/openbios-devel/libc/extra.c Log: Add a function forth_printf() which prints to openbios stdout.
Signed-off-by: Laurent Vivier Laurent@vivier.eu
Modified: trunk/openbios-devel/include/libc/vsprintf.h =================================================================== --- trunk/openbios-devel/include/libc/vsprintf.h 2009-11-22 09:47:08 UTC (rev 627) +++ trunk/openbios-devel/include/libc/vsprintf.h 2009-11-22 09:50:54 UTC (rev 628) @@ -25,4 +25,6 @@ extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); extern int snprintf(char * buf, size_t size, const char *fmt, ...);
+extern int forth_printf( const char *fmt, ... ); + #endif /* _H_VSPRINTF */
Modified: trunk/openbios-devel/libc/extra.c =================================================================== --- trunk/openbios-devel/libc/extra.c 2009-11-22 09:47:08 UTC (rev 627) +++ trunk/openbios-devel/libc/extra.c 2009-11-22 09:50:54 UTC (rev 628) @@ -16,6 +16,8 @@
#include "openbios/config.h" #include "libc/string.h" +#include "libc/vsprintf.h" +#include "openbios/bindings.h"
/* strncpy without 0-pad */ char * @@ -24,3 +26,24 @@ int len = MIN( n, strlen(src)+1 ); return memcpy( dest, src, len ); } + +/* printf */ + +int forth_printf( const char *fmt, ... ) +{ + char buf[512]; + va_list args; + int i; + + va_start(args, fmt); + i = vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + + PUSH((ucell)buf); + PUSH(i); + fword("type"); + + return i; +} + +