aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-08-09 22:35:08 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-08-09 22:35:08 +0530
commit1197c736a0cc8551974a5dfbef1a114007f9c046 (patch)
tree83bb601f1523c5535b2fc4c4d11c52324dddb6e6 /src
parent2b600657c0770b155c3af9a36e5526fa0a450d00 (diff)
engine: eachdo: add priority to atom
Diffstat (limited to 'src')
-rw-r--r--src/engine/eachdo.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/engine/eachdo.c b/src/engine/eachdo.c
index 9a1afca..d0ccd1e 100644
--- a/src/engine/eachdo.c
+++ b/src/engine/eachdo.c
@@ -43,9 +43,11 @@ static void
write_eachdo_iteration(list_t *atoms,
list_t *directives,
list_t *keys,
- list_t *values)
+ list_t *values,
+ size_t priority)
{
atom_t *atom = malloc(sizeof(atom_t));
+ atom->priority = priority;
atom->content = calloc(1, sizeof(char));
for (size_t i = 0; i < directives->size; i++) {
@@ -125,7 +127,15 @@ handle_file_source(list_t *atoms,
config_t *config = config_fetch_and_parse(path);
- write_eachdo_iteration(atoms, directives, config->keys, config->values);
+ size_t priority = 0;
+ char *priority_string
+ = unwrap(list_find_corresponding_value_from_ptr_wrapper(
+ config->keys, config->values, "priority"));
+ if (priority_string != NULL)
+ priority = atoll(priority_string);
+
+ write_eachdo_iteration(
+ atoms, directives, config->keys, config->values, priority);
config_delete(config);
free(file_path);
@@ -167,6 +177,9 @@ handle_eachdo(char **buffer, key_match_t *match, directive_t *directive)
for (size_t i = 0; i < atoms->size; i++) {
atom_t *atom = list_get(atoms, i);
content = realloc(content, strlen(content) + strlen(atom->content) + 1);
+#ifdef DEBUG
+ printf("PRIORITY: %lu\n", atom->priority);
+#endif
strcat(content, atom->content);
}