summaryrefslogtreecommitdiff
path: root/src/templating/test6
diff options
context:
space:
mode:
Diffstat (limited to 'src/templating/test6')
-rw-r--r--src/templating/test6/.gitignore1
-rw-r--r--src/templating/test6/Makefile12
-rw-r--r--src/templating/test6/json8
-rw-r--r--src/templating/test6/must4
-rw-r--r--src/templating/test6/resu.ref90
-rw-r--r--src/templating/test6/test-custom-write.c12
-rw-r--r--src/templating/test6/vg.ref14
7 files changed, 58 insertions, 83 deletions
diff --git a/src/templating/test6/.gitignore b/src/templating/test6/.gitignore
index 62f4d9190..15e6dd5a5 100644
--- a/src/templating/test6/.gitignore
+++ b/src/templating/test6/.gitignore
@@ -1,4 +1,3 @@
resu.last
vg.last
test-custom-write
-!test-custom-write.c
diff --git a/src/templating/test6/Makefile b/src/templating/test6/Makefile
new file mode 100644
index 000000000..ea4f86e79
--- /dev/null
+++ b/src/templating/test6/Makefile
@@ -0,0 +1,12 @@
+.PHONY: test clean
+
+test-custom-write: test-custom-write.c ../mustach-json-c.h ../mustach-json-c.c ../mustach-wrap.c ../mustach.h ../mustach.c
+ @echo building test-custom-write
+ $(CC) $(CFLAGS) $(LDFLAGS) -g -o test-custom-write test-custom-write.c ../mustach.c ../mustach-json-c.c ../mustach-wrap.c -ljson-c
+
+test: test-custom-write
+ @mustach=./test-custom-write ../dotest.sh json -U must -l must -x must
+
+clean:
+ rm -f resu.last vg.last test-custom-write
+
diff --git a/src/templating/test6/json b/src/templating/test6/json
index 5b2e3d83a..6562fb064 100644
--- a/src/templating/test6/json
+++ b/src/templating/test6/json
@@ -5,12 +5,12 @@
"in_ca": true,
"person": false,
"repo": [
- { "name": "resque", "who": [ { "committer": "joe" }, { "reviewer": "avrel" }, { "committer": "william" } ] },
- { "name": "hub", "who": [ { "committer": "jack" }, { "reviewer": "avrel" }, { "committer": "greg" } ] },
- { "name": "rip", "who": [ { "reviewer": "joe" }, { "reviewer": "jack" }, { "committer": "greg" } ] }
+ { "name": "resque", "who": [ { "commiter": "joe" }, { "reviewer": "avrel" }, { "commiter": "william" } ] },
+ { "name": "hub", "who": [ { "commiter": "jack" }, { "reviewer": "avrel" }, { "commiter": "greg" } ] },
+ { "name": "rip", "who": [ { "reviewer": "joe" }, { "reviewer": "jack" }, { "commiter": "greg" } ] }
],
"person?": { "name": "Jon" },
- "special": "----{{extra}}----",
+ "special": "----{{extra}}----\n",
"extra": 3.14159,
"#sharp": "#",
"!bang": "!",
diff --git a/src/templating/test6/must b/src/templating/test6/must
index 723f966c4..6df523669 100644
--- a/src/templating/test6/must
+++ b/src/templating/test6/must
@@ -12,7 +12,7 @@ Shown.
{{/person}}
{{#repo}}
- <b>{{name}}</b> reviewers:{{#who}} {{reviewer}}{{/who}} committers:{{#who}} {{committer}}{{/who}}
+ <b>{{name}}</b> reviewers:{{#who}} {{reviewer}}{{/who}} commiters:{{#who}} {{commiter}}{{/who}}
{{/repo}}
{{#person?}}
@@ -23,7 +23,7 @@ Shown.
=====================================
%(%! gros commentaire %)%
%(%#repo%)%
- <b>%(%name%)%</b> reviewers:%(%#who%)% %(%reviewer%)%%(%/who%)% committers:%(%#who%)% %(%committer%)%%(%/who%)%
+ <b>%(%name%)%</b> reviewers:%(%#who%)% %(%reviewer%)%%(%/who%)% commiters:%(%#who%)% %(%commiter%)%%(%/who%)%
%(%/repo%)%
=====================================
%(%={{ }}=%)%
diff --git a/src/templating/test6/resu.ref b/src/templating/test6/resu.ref
index 345d3aef6..377eb11af 100644
--- a/src/templating/test6/resu.ref
+++ b/src/templating/test6/resu.ref
@@ -1,38 +1,20 @@
HELLO CHRIS
YOU HAVE JUST WON 10000 DOLLARS!
-
WELL, 6000 DOLLARS, AFTER TAXES.
-
SHOWN.
-
-
NO PERSON
-
-
- <B>RESQUE</B> REVIEWERS: AVREL COMMITTERS: JOE WILLIAM
-
- <B>HUB</B> REVIEWERS: AVREL COMMITTERS: JACK GREG
-
- <B>RIP</B> REVIEWERS: JOE JACK COMMITTERS: GREG
-
-
+ <B>RESQUE</B> REVIEWERS: AVREL COMMITERS: JOE WILLIAM
+ <B>HUB</B> REVIEWERS: AVREL COMMITERS: JACK GREG
+ <B>RIP</B> REVIEWERS: JOE JACK COMMITERS: GREG
HI JON!
-
-
=====================================
-
-
- <B>RESQUE</B> REVIEWERS: AVREL COMMITTERS: JOE WILLIAM
-
- <B>HUB</B> REVIEWERS: AVREL COMMITTERS: JACK GREG
-
- <B>RIP</B> REVIEWERS: JOE JACK COMMITTERS: GREG
-
+ <B>RESQUE</B> REVIEWERS: AVREL COMMITERS: JOE WILLIAM
+ <B>HUB</B> REVIEWERS: AVREL COMMITERS: JACK GREG
+ <B>RIP</B> REVIEWERS: JOE JACK COMMITERS: GREG
=====================================
-
GGGGGGGGG
----3.14159----
JJJJJJJJJ
@@ -49,39 +31,21 @@ END
&GT;
hello chris
you have just won 10000 dollars!
-
well, 6000 dollars, after taxes.
-
shown.
-
-
no person
-
-
- <b>resque</b> reviewers: avrel committers: joe william
-
- <b>hub</b> reviewers: avrel committers: jack greg
-
- <b>rip</b> reviewers: joe jack committers: greg
-
-
+ <b>resque</b> reviewers: avrel commiters: joe william
+ <b>hub</b> reviewers: avrel commiters: jack greg
+ <b>rip</b> reviewers: joe jack commiters: greg
hi jon!
-
-
=====================================
-
-
- <b>resque</b> reviewers: avrel committers: joe william
-
- <b>hub</b> reviewers: avrel committers: jack greg
-
- <b>rip</b> reviewers: joe jack committers: greg
-
+ <b>resque</b> reviewers: avrel commiters: joe william
+ <b>hub</b> reviewers: avrel commiters: jack greg
+ <b>rip</b> reviewers: joe jack commiters: greg
=====================================
-
ggggggggg
----3.14159----
jjjjjjjjj
@@ -98,39 +62,21 @@ end
&gt;
Hello Chris
You have just won 10000 dollars!
-
Well, 6000 dollars, after taxes.
-
Shown.
-
-
No person
-
-
- <b>resque</b> reviewers: avrel committers: joe william
-
- <b>hub</b> reviewers: avrel committers: jack greg
-
- <b>rip</b> reviewers: joe jack committers: greg
-
-
+ <b>resque</b> reviewers: avrel commiters: joe william
+ <b>hub</b> reviewers: avrel commiters: jack greg
+ <b>rip</b> reviewers: joe jack commiters: greg
Hi Jon!
-
-
=====================================
-
-
- <b>resque</b> reviewers: avrel committers: joe william
-
- <b>hub</b> reviewers: avrel committers: jack greg
-
- <b>rip</b> reviewers: joe jack committers: greg
-
+ <b>resque</b> reviewers: avrel commiters: joe william
+ <b>hub</b> reviewers: avrel commiters: jack greg
+ <b>rip</b> reviewers: joe jack commiters: greg
=====================================
-
ggggggggg
----3.14159----
jjjjjjjjj
diff --git a/src/templating/test6/test-custom-write.c b/src/templating/test6/test-custom-write.c
index cc50a47cb..20042c1ed 100644
--- a/src/templating/test6/test-custom-write.c
+++ b/src/templating/test6/test-custom-write.c
@@ -1,6 +1,5 @@
/*
Author: José Bollo <jobol@nonadev.net>
- Author: José Bollo <jose.bollo@iot.bzh>
https://gitlab.com/jobol/mustach
@@ -17,7 +16,9 @@
limitations under the License.
*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdlib.h>
#include <stdio.h>
@@ -36,7 +37,7 @@ static char *readfile(const char *filename)
{
int f;
struct stat s;
- char *result;
+ char *result, *ptr;
size_t size, pos;
ssize_t rc;
@@ -80,7 +81,10 @@ static char *readfile(const char *filename)
pos += (size_t)rc;
if (pos > size) {
size = pos + BLOCKSIZE;
- result = realloc(result, size + 1);
+ ptr = realloc(result, size + 1);
+ if (!ptr)
+ free(result);
+ result = ptr;
}
}
} while(rc > 0);
@@ -132,7 +136,7 @@ int main(int ac, char **av)
mode = None;
else {
t = readfile(*av);
- s = umustach_json_c(t, o, uwrite, NULL);
+ s = mustach_json_c_write(t, 0, o, Mustach_With_AllExtensions, uwrite, NULL);
if (s != 0)
fprintf(stderr, "Template error %d\n", s);
free(t);
diff --git a/src/templating/test6/vg.ref b/src/templating/test6/vg.ref
new file mode 100644
index 000000000..fb0e31bd8
--- /dev/null
+++ b/src/templating/test6/vg.ref
@@ -0,0 +1,14 @@
+Memcheck, a memory error detector
+Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
+Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
+Command: ./test-custom-write json -U must -l must -x must
+
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 174 allocs, 174 frees, 24,250 bytes allocated
+
+All heap blocks were freed -- no leaks are possible
+
+For lists of detected and suppressed errors, rerun with: -s
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)