comparison config.c @ 792:724bbec47f86

Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
author Michael Pavone <pavone@retrodev.com>
date Sat, 25 Jul 2015 18:22:07 -0700
parents 1b2f8280ba81
children 0b692b5d154b
comparison
equal deleted inserted replaced
791:60686f8d5e48 792:724bbec47f86
51 } 51 }
52 if (curline[0] == '}') { 52 if (curline[0] == '}') {
53 if (started) { 53 if (started) {
54 return head; 54 return head;
55 } 55 }
56 fprintf(stderr, "unexpected } on line %d\n", *line); 56 fatal_error("unexpected } on line %d\n", *line);
57 exit(1);
58 } 57 }
59 58
60 char * end = curline + len - 1; 59 char * end = curline + len - 1;
61 if (*end == '{') { 60 if (*end == '{') {
62 *end = 0; 61 *end = 0;
131 success: 130 success:
132 if (ret) { 131 if (ret) {
133 return ret; 132 return ret;
134 } 133 }
135 no_config: 134 no_config:
136 fputs("Failed to find a config file in ~/.config/blastem/blastem.cfg or in the blastem executable directory\n", stderr); 135 fatal_error("Failed to find a config file in ~/.config/blastem/blastem.cfg or in the blastem executable directory\n");
137 exit(1); 136 //this will never get reached, but the compiler doesn't know that. Let's make it happy
137 return NULL;
138 } 138 }
139 139