mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-13 07:52:22 -07:00
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:
+2
-1
@@ -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
@@ -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
Reference in New Issue
Block a user