aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2019-04-13 19:46:39 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2019-04-13 19:46:39 +0200
commit64a808bb68b88605090577e296150320cb7af18a (patch)
tree07a7ae9e983b4f62a558becf2a913788148a4407
parent0a79af2e17386d60a06172d72b50d9196d0fcb28 (diff)
downloadblogc-64a808bb68b88605090577e296150320cb7af18a.tar.gz
blogc-64a808bb68b88605090577e296150320cb7af18a.tar.bz2
blogc-64a808bb68b88605090577e296150320cb7af18a.zip
blogc: added support for formatted variables in -p
-rw-r--r--man/blogc.1.ronn5
-rw-r--r--src/blogc/main.c9
2 files changed, 4 insertions, 10 deletions
diff --git a/man/blogc.1.ronn b/man/blogc.1.ronn
index 8bcd12d..8b5b52f 100644
--- a/man/blogc.1.ronn
+++ b/man/blogc.1.ronn
@@ -72,11 +72,6 @@ designed to be used with make(1).
is useful to get parameters for your `Makefile`, like the last page when
implementing pagination, see blogc-pagination(7) for details. This option can
also dump variables defined in a source file, if called without `-l`.
- Please note that variables generated by blogc during rendering process, like
- `BLOGC_RUSAGE_MEMORY` are not available, because blogc will exit without
- rendering any content when called with this option, and will not even require
- a template. However, variables generated during parsing process, like
- `CONTENT` are available.
* `-t` <TEMPLATE>:
Template file. It is a required option, if `blogc` needs to render something.
diff --git a/src/blogc/main.c b/src/blogc/main.c
index 5a4df99..2f93d18 100644
--- a/src/blogc/main.c
+++ b/src/blogc/main.c
@@ -315,13 +315,11 @@ main(int argc, char **argv)
}
if (print != NULL) {
- const char *val = NULL;
+ bc_trie_t *local = NULL;
if (!listing && s != NULL) {
- val = bc_trie_lookup(s->data, print);
- }
- if (val == NULL) {
- val = bc_trie_lookup(config, print);
+ local = s->data;
}
+ char *val = blogc_format_variable(print, config, local, NULL);
if (val == NULL) {
fprintf(stderr, "blogc: error: variable not found: %s\n",
print);
@@ -330,6 +328,7 @@ main(int argc, char **argv)
else {
printf("%s\n", val);
}
+ free(val);
goto cleanup2;
}