From da3fceb19f1a6f6db17c962829e46eb8283ef5cb Mon Sep 17 00:00:00 2001 From: krzosa Date: Fri, 3 Jan 2025 09:09:26 +0100 Subject: [PATCH] os_parse_float --- src/core/core_platform.h | 17 ----------------- src/core/core_platform_unix.c | 4 ++++ src/core/core_platform_wasm.c | 3 +-- src/core/core_platform_win32.c | 4 ++++ src/core/core_string.c | 2 +- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/core/core_platform.h b/src/core/core_platform.h index 2527812..3fc4fd8 100644 --- a/src/core/core_platform.h +++ b/src/core/core_platform.h @@ -9,23 +9,6 @@ struct date_t { u16 year; }; -#if 0 -typedef struct core_funcs_t core_funcs_t; -struct core_funcs_t { - void (*error_box)(char *str); - void (*console_log)(char *str); - - date_t (*date_now)(void); - f64 (*milliseconds_now)(void); - - void *(*reserve)(usize size); - b32 (*commit)(void *p, usize size); - b32 (*release)(void *p); - b32 (*decommit)(void *p, usize size); -}; -#endif - - fn void os_error_box(char *str); fn void os_console_log(char *str); fn date_t os_date_now(void); diff --git a/src/core/core_platform_unix.c b/src/core/core_platform_unix.c index 7c30b68..2bdbcc3 100644 --- a/src/core/core_platform_unix.c +++ b/src/core/core_platform_unix.c @@ -53,5 +53,9 @@ fn void os_console_log(char *str) { puts(str); } +fn f64 os_parse_float(char *str) { + return strtod(str, NULL); +} + fn void core_init(void) { } \ No newline at end of file diff --git a/src/core/core_platform_wasm.c b/src/core/core_platform_wasm.c index 09948cc..974478c 100644 --- a/src/core/core_platform_wasm.c +++ b/src/core/core_platform_wasm.c @@ -34,8 +34,7 @@ fn void os_console_log(char *str) { wasm_write_to_console((isize)str, str_len(str)); } -fn double strtod(const char *str, char **end_unused) { - assert(end_unused == NULL); +fn f64 os_parse_float(char *str) { return wasm_parse_float((isize)str, str_len((char *)str)); } diff --git a/src/core/core_platform_win32.c b/src/core/core_platform_win32.c index 8a2b60b..ddfdaca 100644 --- a/src/core/core_platform_win32.c +++ b/src/core/core_platform_win32.c @@ -62,5 +62,9 @@ fn void os_console_log(char *str) { puts(str); } +fn f64 os_parse_float(char *str) { + return strtod(str, NULL); +} + fn void core_init(void) { } \ No newline at end of file diff --git a/src/core/core_string.c b/src/core/core_string.c index 19bf75c..73f7af4 100644 --- a/src/core/core_string.c +++ b/src/core/core_string.c @@ -483,7 +483,7 @@ fn u64 u64_from_s8(s8_t s, u64 base) { fn f64 f64_from_s8(s8_t string) { ma_temp_t scratch = ma_begin_scratch(); s8_t num_string = s8_copy(scratch.arena, string); - f64 result = strtod(num_string.str, NULL); + f64 result = os_parse_float(num_string.str); ma_end_scratch(scratch); return result; } \ No newline at end of file