This commit is contained in:
snarmph 2026-07-06 11:30:24 +02:00
parent 144312744c
commit c10a3decd0
2 changed files with 33 additions and 15 deletions

44
colla.h
View file

@ -324,6 +324,8 @@ for_each (chunk, arr) {
(arr)->items[(arr)->count++] = (item); \
} while (0)
#define darr_pop(arr) if ((arr) && (arr)->count) --(arr)->count
// STRING TYPES /////////////////////////////////
#define STR_NONE SIZE_MAX
@ -487,6 +489,7 @@ usize strv_rfind_view(strview_t ctx, strview_t view, usize from_right);
bool char_is_space(char c);
bool char_is_alpha(char c);
bool char_is_num(char c);
bool char_is_hex(char c);
char char_lower(char c);
char char_upper(char c);
@ -603,23 +606,23 @@ bool ibstr_get_i16(ibstream_t *ib, i16 *out);
bool ibstr_get_i32(ibstream_t *ib, i32 *out);
bool ibstr_get_i64(ibstream_t *ib, i64 *out);
// SIMPLE REGEX /////////////////////////////////
// REGEX ////////////////////////////////////////
// only supports *, every star matches until the following character
// is found, e.g.
// ab*e
// abcde
// matches (cd)
// typedef struct rg_result_t rg_result_t;
// struct rg_result_t {
// strview_t text;
// i64 offset;
// };
//
// typedef struct rg_match_t rg_match_t;
// struct rg_match_t {
// rg_result_t matches[COLLA_RG_MAX_MATCHES];
// int count;
// bool found_match;
// };
typedef struct rg_match_t rg_match_t;
struct rg_match_t {
strview_t text[COLLA_RG_MAX_MATCHES];
int count;
bool matches;
};
rg_match_t rg_match(strview_t rg, strview_t text);
bool rg_match_easy(strview_t rg, strview_t text);
bool rg_matches(strview_t rg, strview_t text);
bool glob_matches(strview_t glob, strview_t text);
/////////////////////////////////////////////////
@ -725,6 +728,7 @@ void os_abort(int code);
iptr os_get_last_error(void);
// NOT thread safe
str_t os_get_error_string(iptr error);
str_t os_get_last_error_string(void);
// == HANDLE ====================================
@ -824,6 +828,12 @@ oshandle_t os_stdin(void);
// windows specific
oshandle_t os_win_conout(void);
oshandle_t os_win_conin(void);
oshandle_t os_win_regopen(arena_t scratch, strview_t name);
void os_win_regclose(oshandle_t key);
str_t os_win_regread_str(arena_t *arena, oshandle_t key, strview_t value);
i64 os_win_regread_int(arena_t scratch, oshandle_t key, strview_t value);
str_t os_win_regkey_str(arena_t *arena, strview_t key, strview_t value);
#define print(...) fmt_print(__VA_ARGS__)
#define println(...) os_log_print(__FILE__, __LINE__, LOG_BASIC, __VA_ARGS__)
@ -921,6 +931,7 @@ typedef strv_list_t os_cmd_t;
typedef struct os_cmd_options_t os_cmd_options_t;
struct os_cmd_options_t {
os_env_t *env;
bool quiet;
// redirected if !NULL
oshandle_t *error;
oshandle_t *out;
@ -1035,6 +1046,8 @@ job_t *jq_pop_job(job_queue_t *queue);
// == ATOMICS ========================================
#if !COLLA_NO_ATOMICS
i64 atomic_set_i64(i64 *dest, i64 val);
i64 atomic_add_i64(i64 *dest, i64 val);
i64 atomic_and_i64(i64 *dest, i64 val);
@ -1044,6 +1057,7 @@ i64 atomic_inc_i64(i64 *dest);
i64 atomic_dec_i64(i64 *dest);
i64 atomic_or_i64(i64 *dest, i64 val);
i64 atomic_xor_i64(i64 *dest, i64 val);
#endif
// PARSERS //////////////////////////////////////