[utils] Adding index to cstring_array_foreach, similar to Python's enumerate
This commit is contained in:
@@ -162,8 +162,9 @@ int64_t cstring_array_token_length(cstring_array *self, uint32_t i);
|
|||||||
|
|
||||||
void cstring_array_destroy(cstring_array *self);
|
void cstring_array_destroy(cstring_array *self);
|
||||||
|
|
||||||
#define cstring_array_foreach(array, s, code) { \
|
#define cstring_array_foreach(array, i, s, code) { \
|
||||||
for (int __si = 0; __si < array->indices->n; __si++) { \
|
for (int __si = 0; __si < array->indices->n; __si++) { \
|
||||||
|
(i) = __si; \
|
||||||
(s) = array->str->a + array->indices->a[__si]; \
|
(s) = array->str->a + array->indices->a[__si]; \
|
||||||
code; \
|
code; \
|
||||||
} \
|
} \
|
||||||
|
|||||||
Reference in New Issue
Block a user