From 803eb202e9d2d96fbb0de6f0514db2f0ab959d11 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 25 Jul 2017 19:46:14 +0200 Subject: loader: added FILTER_REVERSE --- src/blogc/loader.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/blogc/loader.c b/src/blogc/loader.c index a9a660e..881661b 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -103,6 +103,17 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) if (err == NULL || *err != NULL) return NULL; + bool reverse = bc_trie_lookup(conf, "FILTER_REVERSE"); + bc_slist_t* sources = NULL; + for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) { + if (reverse) { + sources = bc_slist_prepend(sources, tmp->data); + } + else { + sources = bc_slist_append(sources, tmp->data); + } + } + bc_error_t *tmp_err = NULL; bc_slist_t *rv = NULL; unsigned int with_date = 0; @@ -135,7 +146,7 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) unsigned int end = start + per_page; unsigned int counter = 0; - for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) { + for (bc_slist_t *tmp = sources; tmp != NULL; tmp = tmp->next) { char *f = tmp->data; bc_trie_t *s = blogc_source_parse_from_file(f, &tmp_err); if (s == NULL) { @@ -182,6 +193,8 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) rv = bc_slist_append(rv, s); } + bc_slist_free(sources); + if (with_date > 0 && with_date < bc_slist_length(rv)) { *err = bc_error_new_printf(BLOGC_ERROR_LOADER, "'DATE' variable provided for at least one source file, but not " -- cgit v1.2.3-18-g5258