diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-03-20 18:54:18 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-03-20 19:01:19 +0100 |
commit | 3785fc5ea7f47849ae11764b5cca5c220bc3866d (patch) | |
tree | 759574d38f69b035a3e002d94159e677d2516022 | |
parent | 595462580d0eb1561f2497762fb55407c5ddf404 (diff) | |
download | blogc-3785fc5ea7f47849ae11764b5cca5c220bc3866d.tar.gz blogc-3785fc5ea7f47849ae11764b5cca5c220bc3866d.tar.bz2 blogc-3785fc5ea7f47849ae11764b5cca5c220bc3866d.zip |
make: avoid infinite-loop if posts_per_page <= 0
-rw-r--r-- | man/blogc-make.1.ronn | 3 | ||||
-rw-r--r-- | src/blogc-make/rules.c | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/man/blogc-make.1.ronn b/man/blogc-make.1.ronn index 6d5552b..ca9c4da 100644 --- a/man/blogc-make.1.ronn +++ b/man/blogc-make.1.ronn @@ -89,7 +89,8 @@ The rule passes the following helper variables to blogc(1): ### pagination -Build pagination pages from posts. +Build pagination pages from posts. This rule will be disabled if +`posts_per_page` is negative or `0` in blogcfile(5). The rule passes the following helper variables to blogc(1): diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c index d8614b6..79d722a 100644 --- a/src/blogc-make/rules.c +++ b/src/blogc-make/rules.c @@ -228,6 +228,9 @@ pagination_outputlist(bm_ctx_t *ctx) long posts_per_page = strtol( bc_trie_lookup(ctx->settings->settings, "posts_per_page"), NULL, 10); // FIXME: improve + if (posts_per_page <= 0) + return NULL; + size_t pages = ceilf(((float) num_posts) / posts_per_page); const char *pagination_prefix = bc_trie_lookup(ctx->settings->settings, |