add modified version of stb_sprintf to library; use it instead of CRT; first-pass on %S for MD_String8

This commit is contained in:
ryanfleury
2021-06-30 12:36:05 -06:00
parent 7f730b0b0b
commit d0717e3b5f
3 changed files with 1915 additions and 3 deletions
+2 -1
View File
@@ -202,6 +202,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#define STB_SPRINTF_DECORATE(name) md_stbsp_##name
#include "md_stb_sprintf.h"
typedef int8_t MD_i8;
typedef int16_t MD_i16;
@@ -218,7 +220,6 @@ typedef int64_t MD_b64;
typedef float MD_f32;
typedef double MD_f64;
//~ Basic Unicode string types.
typedef struct MD_String8 MD_String8;
+6 -2
View File
@@ -4,6 +4,10 @@
#define MD_PRIVATE_FUNCTION_IMPL MD_FUNCTION_IMPL
#define MD_UNTERMINATED_TOKEN_LEN_CAP 20
#define STB_SPRINTF_IMPLEMENTATION
#define STB_SPRINTF_DECORATE(name) md_stbsp_##name
#include "md_stb_sprintf.h"
//~ Nil Node Definition
static MD_Node _md_nil_node =
@@ -305,10 +309,10 @@ MD_PushStringFV(char *fmt, va_list args)
MD_String8 result = MD_ZERO_STRUCT;
va_list args2;
va_copy(args2, args);
MD_u64 needed_bytes = vsnprintf(0, 0, fmt, args)+1;
MD_u64 needed_bytes = md_stbsp_vsnprintf(0, 0, fmt, args)+1;
result.str = MD_PushArray(MD_u8, needed_bytes);
result.size = needed_bytes - 1;
vsnprintf((char*)result.str, needed_bytes, fmt, args2);
md_stbsp_vsnprintf((char*)result.str, needed_bytes, fmt, args2);
return result;
}
File diff suppressed because it is too large Load Diff