From 7e7c371b9e1f35c1cab530cf1c6b49781fb105e8 Mon Sep 17 00:00:00 2001 From: alessandro bason Date: Wed, 1 Oct 2025 16:58:04 +0200 Subject: [PATCH] . --- colla.c | 12 ++++++++++++ colla.h | 10 ++++++++++ colla_win32.c | 8 ++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/colla.c b/colla.c index 0476367..6835d35 100644 --- a/colla.c +++ b/colla.c @@ -693,6 +693,18 @@ bool istr_get_num(instream_t *ctx, double *val) { return true; } +bool istr_get_float(instream_t *ctx, float *val) { + double v = 0; + if (!istr_get_num(ctx, &v)) { + return false; + } + if (v >= HUGE_VALF || v <= -HUGE_VALF) { + return false; + } + *val = (float)v; + return true; +} + strview_t istr_get_view(instream_t *ctx, char delim) { if (!ctx || !ctx->cur) return STRV_EMPTY; const char *from = ctx->cur; diff --git a/colla.h b/colla.h index e0a6c30..53a4d98 100644 --- a/colla.h +++ b/colla.h @@ -9,6 +9,15 @@ #include #include +// LIBC FUNCTIONS /////////////////////////////// + +extern void *memcpy(void *dst, const void *src, size_t size); +extern void *memmove(void *dst, const void *src, size_t size); + +#define static_assert(cond, ...) _Static_assert(cond, "" __VA_ARGS__) + +///////////////////////////////////////////////// + // CORE MODULES ///////////////////////////////// typedef enum { @@ -515,6 +524,7 @@ bool istr_get_i16(instream_t *ctx, i16 *val); bool istr_get_i32(instream_t *ctx, i32 *val); bool istr_get_i64(instream_t *ctx, i64 *val); bool istr_get_num(instream_t *ctx, double *val); +bool istr_get_float(instream_t *ctx, float *val); strview_t istr_get_view(instream_t *ctx, char delim); strview_t istr_get_view_either(instream_t *ctx, strview_t chars); strview_t istr_get_view_len(instream_t *ctx, usize len); diff --git a/colla_win32.c b/colla_win32.c index 0701b3a..e24523f 100644 --- a/colla_win32.c +++ b/colla_win32.c @@ -280,14 +280,14 @@ arena_t scratch = arena_make(ARENA_STATIC, sizeof(tmpbuf), tmpbuf) DWORD os__win_mode_to_access(filemode_e mode) { DWORD out = 0; - if (mode & FILEMODE_READ) out |= GENERIC_READ; - if (mode & FILEMODE_WRITE) out |= GENERIC_WRITE; + if (mode & OS_FILE_READ) out |= GENERIC_READ; + if (mode & OS_FILE_WRITE) out |= GENERIC_WRITE; return out; } DWORD os__win_mode_to_creation(filemode_e mode) { - if (mode == FILEMODE_READ) return OPEN_EXISTING; - if (mode == FILEMODE_WRITE) return CREATE_ALWAYS; + if (mode == OS_FILE_READ) return OPEN_EXISTING; + if (mode == OS_FILE_WRITE) return CREATE_ALWAYS; return OPEN_ALWAYS; }