aboutsummaryrefslogtreecommitdiffstats
path: root/src/template-parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-05-17 16:18:58 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-05-17 16:18:58 -0300
commitd7f5252a0d7c4c428bfbd560ce78b81073d3d6ec (patch)
tree8cf069f1e7ff1832b01b68c2c4b99cf5e6b00295 /src/template-parser.c
parent365a0c8f2b46b2afa0c43d6a286fa07b86bd1520 (diff)
downloadblogc-d7f5252a0d7c4c428bfbd560ce78b81073d3d6ec.tar.gz
blogc-d7f5252a0d7c4c428bfbd560ce78b81073d3d6ec.tar.bz2
blogc-d7f5252a0d7c4c428bfbd560ce78b81073d3d6ec.zip
template-parser: minor fixes. tests
Diffstat (limited to 'src/template-parser.c')
-rw-r--r--src/template-parser.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/template-parser.c b/src/template-parser.c
index 6eb65b6..47cb762 100644
--- a/src/template-parser.c
+++ b/src/template-parser.c
@@ -222,19 +222,25 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)
if ((c >= 'a' && c <= 'z') || c == '_')
break;
if (c == ' ') {
- if (0 == strncmp("entry", src + start, current - start)) {
+ if ((current - start == 5) &&
+ (0 == strncmp("entry", src + start, current - start)))
+ {
block_state = BLOCK_ENTRY;
end = current;
state = TEMPLATE_BLOCK_END;
break;
}
- else if (0 == strncmp("listing", src + start, current - start)) {
+ else if ((current - start == 7) &&
+ (0 == strncmp("listing", src + start, current - start)))
+ {
block_state = BLOCK_LISTING;
end = current;
state = TEMPLATE_BLOCK_END;
break;
}
- else if (0 == strncmp("listing_once", src + start, current - start)) {
+ else if ((current - start == 12) &&
+ (0 == strncmp("listing_once", src + start, current - start)))
+ {
block_state = BLOCK_LISTING_ONCE;
end = current;
state = TEMPLATE_BLOCK_END;
@@ -434,7 +440,10 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)
}
if (*err == NULL) {
- if (if_count != 0)
+ if (state == TEMPLATE_BLOCK_IF_OPERAND)
+ *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, src, src_len,
+ start2 - 1, "Found an open double-quoted string.");
+ else if (if_count != 0)
*err = blogc_error_new_printf(BLOGC_ERROR_TEMPLATE_PARSER,
"%d open 'ifdef' and/or 'ifndef' statements were not closed!",
if_count);