From ca7eb41917f544a6c01a6470c2484b4591270264 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 31 Jan 2024 13:54:49 +0600 Subject: [PATCH 1/4] Test fix for saving --- source/libublsettings.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 1c2bf12..90b0b3c 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -1295,16 +1295,18 @@ int yon_config_save_registered(char *path){ dictionary *sections_remove=NULL; for_dictionaries(dct,(dictionary*)__yon__config__strings){ if (((yon_config_parameter*)dct)->flag1==1){ - if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ + if (dct->data&&!yon_char_is_empty(yon_dictionary_get_data(dct,char*))){ ((yon_config_parameter*)dct)->flag1=0; if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } } else if (((yon_config_parameter*)dct)->flag1==-1){ - ((yon_config_parameter*)dct)->flag1=0; - if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); - yon_dictionary_rip(dct); + if (dct->data&&!yon_char_is_empty(yon_dictionary_get_data(dct,char*))){ + ((yon_config_parameter*)dct)->flag1=0; + if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + yon_dictionary_rip(dct); + } } } if (sections_add) From 69c6deb11490c744fa9c4fa0efe21e83b0644d25 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 31 Jan 2024 14:04:24 +0600 Subject: [PATCH 2/4] Test fix for saving --- source/libublsettings.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 90b0b3c..201d220 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -1105,9 +1105,11 @@ int yon_config_append_element(char *key, char *append, char *divider){ int yon_config_set_status(char *key, int status){ check_config{ - if(yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ - ((yon_config_parameter*)__yon__config__strings)->flag1=status; - return 1; + if (!yon_char_is_empty(key)){ + if(yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ + ((yon_config_parameter*)__yon__config__strings)->flag1=status; + return 1; + } } } return 0; From 63e043bee304b6784cafa822e81b563aab9d7649 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 31 Jan 2024 17:47:58 +0600 Subject: [PATCH 3/4] Fixed removing parameters from config --- source/libublsettings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 201d220..24adc76 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -1303,7 +1303,7 @@ int yon_config_save_registered(char *path){ else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } } else if (((yon_config_parameter*)dct)->flag1==-1){ - if (dct->data&&!yon_char_is_empty(yon_dictionary_get_data(dct,char*))){ + if (dct->data&&yon_char_is_empty(yon_dictionary_get_data(dct,char*))){ ((yon_config_parameter*)dct)->flag1=0; if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); From 36ef5bd749acf16b64698a14069b73fc8926854c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 1 Feb 2024 10:59:10 +0600 Subject: [PATCH 4/4] Brackets removal --- source/libublsettings.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 24adc76..19c1e28 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -961,6 +961,11 @@ int yon_config_load_register_no_cleaning(YON_CONFIG_TYPE config_type,char *secti { char *key = yon_char_divide_search(str,"=",-1); char *final_str=yon_char_divide_search(str,"\n",-1); + if ((final_str[0]=='\''&&final_str[strlen(final_str)-1]=='\'')||(final_str[0]=='\"'&&final_str[strlen(final_str)-1]=='\"')){ + final_str[strlen(final_str)-1] = '\0'; + free(yon_char_divide(final_str,0)); + } + if (!yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); @@ -1015,10 +1020,14 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par memset(str, 0, 4096); while (fgets(str, 4096, output)) { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) + if (!yon_char_is_empty(str)&& strcmp(str,"(null)\n")!=0) { char *key = yon_char_divide_search(str,"=",-1); char *final_str=yon_char_divide_search(str,"\n",-1); + if ((final_str[0]=='\''&&final_str[strlen(final_str)-1]=='\'')||(final_str[0]=='\"'&&final_str[strlen(final_str)-1]=='\"')){ + final_str[strlen(final_str)-1] = '\0'; + free(yon_char_divide(final_str,0)); + } if (!yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str));