aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-12-03 11:00:25 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-12-03 11:00:25 +0100
commita8b907760bab503b99edb1fd832d29d409d125a3 (patch)
tree4937cdf7e36db022f31a4a1b26370a1be1656688 /src
parent5dd30eea54d5b1ef25e517505c5a47ff1a37c424 (diff)
downloadunja-a8b907760bab503b99edb1fd832d29d409d125a3.tar.gz
unja-a8b907760bab503b99edb1fd832d29d409d125a3.zip
fix inheritance not working because of read_file not populating memory correctly
Diffstat (limited to 'src')
-rw-r--r--src/template.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/template.c b/src/template.c
index 6949068..105a8c3 100644
--- a/src/template.c
+++ b/src/template.c
@@ -197,6 +197,9 @@ struct env *env_new(char *dirname) {
strcpy(name, de->d_name);
char *tmpl = read_file(name);
+ #if DEBUG
+ printf("Parsing template from file %s: %s\n", name, tmpl);
+ #endif
mpc_ast_t *ast = parse(tmpl);
free(tmpl);
@@ -242,7 +245,7 @@ char *read_file(char *filename) {
}
unsigned int read = 0;
- while ( (read = fread(input, 1, BUFSIZ, f)) > 0) {
+ while ( (read = fread(input + read, 1, BUFSIZ, f)) > 0) {
size += read;
input = realloc(input, size + BUFSIZ);
}