mirror of
https://github.com/libretro/RetroArch
synced 2025-03-18 04:21:19 +00:00
Reordered this code somewhat
This commit is contained in:
parent
e7b73e179a
commit
53f3199652
@ -326,56 +326,57 @@ static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
|
|||||||
static bool parse_line(config_file_t *conf,
|
static bool parse_line(config_file_t *conf,
|
||||||
struct config_entry_list *list, char *line, config_file_cb_t *cb)
|
struct config_entry_list *list, char *line, config_file_cb_t *cb)
|
||||||
{
|
{
|
||||||
char *key = NULL;
|
size_t cur_size = 8;
|
||||||
char *key_tmp = NULL;
|
size_t idx = 0;
|
||||||
size_t cur_size = 8;
|
char *comment = NULL;
|
||||||
size_t idx = 0;
|
char *key = NULL;
|
||||||
char *comment = NULL;
|
char *key_tmp = NULL;
|
||||||
|
|
||||||
/* Ignore empty lines */
|
/* Ignore empty lines */
|
||||||
if (string_is_empty(line))
|
if (string_is_empty(line))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Check whether line is a comment */
|
/* Check whether line is a comment */
|
||||||
comment = strip_comment(line);
|
comment = strip_comment(line);
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
{
|
{
|
||||||
|
char *path = NULL;
|
||||||
|
char *include_line = NULL;
|
||||||
|
|
||||||
/* Starting a line with '#include' appends a
|
/* Starting a line with '#include' appends a
|
||||||
* sub-config file */
|
* sub-config file */
|
||||||
if (string_starts_with(comment, "include "))
|
|
||||||
{
|
|
||||||
char *include_line = comment + STRLEN_CONST("include ");
|
|
||||||
char *path = NULL;
|
|
||||||
|
|
||||||
if (string_is_empty(include_line))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
path = extract_value(include_line, false);
|
|
||||||
|
|
||||||
if (!path)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (string_is_empty(path))
|
|
||||||
{
|
|
||||||
free(path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
|
||||||
free(path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_sub_conf(conf, path, cb);
|
|
||||||
free(path);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/* All other comment lines are ignored */
|
/* All other comment lines are ignored */
|
||||||
else
|
if (!string_starts_with(comment, "include "))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
include_line = comment + STRLEN_CONST("include ");
|
||||||
|
|
||||||
|
if (string_is_empty(include_line))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
path = extract_value(include_line, false);
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (string_is_empty(path))
|
||||||
|
{
|
||||||
|
free(path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
||||||
|
free(path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_sub_conf(conf, path, cb);
|
||||||
|
free(path);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skips to first character. */
|
/* Skips to first character. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user