diff options
Diffstat (limited to 'src/engine/include.c')
-rw-r--r-- | src/engine/include.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/engine/include.c b/src/engine/include.c index 5cb650e..6114f07 100644 --- a/src/engine/include.c +++ b/src/engine/include.c @@ -38,31 +38,32 @@ extern msg_t *msg; void handle_include(char **buffer, key_match_t *match, directive_t *directive) { - char *operand = directive->operands; - char *partial_path; - asprintf(&partial_path, "%s/%s/%s", msg->base_directory, PARTIALS, operand); + char *operand = directive->operands; + char *partial_path; + asprintf( + &partial_path, "%s/%s/%s", msg->base_directory, PARTIALS, operand); - FILE *f = fopen(partial_path, "r"); - if (f == NULL) { - printf("Could not open: %s\n", partial_path); - return; - } - free(partial_path); + FILE *f = fopen(partial_path, "r"); + if (f == NULL) { + printf("Could not open: %s\n", partial_path); + return; + } + free(partial_path); - unsigned int size = fsize(f); - char *partial_content = fcontent(f, size); - fclose(f); + unsigned int size = fsize(f); + char *partial_content = fcontent(f, size); + fclose(f); - char *temp_buffer = strdup(*buffer); + char *temp_buffer = strdup(*buffer); - free(*buffer); - asprintf(buffer, - "%.*s%s%s\n", - match->offset, - temp_buffer, - partial_content, - temp_buffer + match->offset + match->length); + free(*buffer); + asprintf(buffer, + "%.*s%s%s\n", + match->offset, + temp_buffer, + partial_content, + temp_buffer + match->offset + match->length); - free(partial_content); - free(temp_buffer); + free(partial_content); + free(temp_buffer); } |