aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compromyse.xyz/index.html6
-rw-r--r--include/engine.h1
-rw-r--r--src/engine.c21
-rw-r--r--src/lexer.c7
4 files changed, 28 insertions, 7 deletions
diff --git a/compromyse.xyz/index.html b/compromyse.xyz/index.html
index 3dc4fc5..2a2e994 100644
--- a/compromyse.xyz/index.html
+++ b/compromyse.xyz/index.html
@@ -1,6 +1,8 @@
-{{ for post : posts }}KSFAISO
+{{ for post : posts }}
+KSFAISO
ASHIAUHSFI
-HERE{{ endfor }}
+HERE
+{{ endfor }}
<div class="p-16">
<div class="flex flex-wrap gap-8">
diff --git a/include/engine.h b/include/engine.h
index 7719528..6fd437e 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -12,5 +12,6 @@ void handle_contentfor(char **buffer,
key_match_t *match,
directive_t *directive,
list_t *content_headers);
+void handle_for(char **buffer, key_match_t *match, directive_t *directive);
#endif
diff --git a/src/engine.c b/src/engine.c
index 5f4c51a..7477d16 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <string.h>
+#define DEBUG
+
extern msg_t *msg;
void
@@ -69,6 +71,21 @@ handle_contentfor(char **buffer,
free(operand);
}
+void
+handle_for(char **buffer, key_match_t *match, directive_t *directive)
+{
+ for_operand_t *operand = directive->operands;
+
+#ifdef DEBUG
+ printf("KEY: %s\n", operand->key);
+ printf("SOURCE: %s\n", operand->source);
+ printf("CONTENT: %s\n", operand->content);
+ exit(1);
+#endif
+
+ free(operand);
+}
+
list_t *
ingest(char **buffer)
{
@@ -108,7 +125,11 @@ ingest(char **buffer)
case CONTENTFOR:
handle_contentfor(buffer, match, directive, content_headers);
break;
+ case FOR:
+ handle_for(buffer, match, directive);
+ break;
+ case ENDFOR:
case BODY:
case CONTENT:
case ENDCONTENT:
diff --git a/src/lexer.c b/src/lexer.c
index 24a8876..caddf17 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -165,6 +165,7 @@ lexer_handle_contentfor(directive_t *directive,
operands->content = strndup(buffer, new_match->offset);
operands->length
= match->offset + match->length + new_match->offset + new_match->length;
+ free(new_match);
directive->operands = operands;
}
@@ -223,11 +224,7 @@ lexer_handle_for(directive_t *directive,
}
operands->content = strndup(buffer, new_match->offset);
-
- printf("KEY: %s\n", operands->key);
- printf("SOURCE: %s\n", operands->source);
- printf("CONTENT: %s\n", operands->content);
- exit(1);
+ free(new_match);
directive->operands = operands;
}