diff options
| author | Tyge Løvset <[email protected]> | 2022-09-23 11:15:16 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-23 11:15:16 +0200 |
| commit | d3b7d6febef6d0ae588ac4b176a735d7bc522942 (patch) | |
| tree | 7ea145e92a8abbf9c97d69d9a66005b1d79b3b50 | |
| parent | 34bec4fdf406caff8492d53f0afc80df5d75bba4 (diff) | |
| download | STC-modified-d3b7d6febef6d0ae588ac4b176a735d7bc522942.tar.gz STC-modified-d3b7d6febef6d0ae588ac4b176a735d7bc522942.zip | |
Renamed c_forloop* macros to more descriptive c_forwhile*.
| -rw-r--r-- | examples/list.c | 4 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/list.c b/examples/list.c index 2f5fa964..1f21304f 100644 --- a/examples/list.c +++ b/examples/list.c @@ -25,14 +25,14 @@ int main() { sum += *i.ref; printf("sum %f\n\n", sum); - c_forloop (i, clist_fx, list, i.index < 10) + c_forwhile (i, clist_fx, list, i.index < 10) printf("%8d: %10f\n", (int)i.index, *i.ref); puts("sort"); clist_fx_sort(&list); // mergesort O(n*log n) puts("sorted"); - c_forloop (i, clist_fx, list, i.index < 10) + c_forwhile (i, clist_fx, list, i.index < 10) printf("%8d: %10f\n", (int)i.index, *i.ref); puts(""); diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index d01254a6..59056905 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -176,11 +176,11 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, #define c_forfilter5(it, C, cnt, filter, cond) \ c_forfilter_s(it, C, C##_begin(&cnt), filter, cond) #define c_forfilter_s(it, C, start, filter, cond) \ - c_forloop_s(it, C, start, cond) if (!((filter) && ++it.count)) ; else + c_forwhile_s(it, C, start, cond) if (!((filter) && ++it.count)) ; else -#define c_forloop(i, C, cnt, cond) \ - c_forloop_s(i, C, C##_begin(&cnt), cond) -#define c_forloop_s(i, C, start, cond) \ +#define c_forwhile(i, C, cnt, cond) \ + c_forwhile_s(i, C, C##_begin(&cnt), cond) +#define c_forwhile_s(i, C, start, cond) \ for (struct {C##_iter it; const C##_value *ref; size_t index, count;} \ i = {.it=start, .ref=i.it.ref}; i.ref && (cond) \ ; C##_next(&i.it), i.ref = i.it.ref, ++i.index) |
