parse_key now detects if the key has arguments or not, parse config will not parse nonexistent values

pull/19/head
Sara 2023-07-17 00:41:15 +02:00
parent 1ae19b5d04
commit 3dd5b82cb0
1 changed files with 7 additions and 3 deletions

View File

@ -78,7 +78,7 @@ int nextnw(FILE* file) {
} }
static static
void _parse_key(FILE* file, char* out) { int _parse_key(FILE* file, char* out) {
char c; char c;
do { do {
c = fgetc(file); c = fgetc(file);
@ -91,6 +91,8 @@ void _parse_key(FILE* file, char* out) {
++out; ++out;
} }
} while(c != ':' && c != ';'); } while(c != ':' && c != ';');
return c != ':';
} }
static static
@ -137,9 +139,11 @@ void _parse_config(FILE* file) {
char begin = nextnw(file); char begin = nextnw(file);
ungetc(begin, file); ungetc(begin, file);
_parse_key(file, key); int has_args = _parse_key(file, key);
ungetc(nextnw(file), file); ungetc(nextnw(file), file);
if(has_args) {
_parse_value(file, value, &argc, argv); _parse_value(file, value, &argc, argv);
}
struct type_handler_t* handler = _find_handler_for(key); struct type_handler_t* handler = _find_handler_for(key);