Hello community, here is the log from the commit of package blogc for openSUSE:Factory checked in at 2018-03-12 12:13:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/blogc (Old) and /work/SRC/openSUSE:Factory/.blogc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "blogc" Mon Mar 12 12:13:19 2018 rev:2 rq:585770 version:0.13.2 Changes: -------- --- /work/SRC/openSUSE:Factory/blogc/blogc.changes 2018-02-26 23:25:34.901406824 +0100 +++ /work/SRC/openSUSE:Factory/.blogc.new/blogc.changes 2018-03-12 12:13:33.499541155 +0100 @@ -1,0 +2,8 @@ +Mon Mar 12 07:40:20 UTC 2018 - mvet...@suse.com + +- Update to 0.13.2: + * Pass MAKE_TAGS to blogc. + * MAKE_SLUG to blogc when running pages and posts build tasks. + * Fix memory leak + +------------------------------------------------------------------- Old: ---- blogc-0.13.1.tar.xz New: ---- blogc-0.13.2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ blogc.spec ++++++ --- /var/tmp/diff_new_pack.dvA98F/_old 2018-03-12 12:13:35.483470370 +0100 +++ /var/tmp/diff_new_pack.dvA98F/_new 2018-03-12 12:13:35.487470228 +0100 @@ -17,12 +17,12 @@ Name: blogc -Version: 0.13.1 +Version: 0.13.2 Release: 0 Summary: Blog compiler License: BSD-3-Clause Group: Productivity/Networking/Web/Utilities -URL: https://blogc.rgm.io/ +Url: https://blogc.rgm.io/ Source: https://github.com/blogc/blogc/releases/download/v%{version}/blogc-%{version}.tar.xz BuildRequires: xz ++++++ blogc-0.13.1.tar.xz -> blogc-0.13.2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/.tarball-version new/blogc-0.13.2/.tarball-version --- old/blogc-0.13.1/.tarball-version 2018-02-22 20:55:57.000000000 +0100 +++ new/blogc-0.13.2/.tarball-version 2018-03-12 01:09:49.000000000 +0100 @@ -1 +1 @@ -0.13.1 +0.13.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/.version new/blogc-0.13.2/.version --- old/blogc-0.13.1/.version 2018-02-22 20:55:57.000000000 +0100 +++ new/blogc-0.13.2/.version 2018-03-12 01:09:49.000000000 +0100 @@ -1 +1 @@ -0.13.1 +0.13.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-git-receiver.1 new/blogc-0.13.2/blogc-git-receiver.1 --- old/blogc-0.13.1/blogc-git-receiver.1 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogc-git-receiver.1 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-GIT\-RECEIVER" "1" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-GIT\-RECEIVER" "1" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-git\-receiver\fR \- a simple login shell/git hook to deploy blogc websites diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-make.1 new/blogc-0.13.2/blogc-make.1 --- old/blogc-0.13.1/blogc-make.1 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogc-make.1 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-MAKE" "1" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-MAKE" "1" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-make\fR \- a simple build tool for blogc @@ -42,16 +42,13 @@ . .SH "HELPER RULES" . -.TP -\fBall\fR +.SS "all" Run all build rules\. This is the default rule\. . -.TP -\fBclean\fR +.SS "clean" Clean built files and empty directories in output directory\. . -.TP -\fBrunserver\fR +.SS "runserver" Run \fBblogc\-runserver(1)\fR pointing to output directory, if available\. This rule accepts some arguments, in the following format: . .IP "" 4 @@ -64,41 +61,118 @@ . .IP "" 0 . -.IP +.P The values in the example are the default values\. . .SH "BUILD RULES" . +.SS "index" +Build website index from posts\. +. +.P +The rule passes the following helper variables to blogc(1): +. .TP +\fBMAKE_RULE\fR \fBindex\fR -Build website index from posts\. . .TP -\fBatom\fR +\fBMAKE_TYPE\fR +\fBpost\fR +. +.SS "atom" Build main atom feed from posts\. . +.P +The rule passes the following helper variables to blogc(1): +. .TP -\fBatom_tags\fR +\fBMAKE_RULE\fR +\fBatom\fR +. +.TP +\fBMAKE_TYPE\fR +\fBatom\fR +. +.SS "atom_tags" Build atom feeds for each tag from posts\. . +.P +The rule passes the following helper variables to blogc(1): +. .TP -\fBpagination\fR +\fBMAKE_RULE\fR +\fBatom_tags\fR +. +.TP +\fBMAKE_TYPE\fR +\fBatom\fR +. +.SS "pagination" Build pagination pages from posts\. . +.P +The rule passes the following helper variables to blogc(1): +. .TP -\fBposts\fR +\fBMAKE_RULE\fR +\fBpagination\fR +. +.TP +\fBMAKE_TYPE\fR +\fBpost\fR +. +.SS "posts" Build individual pages for each post\. . +.P +The rule passes the following helper variables to blogc(1): +. .TP -\fBtags\fR +\fBMAKE_RULE\fR +\fBposts\fR +. +.TP +\fBMAKE_TYPE\fR +\fBpost\fR +. +.TP +\fBMAKE_SLUG\fR +The slug of the post being built, as provided in blogcfile +. +.SS "tags" Build post listings for each tag from posts\. . +.P +The rule passes the following helper variables to blogc(1): +. .TP -\fBpages\fR +\fBMAKE_RULE\fR +\fBtags\fR +. +.TP +\fBMAKE_TYPE\fR +\fBpost\fR +. +.SS "pages" Build individual pages for each page\. . +.P +The rule passes the following helper variables to blogc(1): +. +.TP +\fBMAKE_RULE\fR +\fBpages\fR +. .TP -\fBcopy\fR +\fBMAKE_TYPE\fR +\fBpage\fR +. +.TP +\fBMAKE_SLUG\fR +The slug of the page being built, as provided in blogcfile +. +.SS "copy" Copy static files from source directory to output directory\. . .SH "FILES" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-pagination.7 new/blogc-0.13.2/blogc-pagination.7 --- old/blogc-0.13.1/blogc-pagination.7 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogc-pagination.7 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-PAGINATION" "7" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-PAGINATION" "7" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-pagination\fR \- blogc\'s pagination support diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-runserver.1 new/blogc-0.13.2/blogc-runserver.1 --- old/blogc-0.13.1/blogc-runserver.1 2018-02-22 20:55:57.000000000 +0100 +++ new/blogc-0.13.2/blogc-runserver.1 2018-03-12 01:09:49.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-RUNSERVER" "1" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-RUNSERVER" "1" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-runserver\fR \- a simple HTTP server to test blogc websites diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-source.7 new/blogc-0.13.2/blogc-source.7 --- old/blogc-0.13.1/blogc-source.7 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogc-source.7 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-SOURCE" "7" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-SOURCE" "7" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-source\fR \- blogc\'s source file format diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc-template.7 new/blogc-0.13.2/blogc-template.7 --- old/blogc-0.13.1/blogc-template.7 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogc-template.7 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC\-TEMPLATE" "7" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC\-TEMPLATE" "7" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\-template\fR \- blogc\'s template format diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc.1 new/blogc-0.13.2/blogc.1 --- old/blogc-0.13.1/blogc.1 2018-02-22 20:55:55.000000000 +0100 +++ new/blogc-0.13.2/blogc.1 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGC" "1" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGC" "1" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogc\fR \- a blog compiler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc.spec new/blogc-0.13.2/blogc.spec --- old/blogc-0.13.1/blogc.spec 2018-02-22 20:55:55.000000000 +0100 +++ new/blogc-0.13.2/blogc.spec 2018-03-12 01:09:47.000000000 +0100 @@ -1,11 +1,11 @@ Name: blogc -Version: 0.13.1 +Version: 0.13.2 Release: 1%{?dist} License: BSD Group: Applications/Text Summary: A blog compiler URL: https://blogc.rgm.io/ -Source0: https://github.com/blogc/blogc/releases/download/v0.13.1/blogc-0.13.1.tar.xz +Source0: https://github.com/blogc/blogc/releases/download/v0.13.2/blogc-0.13.2.tar.xz BuildRequires: libcmocka-devel, bash, coreutils, diffutils %if ! 0%{?el6} BuildRequires: git, tar, make @@ -43,7 +43,7 @@ blogc-runserver is a simple HTTP server to test blogc websites. %prep -%setup -q -n blogc-0.13.1 +%setup -q -n blogc-0.13.2 %build %if 0%{?el6} @@ -88,6 +88,9 @@ %license LICENSE %changelog +* Mon Mar 12 2018 Rafael G. Martins <raf...@rafaelmartins.eng.br> 0.13.2-1 +- New release. + * Thu Feb 22 2018 Rafael G. Martins <raf...@rafaelmartins.eng.br> 0.13.1-1 - New release. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogc.spec.in new/blogc-0.13.2/blogc.spec.in --- old/blogc-0.13.1/blogc.spec.in 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/blogc.spec.in 2018-03-12 01:09:06.000000000 +0100 @@ -88,6 +88,9 @@ %license LICENSE %changelog +* Mon Mar 12 2018 Rafael G. Martins <raf...@rafaelmartins.eng.br> 0.13.2-1 +- New release. + * Thu Feb 22 2018 Rafael G. Martins <raf...@rafaelmartins.eng.br> 0.13.1-1 - New release. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/blogcfile.5 new/blogc-0.13.2/blogcfile.5 --- old/blogc-0.13.1/blogcfile.5 2018-02-22 20:55:56.000000000 +0100 +++ new/blogc-0.13.2/blogcfile.5 2018-03-12 01:09:48.000000000 +0100 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BLOGCFILE" "5" "February 2018" "Rafael G. Martins" "blogc Manual" +.TH "BLOGCFILE" "5" "March 2018" "Rafael G. Martins" "blogc Manual" . .SH "NAME" \fBblogcfile\fR \- blogc\-make\'s configuration file @@ -126,6 +126,9 @@ .SS "Tags listing" The \fB[tags]\fR section is a listing of the tags that should be listed in the website\. blogc\-make(1) will generate post listing indexes and Atom feeds for each tag listed in the section\. . +.P +The tags will be also provided to blogc as a \fBMAKE_TAGS\fR variable, that is a space\-separated list of the tags, useful to generate tag clouds using the \fBforeach\fR template iterator\. See blogc\-template(7)\. +. .SS "Copy listing" The \fB[copy]\fR section is a listing of the files that should be copied to the output directory\. . @@ -169,4 +172,4 @@ Rafael G\. Martins <\fIrafael@rafaelmartins\.eng\.br\fR> . .SH "SEE ALSO" -blogc(1), blogc\-make(1), strftime(3) +blogc(1), blogc\-make(1), blogc\-template(7) strftime(3) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/configure new/blogc-0.13.2/configure --- old/blogc-0.13.1/configure 2018-02-22 20:55:50.000000000 +0100 +++ new/blogc-0.13.2/configure 2018-03-12 01:09:43.000000000 +0100 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for blogc 0.13.1. +# Generated by GNU Autoconf 2.69 for blogc 0.13.2. # # Report bugs to <https://github.com/blogc/blogc>. # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='blogc' PACKAGE_TARNAME='blogc' -PACKAGE_VERSION='0.13.1' -PACKAGE_STRING='blogc 0.13.1' +PACKAGE_VERSION='0.13.2' +PACKAGE_STRING='blogc 0.13.2' PACKAGE_BUGREPORT='https://github.com/blogc/blogc' PACKAGE_URL='https://blogc.rgm.io/' @@ -1375,7 +1375,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures blogc 0.13.1 to adapt to many kinds of systems. +\`configure' configures blogc 0.13.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1445,7 +1445,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of blogc 0.13.1:";; + short | recursive ) echo "Configuration of blogc 0.13.2:";; esac cat <<\_ACEOF @@ -1572,7 +1572,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -blogc configure 0.13.1 +blogc configure 0.13.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1941,7 +1941,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by blogc $as_me 0.13.1, which was +It was created by blogc $as_me 0.13.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2806,7 +2806,7 @@ # Define the identity of the package. PACKAGE='blogc' - VERSION='0.13.1' + VERSION='0.13.2' cat >>confdefs.h <<_ACEOF @@ -14934,7 +14934,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by blogc $as_me 0.13.1, which was +This file was extended by blogc $as_me 0.13.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15001,7 +15001,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -blogc config.status 0.13.1 +blogc config.status 0.13.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/man/blogc-make.1.ronn new/blogc-0.13.2/man/blogc-make.1.ronn --- old/blogc-0.13.1/man/blogc-make.1.ronn 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/man/blogc-make.1.ronn 2018-03-12 01:09:06.000000000 +0100 @@ -35,45 +35,109 @@ ## HELPER RULES - * `all`: - Run all build rules. This is the default rule. +### all - * `clean`: - Clean built files and empty directories in output directory. +Run all build rules. This is the default rule. - * `runserver`: - Run `blogc-runserver(1)` pointing to output directory, if available. This - rule accepts some arguments, in the following format: +### clean - runserver:host=127.0.0.1,port=8080,threads=20 +Clean built files and empty directories in output directory. - The values in the example are the default values. +### runserver + +Run `blogc-runserver(1)` pointing to output directory, if available. This +rule accepts some arguments, in the following format: + + runserver:host=127.0.0.1,port=8080,threads=20 + +The values in the example are the default values. ## BUILD RULES - * `index`: - Build website index from posts. +### index + +Build website index from posts. + +The rule passes the following helper variables to blogc(1): + + * `MAKE_RULE`: + `index` + * `MAKE_TYPE`: + `post` + +### atom + +Build main atom feed from posts. + +The rule passes the following helper variables to blogc(1): + + * `MAKE_RULE`: + `atom` + * `MAKE_TYPE`: + `atom` + +### atom_tags + +Build atom feeds for each tag from posts. + +The rule passes the following helper variables to blogc(1): + + * `MAKE_RULE`: + `atom_tags` + * `MAKE_TYPE`: + `atom` + +### pagination + +Build pagination pages from posts. + +The rule passes the following helper variables to blogc(1): + + * `MAKE_RULE`: + `pagination` + * `MAKE_TYPE`: + `post` + +### posts + +Build individual pages for each post. + +The rule passes the following helper variables to blogc(1): + + * `MAKE_RULE`: + `posts` + * `MAKE_TYPE`: + `post` + * `MAKE_SLUG`: + The slug of the post being built, as provided in blogcfile + +### tags + +Build post listings for each tag from posts. + +The rule passes the following helper variables to blogc(1): - * `atom`: - Build main atom feed from posts. + * `MAKE_RULE`: + `tags` + * `MAKE_TYPE`: + `post` - * `atom_tags`: - Build atom feeds for each tag from posts. +### pages - * `pagination`: - Build pagination pages from posts. +Build individual pages for each page. - * `posts`: - Build individual pages for each post. +The rule passes the following helper variables to blogc(1): - * `tags`: - Build post listings for each tag from posts. + * `MAKE_RULE`: + `pages` + * `MAKE_TYPE`: + `page` + * `MAKE_SLUG`: + The slug of the page being built, as provided in blogcfile - * `pages`: - Build individual pages for each page. +### copy - * `copy`: - Copy static files from source directory to output directory. +Copy static files from source directory to output directory. ## FILES diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/man/blogcfile.5.ronn new/blogc-0.13.2/man/blogcfile.5.ronn --- old/blogc-0.13.1/man/blogcfile.5.ronn 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/man/blogcfile.5.ronn 2018-03-12 01:09:06.000000000 +0100 @@ -136,6 +136,10 @@ website. blogc-make(1) will generate post listing indexes and Atom feeds for each tag listed in the section. +The tags will be also provided to blogc as a `MAKE_TAGS` variable, that is a +space-separated list of the tags, useful to generate tag clouds using the +`foreach` template iterator. See blogc-template(7). + ### Copy listing The `[copy]` section is a listing of the files that should be copied to the @@ -180,4 +184,4 @@ ## SEE ALSO -blogc(1), blogc-make(1), strftime(3) +blogc(1), blogc-make(1), blogc-template(7) strftime(3) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/src/blogc-make/ctx.c new/blogc-0.13.2/src/blogc-make/ctx.c --- old/blogc-0.13.1/src/blogc-make/ctx.c 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/src/blogc-make/ctx.c 2018-03-12 01:09:06.000000000 +0100 @@ -24,7 +24,8 @@ bm_filectx_t* -bm_filectx_new(bm_ctx_t *ctx, const char *filename) +bm_filectx_new(bm_ctx_t *ctx, const char *filename, const char *slug, + struct stat *st) { if (ctx == NULL || filename == NULL) return NULL; @@ -35,20 +36,25 @@ bm_filectx_t *rv = bc_malloc(sizeof(bm_filectx_t)); rv->path = f; rv->short_path = bc_strdup(filename); + rv->slug = bc_strdup(slug); - struct stat buf; + if (st == NULL) { + struct stat buf; - if (0 != stat(f, &buf)) { - rv->tv_sec = 0; - rv->tv_nsec = 0; - rv->readable = false; - } - else { - rv->tv_sec = buf.st_mtim_tv_sec; - rv->tv_nsec = buf.st_mtim_tv_nsec; - rv->readable = true; + if (0 != stat(f, &buf)) { + rv->tv_sec = 0; + rv->tv_nsec = 0; + rv->readable = false; + return rv; + } + + st = &buf; } + // if it isn't NULL the file exists for sure + rv->tv_sec = st->st_mtim_tv_sec; + rv->tv_nsec = st->st_mtim_tv_nsec; + rv->readable = true; return rv; } @@ -89,7 +95,7 @@ return l; } - l = bc_slist_append(l, bm_filectx_new(ctx, filename)); + l = bc_slist_append(l, bm_filectx_new(ctx, filename, NULL, &buf)); free(f); return l; } @@ -151,6 +157,7 @@ return; free(fctx->path); free(fctx->short_path); + free(fctx->slug); free(fctx); } @@ -196,7 +203,7 @@ rv->settings = settings; char *real_filename = realpath(settings_file, NULL); - rv->settings_fctx = bm_filectx_new(rv, real_filename); + rv->settings_fctx = bm_filectx_new(rv, real_filename, NULL, NULL); rv->root_dir = realpath(dirname(real_filename), NULL); free(real_filename); @@ -218,10 +225,10 @@ 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); + 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); + 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"); @@ -234,7 +241,7 @@ 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)); + bm_filectx_new(rv, f, settings->posts[i], NULL)); free(f); } } @@ -245,7 +252,7 @@ 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)); + bm_filectx_new(rv, f, settings->pages[i], NULL)); free(f); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/src/blogc-make/ctx.h new/blogc-0.13.2/src/blogc-make/ctx.h --- old/blogc-0.13.1/src/blogc-make/ctx.h 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/src/blogc-make/ctx.h 2018-03-12 01:09:06.000000000 +0100 @@ -9,6 +9,7 @@ #ifndef _MAKE_CTX_H #define _MAKE_CTX_H +#include <sys/stat.h> #include <stdbool.h> #include <time.h> #include "settings.h" @@ -36,6 +37,7 @@ typedef struct { char *path; char *short_path; + char *slug; time_t tv_sec; long tv_nsec; bool readable; @@ -63,7 +65,8 @@ bc_slist_t *copy_fctx; } bm_ctx_t; -bm_filectx_t* bm_filectx_new(bm_ctx_t *ctx, const char *filename); +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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/src/blogc-make/exec.c new/blogc-0.13.2/src/blogc-make/exec.c --- old/blogc-0.13.1/src/blogc-make/exec.c 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/src/blogc-make/exec.c 2018-03-12 01:09:06.000000000 +0100 @@ -217,8 +217,8 @@ 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(); @@ -235,11 +235,18 @@ bc_string_append(rv, blogc_bin); if (settings != NULL) { + if (settings->tags != NULL) { + char *tags = bc_strv_join(settings->tags, " "); + bc_string_append_printf(rv, " -D MAKE_TAGS='%s'", tags); + free(tags); + } + bc_trie_foreach(settings->global, (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'"); @@ -270,8 +277,8 @@ 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) @@ -284,8 +291,9 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/src/blogc-make/exec.h new/blogc-0.13.2/src/blogc-make/exec.h --- old/blogc-0.13.1/src/blogc-make/exec.h 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/src/blogc-make/exec.h 2018-03-12 01:09:06.000000000 +0100 @@ -19,10 +19,10 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/src/blogc-make/rules.c new/blogc-0.13.2/src/blogc-make/rules.c --- old/blogc-0.13.1/src/blogc-make/rules.c 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/src/blogc-make/rules.c 2018-03-12 01:09:06.000000000 +0100 @@ -52,7 +52,7 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); return rv; } @@ -82,7 +82,7 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); return rv; } @@ -139,7 +139,7 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; @@ -203,7 +203,7 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; @@ -271,7 +271,7 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; @@ -328,14 +328,18 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; @@ -399,7 +403,7 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; @@ -454,14 +458,18 @@ 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 @@ 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)); + rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL)); free(f); } return rv; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blogc-0.13.1/tests/blogc-make/check_exec.c new/blogc-0.13.2/tests/blogc-make/check_exec.c --- old/blogc-0.13.1/tests/blogc-make/check_exec.c 2018-02-22 20:55:11.000000000 +0100 +++ new/blogc-0.13.2/tests/blogc-make/check_exec.c 2018-03-12 01:09:06.000000000 +0100 @@ -83,26 +83,30 @@ 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); @@ -121,28 +125,33 @@ 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); @@ -151,29 +160,78 @@ static void +test_build_blogc_cmd_with_settings_and_tags(void **state) +{ + bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t)); + settings->settings = bc_trie_new(free); + bc_trie_insert(settings->settings, "locale", bc_strdup("en_US.utf8")); + settings->global = bc_trie_new(free); + bc_trie_insert(settings->global, "FOO", bc_strdup("BAR")); + 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, local, true, + "main.tmpl", "foo.html", true, true); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D MAKE_TAGS='asd foo bar' -D FOO='BAR' " + "-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, NULL, false, NULL, + NULL, true, false); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D MAKE_TAGS='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, NULL, false, NULL, NULL, + true, false); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D MAKE_TAGS='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); + bc_strv_free(settings->tags); + free(settings); +} + + +static void 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); } @@ -187,6 +245,7 @@ #endif unit_test(test_build_blogc_cmd_with_settings), unit_test(test_build_blogc_cmd_with_settings_and_dev), + unit_test(test_build_blogc_cmd_with_settings_and_tags), unit_test(test_build_blogc_cmd_without_settings), }; return run_tests(tests);