diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-04 18:18:42 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-04 22:31:50 -0500 |
commit | 3a6d55f85ff2898c92072b6510adb4ee5ee1bfcf (patch) | |
tree | 3b26a58abd2117ce7d62473278404f5771a1be4b | |
parent | 4138ca4db4cdb92b693e51d6ea59a06bc5e6964c (diff) |
bug fixes
-rw-r--r-- | main.c | 10 | ||||
-rw-r--r-- | toc.c | 2 | ||||
-rw-r--r-- | types.c | 2 |
3 files changed, 7 insertions, 7 deletions
@@ -25,7 +25,7 @@ make sure #export still works properly fix cgen_ident_to_str for unicode idents check for leaks --- -nice syntax for importing something into a namespace +nice syntax for #including something into a namespace run stuff at compile time without assigning it to a constant #compile_only declarations constants in structs @@ -77,13 +77,14 @@ int main(int argc, char **argv) { file.filename = in_filename; Location file_where = {0}; file_where.file = &file; - char *contents = read_entire_file(&main_allocr, in_filename, file_where); - + file.ctx = &err_ctx; + char *contents = read_file_contents(&main_allocr, in_filename, file_where); + if (!contents) return EXIT_FAILURE; + Identifiers idents; idents_create(&idents); Tokenizer t; file.contents = contents; - file.ctx = &err_ctx; tokr_create(&t, &idents, &err_ctx, &main_allocr); if (!tokenize_file(&t, &file)) { err_text_important(&err_ctx, "Errors occured during preprocessing.\n"); @@ -143,7 +144,6 @@ int main(int argc, char **argv) { block_exit(NULL, f.stmts); /* exit global scope */ - free(contents - 1); /* -1 because we put a 0 byte at the beginning */ allocr_free_all(&main_allocr); evalr_free(&ev); fclose(out); @@ -84,7 +84,7 @@ static size_t compiler_sizeof(Type *t); #include "copy.c" /* returns NULL on error */ -static char *read_entire_file(Allocator *a, const char *filename, Location where) { +static char *read_file_contents(Allocator *a, const char *filename, Location where) { FILE *in = fopen(filename, "r"); if (!in) { @@ -2446,7 +2446,7 @@ static bool types_stmt(Typer *tr, Statement *s) { char *filename = eval_expr_as_cstr(tr, &s->inc.filename, "import filename"); if (!filename) return false; - char *contents = read_entire_file(tr->allocr, filename, s->where); + char *contents = read_file_contents(tr->allocr, filename, s->where); if (!contents) return false; Tokenizer tokr; |