diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-08-09 14:12:30 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-08-09 14:12:30 +0530 |
commit | d04fb041acf6aee5cc19dff8b96e118374536700 (patch) | |
tree | 769837e3a3a3cf44456c532acd8ea52f6bd2a992 /src | |
parent | 62bb2c16156898be63d3a337e4369d5523ce1463 (diff) |
engine: eachdo: append one content for each iteration
This will be required in the future when priorities are added.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/eachdo.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/engine/eachdo.c b/src/engine/eachdo.c index 91a6d3f..1cdd92b 100644 --- a/src/engine/eachdo.c +++ b/src/engine/eachdo.c @@ -45,15 +45,15 @@ write_eachdo_iteration(list_t *atoms, list_t *keys, list_t *values) { + char *content = calloc(1, sizeof(char)); + for (size_t i = 0; i < directives->size; i++) { directive_t *_directive = list_get(directives, i); switch (_directive->type) { case _RAW: { - /* *content = realloc(*content, - strlen(*content) + strlen(_directive->operands) + 1); - strcat(*content, _directive->operands); */ - - list_wrap_and_add(atoms, strdup(_directive->operands)); + content = realloc(content, + strlen(content) + strlen(_directive->operands) + 1); + strcat(content, _directive->operands); break; } @@ -62,10 +62,8 @@ write_eachdo_iteration(list_t *atoms, keys, values, trim(_directive->operands))); if (key != NULL) { - /* *content = realloc(*content, strlen(*content) + strlen(key) + 1); - strcat(*content, key); */ - - list_wrap_and_add(atoms, strdup(key)); + content = realloc(content, strlen(content) + strlen(key) + 1); + strcat(content, key); } break; @@ -76,6 +74,8 @@ write_eachdo_iteration(list_t *atoms, break; } } + + list_wrap_and_add(atoms, content); } /* |