From 3c582b07865c48b02039c31ca3f025b5d8fa491d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 24 Dec 2024 10:25:39 +0600 Subject: [PATCH] Fixed removing of default-equaled parameters --- source/libublsettings.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 7e634d2..db90dbf 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -1764,6 +1764,11 @@ void yon_config_register(char *key, char *config_load, void *data){ if (data){ if (!__yon__config__strings||!(current=(yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))){ { + yon_config_parameter *cur_default = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__default__strings,key); + if ((cur_default&&cur_default->data&&!strcmp((char*)cur_default->data,(char*)data))){ + yon_config_remove_by_key(current->key); + return; + } if (__yon__config__strings){ char *data_copy = yon_char_new(data); yon_config_parameter* dict=NULL; @@ -1790,22 +1795,17 @@ void yon_config_register(char *key, char *config_load, void *data){ yon_char_parsed_free(section,size); } else if ((current = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))){ - yon_config_parameter *cur_default = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__default__strings,current->key); - if ((cur_default&&((yon_config_parameter*)current)->flag1==1&&!strcmp((char*)cur_default->data,(char*)data))){ - yon_config_remove_by_key(current->key); - } else if ((current->data&&data!=__yon__config__strings->data&&strcmp(__yon__config__strings->data,data))||!current->data){ - current->data=yon_char_new(data); - current->flag1=1; - current->data_type=DICTIONARY_CHAR_TYPE; - current->load_command=config_load; - if (yon_dictionary_get(&__yon_config_ignored, current->key)){ - __yon_config_ignored = yon_dictionary_rip(__yon_config_ignored); - } - int size=0; - config_str section = yon_char_parse(config_load,&size," "); - current->section=yon_char_new(section[yon_char_parsed_check_exist(section,size,"get")+1]); - yon_char_parsed_free(section,size); + current->data=yon_char_new(data); + current->flag1=1; + current->data_type=DICTIONARY_CHAR_TYPE; + current->load_command=config_load; + if (yon_dictionary_get(&__yon_config_ignored, current->key)){ + __yon_config_ignored = yon_dictionary_rip(__yon_config_ignored); } + int size=0; + config_str section = yon_char_parse(config_load,&size," "); + current->section=yon_char_new(section[yon_char_parsed_check_exist(section,size,"get")+1]); + yon_char_parsed_free(section,size); } } else if ((current = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))) { current->data=NULL;