From 4343af3ad34b71adf668d8e7e68d8d45a04f9f87 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 20 Jun 2022 00:08:18 +0200 Subject: Small addition and warning removed in cregex.c. Else refactoring/cleanup. --- include/stc/ccommon.h | 11 +++-------- include/stc/crandom.h | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 9c00255a..3a6d8f4e 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -203,8 +203,8 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, #define c_apply(v, action, T, ...) do { \ typedef T _c_T; \ - const _c_T _c_arr[] = __VA_ARGS__, *v = _c_arr, \ - *_c_end = v + c_arraylen(_c_arr); \ + _c_T _c_arr[] = __VA_ARGS__, *v = _c_arr; \ + const _c_T *_c_end = v + c_arraylen(_c_arr); \ while (v != _c_end) { action; ++v; } \ } while (0) @@ -215,6 +215,7 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, } while (0) #define c_pair(v) (v)->first, (v)->second +#define c_drop(C, ...) c_apply(_p, C##_drop(*_p), C*, {__VA_ARGS__}) #define c_find_if(C, cnt, it, pred) \ c_find_in(C, C##_begin(&cnt), C##_end(&cnt), it, pred) @@ -229,12 +230,6 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, if (it.ref == _end.ref) it.ref = NULL; \ } while (0) -#define c_drop(C, ...) do { \ - C* _c_arr[] = {__VA_ARGS__}; \ - for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \ - C##_drop(_c_arr[_c_i]); \ -} while (0) - #if defined(__SIZEOF_INT128__) #define c_umul128(a, b, lo, hi) \ do { __uint128_t _z = (__uint128_t)(a)*(b); \ diff --git a/include/stc/crandom.h b/include/stc/crandom.h index 1b94fd66..e99be1ca 100644 --- a/include/stc/crandom.h +++ b/include/stc/crandom.h @@ -191,4 +191,4 @@ STC_DEF double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist) { #undef i_static #undef i_header #undef i_implement -#undef i_extern \ No newline at end of file +#undef i_extern -- cgit v1.2.3