mirror of /home/gitosis/repositories/libowfat.git

4 changed files with 35 additions and 0 deletions
@ -0,0 +1,17 @@
|
||||
#include <stdarg.h> |
||||
#include "fmt.h" |
||||
|
||||
size_t fmt_strm_internal(char* dest, ...) { |
||||
size_t n; |
||||
va_list a; |
||||
const char* s; |
||||
va_start(a,dest); |
||||
for (n=0; s=va_arg(a,const char*); ) { |
||||
size_t inc=fmt_str(dest,s); |
||||
if (n+inc<n) return (size_t)-1; |
||||
if (dest) dest+=inc; |
||||
n+=inc; |
||||
} |
||||
va_end(a); |
||||
return n; |
||||
} |
@ -0,0 +1,14 @@
|
||||
#include <fmt.h> |
||||
#include <string.h> |
||||
#include <assert.h> |
||||
|
||||
int main() { |
||||
char buf[100]; |
||||
buf[5]='x'; |
||||
assert(fmt_str(buf,"fnord")==5); |
||||
assert(buf[5]=='x'); |
||||
buf[5]=0; |
||||
assert(!strcmp(buf,"fnord")); |
||||
assert(fmt_strm(buf,"Fn","0rd")==5); |
||||
assert(!strcmp(buf,"Fn0rd")); |
||||
} |
Loading…
Reference in new issue