aboutsummaryrefslogtreecommitdiff
path: root/src/templating/test6
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-05-13 22:00:04 +0200
committerChristian Grothoff <christian@grothoff.org>2023-05-13 22:00:04 +0200
commitbac4932cf5d8f5cb1af6eca5fcdac05239489e2c (patch)
tree87f376af58989f2d670083e5599de236118efffd /src/templating/test6
parentb7d1ca4cd93ef8582b9b7d97e955ec5363ef2ae3 (diff)
-fix templating tests
Diffstat (limited to 'src/templating/test6')
-rw-r--r--src/templating/test6/.gitignore1
-rw-r--r--src/templating/test6/json8
-rw-r--r--src/templating/test6/must4
-rw-r--r--src/templating/test6/resu.ref147
-rw-r--r--src/templating/test6/test-custom-write.c10
5 files changed, 12 insertions, 158 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/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
deleted file mode 100644
index 345d3aef6..000000000
--- a/src/templating/test6/resu.ref
+++ /dev/null
@@ -1,147 +0,0 @@
-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
-
-
-
- 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
-
-=====================================
-
-GGGGGGGGG
-----3.14159----
-JJJJJJJJJ
-END
-
-#
-!
-~
-~
-/ SEE JSON POINTERS IETF RFC 6901
-^
-=
-:
-&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
-
-
-
- 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
-
-=====================================
-
-ggggggggg
-----3.14159----
-jjjjjjjjj
-end
-
-#
-!
-~
-~
-/ see json pointers ietf rfc 6901
-^
-=
-:
-&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
-
-
-
- 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
-
-=====================================
-
-ggggggggg
-----3.14159----
-jjjjjjjjj
-end
-
-#
-!
-~
-~
-/ see json pointers IETF RFC 6901
-^
-=
-:
-&gt;
diff --git a/src/templating/test6/test-custom-write.c b/src/templating/test6/test-custom-write.c
index cc50a47cb..4ba953a85 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
@@ -36,7 +35,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 +79,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 +134,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);