aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-11 23:15:04 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-11 23:15:08 +0100
commitde43627dab99768da6bbaf6b81fb488507eef212 (patch)
treeb02c7ffd847fe76ee405decdf294a40aa4d1f5b4
parentd5da0fc0d43b722cb5de853c6aca6c443aafa6b9 (diff)
downloadblogc-de43627dab99768da6bbaf6b81fb488507eef212.tar.gz
blogc-de43627dab99768da6bbaf6b81fb488507eef212.tar.bz2
blogc-de43627dab99768da6bbaf6b81fb488507eef212.zip
make: added `MAKE_POST` var to `posts` and `pages` rules
This variable will have the same string that was inserted in tbe `blogcfile` when listing posts and pages, and is useful to highlight active menu items, for example.
-rw-r--r--src/blogc-make/ctx.c17
-rw-r--r--src/blogc-make/ctx.h4
-rw-r--r--src/blogc-make/exec.c16
-rw-r--r--src/blogc-make/exec.h8
-rw-r--r--src/blogc-make/rules.c38
-rw-r--r--tests/blogc-make/check_exec.c57
6 files changed, 84 insertions, 56 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c
index 74932c9..8e152da 100644
--- a/src/blogc-make/ctx.c
+++ b/src/blogc-make/ctx.c
@@ -24,7 +24,8 @@
bm_filectx_t*
-bm_filectx_new(bm_ctx_t *ctx, const char *filename, struct stat *st)
+bm_filectx_new(bm_ctx_t *ctx, const char *filename, const char *slug,
+ struct stat *st)
{
if (ctx == NULL || filename == NULL)
return NULL;
@@ -35,6 +36,7 @@ bm_filectx_new(bm_ctx_t *ctx, const char *filename, struct stat *st)
bm_filectx_t *rv = bc_malloc(sizeof(bm_filectx_t));
rv->path = f;
rv->short_path = bc_strdup(filename);
+ rv->slug = bc_strdup(slug);
if (st == NULL) {
struct stat buf;
@@ -93,7 +95,7 @@ bm_filectx_new_r(bc_slist_t *l, bm_ctx_t *ctx, const char *filename)
return l;
}
- l = bc_slist_append(l, bm_filectx_new(ctx, filename, &buf));
+ l = bc_slist_append(l, bm_filectx_new(ctx, filename, NULL, &buf));
free(f);
return l;
}
@@ -155,6 +157,7 @@ bm_filectx_free(bm_filectx_t *fctx)
return;
free(fctx->path);
free(fctx->short_path);
+ free(fctx->slug);
free(fctx);
}
@@ -200,7 +203,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
rv->settings = settings;
char *real_filename = realpath(settings_file, NULL);
- rv->settings_fctx = bm_filectx_new(rv, real_filename, NULL);
+ rv->settings_fctx = bm_filectx_new(rv, real_filename, NULL, NULL);
rv->root_dir = realpath(dirname(real_filename), NULL);
free(real_filename);
@@ -222,10 +225,10 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
char *main_template = bc_strdup_printf("%s/%s", template_dir,
bc_trie_lookup(settings->settings, "main_template"));
- rv->main_template_fctx = bm_filectx_new(rv, main_template, NULL);
+ rv->main_template_fctx = bm_filectx_new(rv, main_template, NULL, NULL);
free(main_template);
- rv->atom_template_fctx = bm_filectx_new(rv, atom_template, NULL);
+ rv->atom_template_fctx = bm_filectx_new(rv, atom_template, NULL, NULL);
free(atom_template);
const char *content_dir = bc_trie_lookup(settings->settings, "content_dir");
@@ -238,7 +241,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
char *f = bc_strdup_printf("%s/%s/%s%s", content_dir, post_prefix,
settings->posts[i], source_ext);
rv->posts_fctx = bc_slist_append(rv->posts_fctx,
- bm_filectx_new(rv, f, NULL));
+ bm_filectx_new(rv, f, settings->posts[i], NULL));
free(f);
}
}
@@ -249,7 +252,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
char *f = bc_strdup_printf("%s/%s%s", content_dir,
settings->pages[i], source_ext);
rv->pages_fctx = bc_slist_append(rv->pages_fctx,
- bm_filectx_new(rv, f, NULL));
+ bm_filectx_new(rv, f, settings->pages[i], NULL));
free(f);
}
}
diff --git a/src/blogc-make/ctx.h b/src/blogc-make/ctx.h
index 3f70ead..294e0d3 100644
--- a/src/blogc-make/ctx.h
+++ b/src/blogc-make/ctx.h
@@ -37,6 +37,7 @@
typedef struct {
char *path;
char *short_path;
+ char *slug;
time_t tv_sec;
long tv_nsec;
bool readable;
@@ -64,7 +65,8 @@ typedef struct {
bc_slist_t *copy_fctx;
} bm_ctx_t;
-bm_filectx_t* bm_filectx_new(bm_ctx_t *ctx, const char *filename, struct stat *st);
+bm_filectx_t* bm_filectx_new(bm_ctx_t *ctx, const char *filename, const char *slug,
+ struct stat *st);
bc_slist_t* bm_filectx_new_r(bc_slist_t *l, bm_ctx_t *ctx, const char *filename);
bool bm_filectx_changed(bm_filectx_t *ctx, time_t *tv_sec, long *tv_nsec);
void bm_filectx_reload(bm_filectx_t *ctx);
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index a324d47..d246df9 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -217,8 +217,8 @@ list_variables(const char *key, const char *value, bc_string_t *str)
char*
bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
- bc_trie_t *variables, bool listing, const char *template,
- const char *output, bool dev, bool sources_stdin)
+ bc_trie_t *global_variables, bc_trie_t *local_variables, bool listing,
+ const char *template, const char *output, bool dev, bool sources_stdin)
{
bc_string_t *rv = bc_string_new();
@@ -245,7 +245,8 @@ bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
(bc_trie_foreach_func_t) list_variables, rv);
}
- bc_trie_foreach(variables, (bc_trie_foreach_func_t) list_variables, rv);
+ bc_trie_foreach(global_variables, (bc_trie_foreach_func_t) list_variables, rv);
+ bc_trie_foreach(local_variables, (bc_trie_foreach_func_t) list_variables, rv);
if (dev) {
bc_string_append(rv, " -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
@@ -276,8 +277,8 @@ bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
int
-bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
- bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
+bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_variables,
+ bool listing, bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
bool only_first_source)
{
if (ctx == NULL)
@@ -290,8 +291,9 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
break;
}
- char *cmd = bm_exec_build_blogc_cmd(ctx->blogc, ctx->settings, variables,
- listing, template->path, output->path, ctx->dev, input->len > 0);
+ char *cmd = bm_exec_build_blogc_cmd(ctx->blogc, ctx->settings, global_variables,
+ local_variables, listing, template->path, output->path, ctx->dev,
+ input->len > 0);
if (ctx->verbose)
printf("%s\n", cmd);
diff --git a/src/blogc-make/exec.h b/src/blogc-make/exec.h
index 715c903..85f2a44 100644
--- a/src/blogc-make/exec.h
+++ b/src/blogc-make/exec.h
@@ -19,10 +19,10 @@ char* bm_exec_find_binary(const char *argv0, const char *bin, const char *env);
int bm_exec_command(const char *cmd, const char *input, char **output,
char **error, bc_error_t **err);
char* bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
- bc_trie_t *variables, bool listing, const char *template,
- const char *output, bool dev, bool sources_stdin);
-int bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
- bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
+ bc_trie_t *global_variables, bc_trie_t *local_variables, bool listing,
+ const char *template, const char *output, bool dev, bool sources_stdin);
+int bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_variables,
+ bool listing, bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
bool only_first_source);
int bm_exec_blogc_runserver(bm_ctx_t *ctx, const char *host, const char *port,
const char *threads);
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index 8a0558b..d8614b6 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -52,7 +52,7 @@ index_outputlist(bm_ctx_t *ctx)
char *f = bc_strdup_printf("%s%s%s%s", ctx->short_output_dir,
is_index ? "" : "/", is_index ? "" : index_prefix,
html_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
return rv;
}
@@ -82,7 +82,7 @@ index_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ rv = bm_exec_blogc(ctx, variables, NULL, true, ctx->main_template_fctx,
fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
@@ -109,7 +109,7 @@ atom_outputlist(bm_ctx_t *ctx)
const char *atom_ext = bc_trie_lookup(ctx->settings->settings, "atom_ext");
char *f = bc_strdup_printf("%s/%s%s", ctx->short_output_dir,
atom_prefix, atom_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
return rv;
}
@@ -139,7 +139,7 @@ atom_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx, NULL,
fctx, false))
{
- rv = bm_exec_blogc(ctx, variables, true, ctx->atom_template_fctx,
+ rv = bm_exec_blogc(ctx, variables, NULL, true, ctx->atom_template_fctx,
fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
@@ -167,7 +167,7 @@ atom_tags_outputlist(bm_ctx_t *ctx)
for (size_t i = 0; ctx->settings->tags[i] != NULL; i++) {
char *f = bc_strdup_printf("%s/%s/%s%s", ctx->short_output_dir,
atom_prefix, ctx->settings->tags[i], atom_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
@@ -203,7 +203,7 @@ atom_tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx, NULL,
fctx, false))
{
- rv = bm_exec_blogc(ctx, variables, true, ctx->atom_template_fctx,
+ rv = bm_exec_blogc(ctx, variables, NULL, true, ctx->atom_template_fctx,
fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
@@ -239,7 +239,7 @@ pagination_outputlist(bm_ctx_t *ctx)
for (size_t i = 0; i < pages; i++) {
char *f = bc_strdup_printf("%s/%s/%d%s", ctx->short_output_dir,
pagination_prefix, i + 1, html_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
@@ -271,7 +271,7 @@ pagination_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ rv = bm_exec_blogc(ctx, variables, NULL, true, ctx->main_template_fctx,
fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
@@ -301,7 +301,7 @@ posts_outputlist(bm_ctx_t *ctx)
for (size_t i = 0; ctx->settings->posts[i] != NULL; i++) {
char *f = bc_strdup_printf("%s/%s/%s%s", ctx->short_output_dir,
post_prefix, ctx->settings->posts[i], html_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
@@ -328,14 +328,18 @@ posts_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
for (s = ctx->posts_fctx, o = outputs; s != NULL && o != NULL;
s = s->next, o = o->next)
{
+ bm_filectx_t *s_fctx = s->data;
bm_filectx_t *o_fctx = o->data;
if (o_fctx == NULL)
continue;
if (bm_rule_need_rebuild(s, ctx->settings_fctx,
ctx->main_template_fctx, o_fctx, true))
{
- rv = bm_exec_blogc(ctx, variables, false, ctx->main_template_fctx,
+ bc_trie_t *local = bc_trie_new(NULL);
+ bc_trie_insert(local, "MAKE_SLUG", s_fctx->slug); // no need to copy
+ rv = bm_exec_blogc(ctx, variables, local, false, ctx->main_template_fctx,
o_fctx, s, true);
+ bc_trie_free(local);
if (rv != 0)
break;
}
@@ -362,7 +366,7 @@ tags_outputlist(bm_ctx_t *ctx)
for (size_t i = 0; ctx->settings->tags[i] != NULL; i++) {
char *f = bc_strdup_printf("%s/%s/%s%s", ctx->short_output_dir,
tag_prefix, ctx->settings->tags[i], html_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
@@ -399,7 +403,7 @@ tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ rv = bm_exec_blogc(ctx, variables, NULL, true, ctx->main_template_fctx,
fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
@@ -429,7 +433,7 @@ pages_outputlist(bm_ctx_t *ctx)
char *f = bc_strdup_printf("%s%s%s%s", ctx->short_output_dir,
is_index ? "" : "/", is_index ? "" : ctx->settings->pages[i],
html_ext);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
@@ -454,14 +458,18 @@ pages_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
for (s = ctx->pages_fctx, o = outputs; s != NULL && o != NULL;
s = s->next, o = o->next)
{
+ bm_filectx_t *s_fctx = s->data;
bm_filectx_t *o_fctx = o->data;
if (o_fctx == NULL)
continue;
if (bm_rule_need_rebuild(s, ctx->settings_fctx,
ctx->main_template_fctx, o_fctx, true))
{
- rv = bm_exec_blogc(ctx, variables, false, ctx->main_template_fctx,
+ bc_trie_t *local = bc_trie_new(NULL);
+ bc_trie_insert(local, "MAKE_SLUG", s_fctx->slug); // no need to copy
+ rv = bm_exec_blogc(ctx, variables, local, false, ctx->main_template_fctx,
o_fctx, s, true);
+ bc_trie_free(local);
if (rv != 0)
break;
}
@@ -487,7 +495,7 @@ copy_outputlist(bm_ctx_t *ctx)
for (bc_slist_t *s = ctx->copy_fctx; s != NULL; s = s->next) {
char *f = bc_strdup_printf("%s/%s", ctx->short_output_dir,
((bm_filectx_t*) s->data)->short_path);
- rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL));
+ rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(f);
}
return rv;
diff --git a/tests/blogc-make/check_exec.c b/tests/blogc-make/check_exec.c
index 875062c..3bf5df4 100644
--- a/tests/blogc-make/check_exec.c
+++ b/tests/blogc-make/check_exec.c
@@ -83,27 +83,30 @@ test_build_blogc_cmd_with_settings(void **state)
bc_trie_insert(settings->global, "BAR", bc_strdup("BAZ"));
bc_trie_t *variables = bc_trie_new(free);
bc_trie_insert(variables, "LOL", bc_strdup("HEHE"));
+ bc_trie_t *local = bc_trie_new(free);
+ bc_trie_insert(local, "ASD", bc_strdup("QWE"));
settings->tags = NULL;
- char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, true,
+ char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, local, true,
"main.tmpl", "foo.html", false, true);
assert_string_equal(rv,
- "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' -l "
- "-t 'main.tmpl' -o 'foo.html' -i");
+ "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' "
+ "-D ASD='QWE' -l -t 'main.tmpl' -o 'foo.html' -i");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL,
- false, false);
+ rv = bm_exec_build_blogc_cmd("blogc", settings, variables, NULL, false, NULL,
+ NULL, false, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE'");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL,
+ rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, NULL, false, NULL, NULL,
false, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ'");
free(rv);
+ bc_trie_free(local);
bc_trie_free(variables);
bc_trie_free(settings->settings);
bc_trie_free(settings->global);
@@ -122,29 +125,33 @@ test_build_blogc_cmd_with_settings_and_dev(void **state)
bc_trie_insert(settings->global, "BAR", bc_strdup("BAZ"));
bc_trie_t *variables = bc_trie_new(free);
bc_trie_insert(variables, "LOL", bc_strdup("HEHE"));
+ bc_trie_t *local = bc_trie_new(free);
+ bc_trie_insert(local, "ASD", bc_strdup("QWE"));
settings->tags = NULL;
- char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, true,
+ char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, local, true,
"main.tmpl", "foo.html", true, true);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' "
- "-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev' -l -t 'main.tmpl' -o 'foo.html' -i");
+ "-D ASD='QWE' -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev' -l -t 'main.tmpl' "
+ "-o 'foo.html' -i");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL,
- true, false);
+ rv = bm_exec_build_blogc_cmd("blogc", settings, variables, NULL, false, NULL,
+ NULL, true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' "
"-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL,
+ rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, NULL, false, NULL, NULL,
true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' "
"-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
+ bc_trie_free(local);
bc_trie_free(variables);
bc_trie_free(settings->settings);
bc_trie_free(settings->global);
@@ -163,30 +170,33 @@ test_build_blogc_cmd_with_settings_and_tags(void **state)
bc_trie_insert(settings->global, "BAR", bc_strdup("BAZ"));
bc_trie_t *variables = bc_trie_new(free);
bc_trie_insert(variables, "LOL", bc_strdup("HEHE"));
+ bc_trie_t *local = bc_trie_new(free);
+ bc_trie_insert(local, "ASD", bc_strdup("QWE"));
settings->tags = bc_str_split("asd foo bar", ' ', 0);
- char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, true,
+ char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, local, true,
"main.tmpl", "foo.html", true, true);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D TAG_CLOUD='asd foo bar' -D FOO='BAR' "
- "-D BAR='BAZ' -D LOL='HEHE' -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev' -l -t "
- "'main.tmpl' -o 'foo.html' -i");
+ "-D BAR='BAZ' -D LOL='HEHE' -D ASD='QWE' -D MAKE_ENV_DEV=1 "
+ "-D MAKE_ENV='dev' -l -t 'main.tmpl' -o 'foo.html' -i");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL,
- true, false);
+ rv = bm_exec_build_blogc_cmd("blogc", settings, variables, NULL, false, NULL,
+ NULL, true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D TAG_CLOUD='asd foo bar' -D FOO='BAR' "
"-D BAR='BAZ' -D LOL='HEHE' -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL,
+ rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, NULL, false, NULL, NULL,
true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D TAG_CLOUD='asd foo bar' -D FOO='BAR' "
"-D BAR='BAZ' -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
+ bc_trie_free(local);
bc_trie_free(variables);
bc_trie_free(settings->settings);
bc_trie_free(settings->global);
@@ -200,25 +210,28 @@ test_build_blogc_cmd_without_settings(void **state)
{
bc_trie_t *variables = bc_trie_new(free);
bc_trie_insert(variables, "LOL", bc_strdup("HEHE"));
+ bc_trie_t *local = bc_trie_new(free);
+ bc_trie_insert(local, "ASD", bc_strdup("QWE"));
- char *rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, true,
+ char *rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, local, true,
"main.tmpl", "foo.html", false, true);
assert_string_equal(rv,
- "blogc -D LOL='HEHE' -l -t 'main.tmpl' -o 'foo.html' -i");
+ "blogc -D LOL='HEHE' -D ASD='QWE' -l -t 'main.tmpl' -o 'foo.html' -i");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, false, NULL, NULL,
- false, false);
+ rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, NULL, false, NULL,
+ NULL, false, false);
assert_string_equal(rv,
"blogc -D LOL='HEHE'");
free(rv);
- rv = bm_exec_build_blogc_cmd("blogc", NULL, NULL, false, NULL, NULL,
+ rv = bm_exec_build_blogc_cmd("blogc", NULL, NULL, NULL, false, NULL, NULL,
false, false);
assert_string_equal(rv,
"blogc");
free(rv);
+ bc_trie_free(local);
bc_trie_free(variables);
}