From baf75c9c78268a6d8ef8f72829e59bba12656e78 Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 17 Jul 2023 00:36:37 +0200 Subject: [PATCH 1/4] no longer requiring at least one colon in a scene config element This now allows for `player;` instead of requiring `player:;` --- src/corelib/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index 3a225f1..f638bf4 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -177,7 +177,7 @@ int _validate_config(FILE* file) { } } while(c != ';'); - return colon_count == 1; + return colon_count <= 1; } static From 1ae19b5d04f361280bff1058717afed4dba059ee Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 17 Jul 2023 00:38:49 +0200 Subject: [PATCH 2/4] adjusted _parse_key to also allow for configs without arguments --- src/corelib/scene.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index f638bf4..0d6b57e 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -82,7 +82,7 @@ void _parse_key(FILE* file, char* out) { char c; do { c = fgetc(file); - if(c == ':') { + if(c == ':' || c == ';') { *out = '\0'; } else if(c == '#') { freadto(file, '\n'); @@ -90,7 +90,7 @@ void _parse_key(FILE* file, char* out) { *out = c; ++out; } - } while(c != ':'); + } while(c != ':' && c != ';'); } static From 3dd5b82cb0bbbe6cb6338e365f66eea8013a74aa Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 17 Jul 2023 00:41:15 +0200 Subject: [PATCH 3/4] 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); From 56956f93307c88d44d81efa8c12a4da39957ba2a Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 17 Jul 2023 00:43:50 +0200 Subject: [PATCH 4/4] _parse_key will now return 1 if the key DOES have arguments --- src/corelib/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index 9e81aa6..f5a6318 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -92,7 +92,7 @@ int _parse_key(FILE* file, char* out) { } } while(c != ':' && c != ';'); - return c != ':'; + return c == ':'; } static