Don't require a ':' character after every key in scene files #19

Merged
Sara merged 5 commits from dont-require-colon-in-scene into development 2023-07-17 14:48:08 +00:00
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);
_parse_value(file, value, &argc, argv);
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