From d7f5252a0d7c4c428bfbd560ce78b81073d3d6ec Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 17 May 2015 16:18:58 -0300 Subject: template-parser: minor fixes. tests --- src/template-parser.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-18-g5258