.
This commit is contained in:
parent
61c1060a98
commit
7e7c371b9e
3 changed files with 26 additions and 4 deletions
12
colla.c
12
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;
|
||||
|
|
|
|||
10
colla.h
10
colla.h
|
|
@ -9,6 +9,15 @@
|
|||
#include <stdarg.h>
|
||||
#include <uchar.h>
|
||||
|
||||
// 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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue