commit - 664d70035d306f09fe381da2dfaa725623c9e252
commit + 84efe063d23232222a3620238a5de72df40ced47
blob - f781b7ac44f61c8065695ac89ec64680ac84268c
blob + 1dabd1cc6698d8d3b6dd99bdd5581a4eb7188d36
--- regress/template/Makefile
+++ regress/template/Makefile
04-flow \
05-loop \
06-escape \
- 07-printf
+ 07-printf \
+ 08-dangling
REGRESS_CLEANUP = clean-comp
NO_OBJ = Yes
${CC} 07-printf.o runbase.o tmpl.o -o t && ./t > got
diff -u ${.CURDIR}/07.expected got
+08-dangling: 08-dangling.o runbase.o tmpl.o
+ ${CC} 08-dangling.o runbase.o tmpl.o -o t && ./t > got
+ diff -u ${.CURDIR}/08.expected got
+
.include <bsd.regress.mk>
blob - /dev/null
blob + 1784d5d8836cf164c40a94347bdf3f2826dd04bc (mode 644)
--- /dev/null
+++ regress/template/08-dangling.tmpl
+{!
+#include <stdlib.h>
+
+#include "tmpl.h"
+
+int base(struct template *, const char *);
+
+!}
+
+{{ define base(struct template *tp, const char *title) }}
+{! char *foo = NULL; !}
+<!doctype html>
+<html>
+ <head>
+ <title>{{ title }}</title>
+ </head>
+ <body> {! /* TODO: frobnicate this line! */ !}
+ <h1>{{ title }}</h1>
+ {{ " | " }}
+ {{ "other stuff" }}
+ <script>
+ function greet() {
+ console.log("hello, world");
+ }
+ (function() {
+ greet();
+ })();
+ </script>
+ </body>
+</html>
+{{ finally }}
+{! free(foo); !}
+{{ end }}
blob - /dev/null
blob + 306fd0c40a46066d36177ff1c89d5254b95247e2 (mode 644)
--- /dev/null
+++ regress/template/08.expected
+<!doctype html><html><head><title> *hello* </title></head><body> <h1> *hello* </h1> | other stuff<script>function greet() {console.log("hello, world");}(function() {greet();})();</script></body></html>
+<!doctype html><html><head><title><hello></title></head><body> <h1><hello></h1> | other stuff<script>function greet() {console.log("hello, world");}(function() {greet();})();</script></body></html>
blob - fb6e4945dd4e2f6b31882eeeb94bf0a07a38120b
blob + 1e6a9fd07ea3c0e471801ffd54afd0a5773dc68c
--- template/parse.y
+++ template/parse.y
} else if (c == '{') {
starting = 1;
continue;
- }
+ } else if (c == '\n')
+ break;
*p++ = c;
if ((size_t)(p - buf) >= sizeof(buf)) {
yyerror("string too long");
return (findeol());
}
- } while ((c = lgetc(0)) != EOF && c != '\n');
+ } while ((c = lgetc(0)) != EOF);
*p = '\0';
if (c == EOF) {
yyerror("unterminated block");
} else if (c == '!') {
ending = 1;
continue;
- }
+ } else if (c == '\n')
+ break;
*p++ = c;
if ((size_t)(p - buf) >= sizeof(buf)) {
yyerror("line too long");
return (findeol());
}
- } while ((c = lgetc(0)) != EOF && c != '\n');
+ } while ((c = lgetc(0)) != EOF);
*p = '\0';
if (c == EOF) {