summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/ccommon.h7
-rw-r--r--include/stc/views.h4
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; }