medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 52ea14acaae25db2bbacfe22084f665a3b003677
parent 152203c826a183639ea2a3dc1e7983cf291dc6f5
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Oct  8 12:24:38 +0300

Add va_list methods to str

Diffstat:
str.h | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/str.h b/str.h @@ -53,19 +53,27 @@ public: } // TODO: implement our own vsnprintf with support for vectors etc + void sprintf( const char * fmt, va_list argp ) { + size_t copied = vsnprintf( buf, N, fmt, argp ); + length = min( copied, N - 1 ); + } + void sprintf( const char * fmt, ... ) { va_list argp; va_start( argp, fmt ); - size_t copied = vsnprintf( buf, N, fmt, argp ); - length = min( copied, N - 1 ); + sprintf( fmt, argp ); va_end( argp ); } + void appendf( const char * fmt, va_list argp ) { + size_t copied = vsnprintf( buf + length, N - length, fmt, argp ); + length += min( copied, N - length - 1 ); + } + void appendf( const char * fmt, ... ) { va_list argp; va_start( argp, fmt ); - size_t copied = vsnprintf( buf + length, N - length, fmt, argp ); - length += min( copied, N - length - 1 ); + appendf( argp, fmt ); va_end( argp ); }