aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-17 20:57:05 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-17 20:57:05 +0200
commit361bb55f01ba28960a8127b0a16c1e7a7a8de61a (patch)
treeff0479af1c9283c8a0546025022ebc54616a9a75 /t
parent2810ad72aeb973a898034d6875922284062c5ce0 (diff)
downloadcforum-361bb55f01ba28960a8127b0a16c1e7a7a8de61a.tar.gz
Rewrite mktpl script in C
The Perl version didn't handle multiple interpolations on the same line.
Diffstat (limited to 't')
-rw-r--r--t/front.t34
-rw-r--r--t/front.tc25
-rw-r--r--t/post.t1
-rw-r--r--t/post.tc3
-rw-r--r--t/user.t1
-rw-r--r--t/user.tc5
6 files changed, 41 insertions, 28 deletions
diff --git a/t/front.t b/t/front.t
index 0a372a6..a9badb0 100644
--- a/t/front.t
+++ b/t/front.t
@@ -1,16 +1,20 @@
<h1><%= site.name %></h1>
-<% printf("Hello world!"); %>
-<br>
-Request method: <%= getenv("REQUEST_METHOD") %>
-<br>
-<%
- char *a, *b, *bv;
- a = nextparam(512);
- printf("%s (%d)<br>", a, TRUNCATED(a));
- b = nextparam(512);
- printf("%s (%d)<br>", b, TRUNCATED(b));
- bv = split(b);
- printf("'%s' contains '%s'<br>", b, bv);
- printf("Next: %s\n", nextparam(512));
- printf("Next: %s\n", nextparam(512));
-%> \ No newline at end of file
+<p>Thanks for the <%= getenv("REQUEST_METHOD") %> request!</p>
+<table border="1">
+ <tr style="font-weight: bold;">
+ <td style="width: 60px;">Key</td>
+ <td style="width: 140px;">Value</td>
+ </tr>
+ <%
+ char *p, *v;
+ while(p = nextparam(GET, 512)){
+ v = split(p);
+ %>
+ <tr>
+ <td><%= p %></td>
+ <td><%= v %></td>
+ </tr>
+ <%
+ }
+ %>
+</table> \ No newline at end of file
diff --git a/t/front.tc b/t/front.tc
index 89e665a..3307c21 100644
--- a/t/front.tc
+++ b/t/front.tc
@@ -1,16 +1,15 @@
printf("<h1>");
printf("%s", site.name );
-printf("</h1>\n");
- printf("Hello world!"); printf("\n<br>\nRequest method: ");
+printf("</h1>\n<p>Thanks for the ");
printf("%s", getenv("REQUEST_METHOD") );
-printf("<br>\n");
- char *a, *b, *bv;
- a = nextparam(512);
- printf("%s (%d)<br>", a, TRUNCATED(a));
- b = nextparam(512);
- printf("%s (%d)<br>", b, TRUNCATED(b));
- bv = split(b);
- printf("'%s' contains '%s'<br>", b, bv);
- printf("Next: %s\n", nextparam(512));
- printf("Next: %s\n", nextparam(512));
-printf("\n");
+printf(" request!</p>\n<table border=\"1\">\n <tr style=\"font-weight: bold;\">\n <td style=\"width: 60px;\">Key</td>\n <td style=\"width: 140px;\">Value</td>\n </tr>\n ");
+ char *p, *v;
+ while(p = nextparam(GET, 512)){
+ v = split(p);
+ printf("\n <tr>\n <td>");
+printf("%s", p );
+printf("</td>\n <td>");
+printf("%s", v );
+printf("</td>\n </tr>\n ");
+ }
+ printf("\n</table>");
diff --git a/t/post.t b/t/post.t
new file mode 100644
index 0000000..a74f29a
--- /dev/null
+++ b/t/post.t
@@ -0,0 +1 @@
+<h1>Post <% printf("%d", id); %></h1>
diff --git a/t/post.tc b/t/post.tc
new file mode 100644
index 0000000..7c36950
--- /dev/null
+++ b/t/post.tc
@@ -0,0 +1,3 @@
+printf("<h1>Post ");
+printf("%d", id);
+printf("</h1>\n");
diff --git a/t/user.t b/t/user.t
new file mode 100644
index 0000000..9a0fd49
--- /dev/null
+++ b/t/user.t
@@ -0,0 +1 @@
+<h1>User <% printf("%d", id); %>: <%= user->name %></h1> \ No newline at end of file
diff --git a/t/user.tc b/t/user.tc
new file mode 100644
index 0000000..3d92e16
--- /dev/null
+++ b/t/user.tc
@@ -0,0 +1,5 @@
+printf("<h1>User ");
+printf("%d", id);
+printf(": ");
+printf("%s", user->name );
+printf("</h1>");