summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--examples/list.c4
-rw-r--r--include/stc/ccommon.h8
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)