From 3dd5b82cb0bbbe6cb6338e365f66eea8013a74aa Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 17 Jul 2023 00:41:15 +0200 Subject: [PATCH] parse_key now detects if the key has arguments or not, parse config will not parse nonexistent values --- src/corelib/scene.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index 0d6b57e..9e81aa6 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -78,7 +78,7 @@ int nextnw(FILE* file) { } static -void _parse_key(FILE* file, char* out) { +int _parse_key(FILE* file, char* out) { char c; do { c = fgetc(file); @@ -91,6 +91,8 @@ void _parse_key(FILE* file, char* out) { ++out; } } while(c != ':' && c != ';'); + + return c != ':'; } static @@ -137,9 +139,11 @@ void _parse_config(FILE* file) { char begin = nextnw(file); ungetc(begin, file); - _parse_key(file, key); + int has_args = _parse_key(file, key); ungetc(nextnw(file), file); - _parse_value(file, value, &argc, argv); + if(has_args) { + _parse_value(file, value, &argc, argv); + } struct type_handler_t* handler = _find_handler_for(key);