diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-07-24 02:27:48 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-07-24 02:27:51 +0200 |
commit | c16c86bcc01dff2a984aeffd58e2402a876cc12d (patch) | |
tree | 7f2b3a6ea5951f7f684d550549069e0f1f0452f0 /src/blogc-make/ctx.c | |
parent | 355c8d37d0ce570e45fe8b905fee6417be35942e (diff) | |
download | blogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.tar.gz blogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.tar.bz2 blogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.zip |
make: handle empty prefixes properly
still needs to add integration tests
Diffstat (limited to 'src/blogc-make/ctx.c')
-rw-r--r-- | src/blogc-make/ctx.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c index 0a3f9a0..0c47c12 100644 --- a/src/blogc-make/ctx.c +++ b/src/blogc-make/ctx.c @@ -234,12 +234,13 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0, const char *content_dir = bc_trie_lookup(settings->settings, "content_dir"); const char *post_prefix = bc_trie_lookup(settings->settings, "post_prefix"); const char *source_ext = bc_trie_lookup(settings->settings, "source_ext"); + const char *slash = post_prefix[0] == '\0' ? "" : "/"; rv->posts_fctx = NULL; if (settings->posts != NULL) { for (size_t i = 0; settings->posts[i] != NULL; i++) { - char *f = bc_strdup_printf("%s/%s/%s%s", content_dir, post_prefix, - settings->posts[i], source_ext); + char *f = bc_strdup_printf("%s%s%s/%s%s", content_dir, slash, + post_prefix, settings->posts[i], source_ext); rv->posts_fctx = bc_slist_append(rv->posts_fctx, bm_filectx_new(rv, f, settings->posts[i], NULL)); free(f); |