diff options
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/parser.c b/src/parser.c index 8e122fd..f05b31d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -598,17 +598,13 @@ int parser_parse_buffer(Parser *self, BufferView code_buffer, BufferView buffer_ } int parser_parse_file(Parser *self, BufferView filepath) { - int result; - char *file_data; - usize file_size; - + Buffer file_content; + return_if_error(buffer_init(&file_content, self->allocator)); assert(!self->started && "Parser can't be reused. Create a new parser."); self->started = bool_true; assert(filepath.size > 0 && filepath.data[filepath.size] == '\0'); - result = read_whole_file(filepath.data, &file_data, &file_size); - if(result != 0) return result; - result = parser_parse_buffer(self, create_buffer_view(file_data, file_size), filepath); - return result; + return_if_error(read_whole_file(filepath.data, &file_content)); + return parser_parse_buffer(self, create_buffer_view(file_content.data, file_content.size), filepath); } static CHECK_RESULT int file_path_join(BufferView directory, BufferView file, char **result_path) { |