stacinhtml

Static C in HTML - simple static site generator
git clone git://git.kocotian.pl/stacinhtml.git
Log | Files | Refs | README | LICENSE

commit 92e88c1ce18e37e7c171ef0c06fb0e6aa7a7a887
parent 71dcb8b6391f1b6e16955b80bead60418c69843f
Author: kocotian <kocotian@kocotian.pl>
Date:   Mon, 22 Mar 2021 22:43:42 +0100

Checking for variable null directly in macro

Diffstat:
Massemble.h | 2+-
Mcompile.c | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/assemble.h b/assemble.h @@ -31,7 +31,7 @@ #define $$(VARNAME) write(fd, $(VARNAME).data, $(VARNAME).len); #define DECLVAR(VARNAME, VALUE) \ (vs[vss].name.len = strlen(vs[vss].name.data = #VARNAME), \ - vs[vss].value.len = strlen(vs[vss].value.data = VALUE), \ + vs[vss].value.len = strlen(vs[vss].value.data = VALUE == NULL ? "<null>" : VALUE), \ ++vss) #define VS_MAX 256 #define fd 1 /* stdout */ diff --git a/compile.c b/compile.c @@ -208,7 +208,7 @@ main(int argc, char *argv[]) /* Declaring a few variables */ DECLVAR(title, outputfn); - DECLVAR(template, templatefn == NULL ? "none" : templatefn); + DECLVAR(template, templatefn); /* Parsing ("preprocessing") input for variables */ if ((rb = read(inputfd, idata, BUFFER_SIZE)) < 0)