diff options
author | John Ankarström <john@ankarstrom.se> | 2021-09-17 20:57:05 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-09-17 20:57:05 +0200 |
commit | 361bb55f01ba28960a8127b0a16c1e7a7a8de61a (patch) | |
tree | ff0479af1c9283c8a0546025022ebc54616a9a75 /t | |
parent | 2810ad72aeb973a898034d6875922284062c5ce0 (diff) | |
download | cforum-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.t | 34 | ||||
-rw-r--r-- | t/front.tc | 25 | ||||
-rw-r--r-- | t/post.t | 1 | ||||
-rw-r--r-- | t/post.tc | 3 | ||||
-rw-r--r-- | t/user.t | 1 | ||||
-rw-r--r-- | t/user.tc | 5 |
6 files changed, 41 insertions, 28 deletions
@@ -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 @@ -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>"); |