1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

Revert this - was getting crashes in both OSX and MSVC 2003

in config_file.c inside config_get_entry
This commit is contained in:
twinaphex 2018-10-10 23:34:16 +02:00
parent 9862579610
commit 7d0dba3007
6 changed files with 399 additions and 457 deletions

View File

@ -66,7 +66,7 @@ struct config_include_list
};
static config_file_t *config_file_new_internal(
const char *path, unsigned depth, config_file_cb_t *cb);
const char *path, unsigned depth);
static int config_sort_compare_func(struct config_entry_list *a,
struct config_entry_list *b)
@ -267,7 +267,7 @@ static void add_child_list(config_file_t *parent, config_file_t *child)
parent->tail = NULL;
}
static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
static void add_sub_conf(config_file_t *conf, char *path)
{
char real_path[PATH_MAX_LENGTH];
config_file_t *sub_conf = NULL;
@ -314,7 +314,7 @@ static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
#endif
sub_conf = (config_file_t*)
config_file_new_internal(real_path, conf->include_depth + 1, cb);
config_file_new_internal(real_path, conf->include_depth + 1);
if (!sub_conf)
return;
@ -324,7 +324,7 @@ static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
}
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)
{
char *comment = NULL;
char *key_tmp = NULL;
@ -351,7 +351,7 @@ static bool parse_line(config_file_t *conf,
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
else
add_sub_conf(conf, path, cb);
add_sub_conf(conf, path);
free(path);
}
goto error;
@ -396,19 +396,18 @@ error:
}
static config_file_t *config_file_new_internal(
const char *path, unsigned depth, config_file_cb_t *cb)
const char *path, unsigned depth)
{
RFILE *file = NULL;
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
if (!conf)
return NULL;
conf->path = NULL;
conf->entries = NULL;
conf->tail = NULL;
conf->includes = NULL;
conf->include_depth = 0;
conf->guaranteed_no_duplicates = false ;
conf->path = NULL;
conf->entries = NULL;
conf->tail = NULL;
conf->includes = NULL;
conf->include_depth = 0;
if (!path || !*path)
return conf;
@ -456,7 +455,7 @@ static config_file_t *config_file_new_internal(
continue;
}
if (*line && parse_line(conf, list, line, cb))
if (*line && parse_line(conf, list, line))
{
if (conf->entries)
conf->tail->next = list;
@ -464,9 +463,6 @@ static config_file_t *config_file_new_internal(
conf->entries = list;
conf->tail = list;
if (cb != NULL && list->key != NULL && list->value != NULL)
cb->config_file_new_entry_cb(list->key, list->value) ;
}
free(line);
@ -555,12 +551,11 @@ config_file_t *config_file_new_from_string(const char *from_string)
if (!from_string)
return conf;
conf->path = NULL;
conf->entries = NULL;
conf->tail = NULL;
conf->includes = NULL;
conf->include_depth = 0;
conf->guaranteed_no_duplicates = false ;
conf->path = NULL;
conf->entries = NULL;
conf->tail = NULL;
conf->includes = NULL;
conf->include_depth = 0;
lines = string_split(from_string, "\n");
if (!lines)
@ -585,7 +580,7 @@ config_file_t *config_file_new_from_string(const char *from_string)
if (line && conf)
{
if (*line && parse_line(conf, list, line, NULL))
if (*line && parse_line(conf, list, line))
{
if (conf->entries)
conf->tail->next = list;
@ -605,13 +600,9 @@ config_file_t *config_file_new_from_string(const char *from_string)
return conf;
}
config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t *cb)
{
return config_file_new_internal(path, 0, cb);
}
config_file_t *config_file_new(const char *path)
{
return config_file_new_internal(path, 0, NULL);
return config_file_new_internal(path, 0);
}
static struct config_entry_list *config_get_entry(const config_file_t *conf,
@ -843,7 +834,7 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
void config_set_string(config_file_t *conf, const char *key, const char *val)
{
struct config_entry_list *last = conf->entries;
struct config_entry_list *entry = conf->guaranteed_no_duplicates?NULL:config_get_entry(conf, key, &last);
struct config_entry_list *entry = config_get_entry(conf, key, &last);
if (entry && !entry->readonly)
{

View File

@ -58,7 +58,6 @@ struct config_file
struct config_entry_list *entries;
struct config_entry_list *tail;
unsigned include_depth;
bool guaranteed_no_duplicates;
struct config_include_list *includes;
};
@ -66,13 +65,6 @@ struct config_file
typedef struct config_file config_file_t;
struct config_file_cb
{
void (*config_file_new_entry_cb)(char*, char*);
};
typedef struct config_file_cb config_file_cb_t ;
/* Config file format
* - # are treated as comments. Rest of the line is ignored.
* - Format is: key = value. There can be as many spaces as you like in-between.
@ -87,11 +79,6 @@ typedef struct config_file_cb config_file_cb_t ;
* NULL path will create an empty config file. */
config_file_t *config_file_new(const char *path);
/* Loads a config file. Returns NULL if file doesn't exist.
* NULL path will create an empty config file.
* Includes cb callbacks to run custom code during config file processing.*/
config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t *cb);
/* Load a config file from a string. */
config_file_t *config_file_new_from_string(const char *from_string);
@ -191,4 +178,3 @@ bool config_file_exists(const char *path);
RETRO_END_DECLS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -77,8 +77,7 @@ enum cheat_rumble_type
RUMBLE_TYPE_LT_VALUE,
RUMBLE_TYPE_GT_VALUE,
RUMBLE_TYPE_INCREASE_BY_VALUE,
RUMBLE_TYPE_DECREASE_BY_VALUE,
RUMBLE_TYPE_END_LIST
RUMBLE_TYPE_DECREASE_BY_VALUE
};
/* Some codes are ridiculously large - over 10000 bytes */
@ -179,8 +178,6 @@ struct cheat_manager
unsigned browse_address;
char working_desc[CHEAT_DESC_SCRATCH_SIZE] ;
char working_code[CHEAT_CODE_SCRATCH_SIZE] ;
unsigned int loading_cheat_size;
unsigned int loading_cheat_offset;
};
typedef struct cheat_manager cheat_manager_t;

View File

@ -45,7 +45,7 @@ RETRO_BEGIN_DECLS
#endif
#ifndef MAX_CHEAT_COUNTERS
#define MAX_CHEAT_COUNTERS 6000
#define MAX_CHEAT_COUNTERS 100
#endif
#define MENU_SETTINGS_CORE_INFO_NONE 0xffff

View File

@ -4745,7 +4745,7 @@ static bool setting_append_list(
config_uint_cbs(cheat_manager_state.working_cheat.rumble_type, CHEAT_RUMBLE_TYPE,
setting_uint_action_left_default,setting_uint_action_right_default,
MENU_ENUM_LABEL_RUMBLE_TYPE_DISABLED,&setting_get_string_representation_uint_as_enum,
RUMBLE_TYPE_DISABLED,RUMBLE_TYPE_END_LIST-1,1) ;
RUMBLE_TYPE_DISABLED,RUMBLE_TYPE_GT_VALUE,1) ;
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
config_uint_cbs(cheat_manager_state.working_cheat.rumble_value, CHEAT_RUMBLE_VALUE,