diff options
| author | Tyge Løvset <[email protected]> | 2022-10-05 09:16:29 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-10-05 09:16:29 +0200 |
| commit | 905fe02e9c258c8ac8d7aebb439c7039f7109cb1 (patch) | |
| tree | 042b732719e22b2be44c166ac96d82dfbf31810f /include | |
| parent | 5daba7ad2291dd7f02299eabeb650d0d0b77a1a6 (diff) | |
| download | STC-modified-905fe02e9c258c8ac8d7aebb439c7039f7109cb1.tar.gz STC-modified-905fe02e9c258c8ac8d7aebb439c7039f7109cb1.zip | |
Internals.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/ccommon.h | 7 | ||||
| -rw-r--r-- | include/stc/views.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index c93c41b9..0e5b3b22 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -197,9 +197,10 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, ; C##_next(&_.it)) #define c_forloop(...) c_MACRO_OVERLOAD(c_forloop, __VA_ARGS__) -#define c_forloop1(stop) for (long long _i=0, _end=stop; _i < _end; ++_i) -#define c_forloop2(i, stop) c_forloop4(i, 0, stop, 1) -#define c_forloop3(i, start, stop) c_forloop4(i, start, stop, 1) +#define c_forloop1(stop) c_forloop3(_i, 0, stop) +#define c_forloop2(i, stop) c_forloop3(i, 0, stop) +#define c_forloop3(i, start, stop) \ + for (long long i=start, _end=stop; i < _end; ++i) #define c_forloop4(i, start, stop, step) \ for (long long i=start, _inc=step, _end=(stop) - (_inc > 0) \ ; (_inc > 0) ^ (i > _end); i += _inc) diff --git a/include/stc/views.h b/include/stc/views.h index d4186caf..31aaba0d 100644 --- a/include/stc/views.h +++ b/include/stc/views.h @@ -87,7 +87,7 @@ struct stc_nostruct #define crange_MAX INT64_MAX typedef long long crange_value; -typedef struct { crange_value start, end, step, val; } crange; +typedef struct { crange_value start, end, step, value; } crange; typedef struct { crange_value *ref, end, step; } crange_iter; #define crange_init(...) c_MACRO_OVERLOAD(crange_init, __VA_ARGS__) @@ -98,7 +98,7 @@ STC_INLINE crange crange_init3(crange_value start, crange_value stop, crange_val { crange r = {start, stop - (step > 0), step}; return r; } STC_INLINE crange_iter crange_begin(crange* self) - { self->val = self->start; crange_iter it = {&self->val, self->end, self->step}; return it; } + { self->value = self->start; crange_iter it = {&self->value, self->end, self->step}; return it; } STC_INLINE crange_iter crange_end(crange* self) { crange_iter it = {NULL}; return it; } |
