aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 2166ff5..e36d912 100644
--- a/src/main.c
+++ b/src/main.c
@@ -56,6 +56,7 @@ int main(int argc, char **argv) {
char *file_content;
size_t filesize;
TslProgram program;
+ int result = 0;
if(argc != 2) {
usage();
@@ -64,16 +65,22 @@ int main(int argc, char **argv) {
file_content = file_get_content(argv[1], &filesize);
if(!file_content)
- return 1;
+ return 2;
tsl_program_init(&program);
- if(!tsl_parse(file_content, filesize, &program))
- return 2;
- if(!tsl_program_run(&program))
- return 3;
+ if(!tsl_parse(file_content, filesize, &program)) {
+ result = 3;
+ goto cleanup;
+ }
+
+ if(!tsl_program_run(&program)) {
+ result = 4;
+ goto cleanup;
+ }
+ cleanup:
free(file_content);
tsl_program_deinit(&program);
- return 0;
+ return result;
}