Merge pull request 'Don't require a ':' character after every key in scene files' (#19) from dont-require-colon-in-scene into development

Reviewed-on: #19
development
Sara 2023-07-17 14:48:07 +00:00
commit a741f3c473
1 changed files with 10 additions and 6 deletions

View File

@ -78,11 +78,11 @@ 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);
if(c == ':') {
if(c == ':' || c == ';') {
*out = '\0';
} else if(c == '#') {
freadto(file, '\n');
@ -90,7 +90,9 @@ void _parse_key(FILE* file, char* out) {
*out = c;
++out;
}
} while(c != ':');
} 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);
if(has_args) {
_parse_value(file, value, &argc, argv);
}
struct type_handler_t* handler = _find_handler_for(key);
@ -177,7 +181,7 @@ int _validate_config(FILE* file) {
}
} while(c != ';');
return colon_count == 1;
return colon_count <= 1;
}
static