From 3b8e78386ece32ad2d79541635d6db839104731a Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Wed, 21 Jan 2026 09:40:04 +0000 Subject: [PATCH 1/4] Fixes --- source/libublsettings-char.c | 4 +++- source/libublsettings-file.c | 2 +- source/libublsettings.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/libublsettings-char.c b/source/libublsettings-char.c index 1048179..a588e6f 100644 --- a/source/libublsettings-char.c +++ b/source/libublsettings-char.c @@ -481,7 +481,9 @@ config_str yon_char_parsed_new (int *size, ...){ void yon_char_parsed_free(config_str source, int size){ if (source&&size>0){ for (int i=0;i Date: Wed, 28 Jan 2026 10:55:22 +0600 Subject: [PATCH 2/4] Fixed char_from_long function --- source/libublsettings-char.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/libublsettings-char.c b/source/libublsettings-char.c index a588e6f..9b8951c 100644 --- a/source/libublsettings-char.c +++ b/source/libublsettings-char.c @@ -286,14 +286,9 @@ char *yon_char_from_double(double int_to_convert) char *yon_char_from_long(long int_to_convert) { - int i = 1; - double convert_check = (double)int_to_convert; - for (i = 1; convert_check >= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = malloc(i * sizeof(char) + 1); - memset(ch,0,i * sizeof(char) + 1); + size_t size = 20 * sizeof(char) + 1; + char *ch = malloc(size); + memset(ch,0,size); sprintf(ch, "%ld", int_to_convert); return ch; } -- 2.35.1 From 4230fef85482000692f5c2c4abd4a6b67ff11abd Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Mon, 2 Feb 2026 17:20:21 +0600 Subject: [PATCH 3/4] Test fix for negative numbers conversion --- source/libublsettings-char.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libublsettings-char.c b/source/libublsettings-char.c index 9b8951c..73781ad 100644 --- a/source/libublsettings-char.c +++ b/source/libublsettings-char.c @@ -250,7 +250,7 @@ char *yon_char_from_int(int int_to_convert) { int i = snprintf( NULL, 0, "%d", int_to_convert ); - char *ch = malloc(i * sizeof(char) + 1); + char *ch = malloc(i * sizeof(char) + 1+ int_to_convert<0?1:0); memset(ch,0,i * sizeof(char) + 1); sprintf(ch, "%d", int_to_convert); return ch; @@ -264,7 +264,7 @@ char *yon_char_from_float(float int_to_convert) { convert_check = convert_check / 10; } - char *ch = malloc((i + 9)* sizeof(char)); + char *ch = malloc((i + 9)* sizeof(char)+ int_to_convert<0?1:0); memset(ch,0,(i + 9)* sizeof(char)); sprintf(ch, "%.2f", int_to_convert); return ch; @@ -278,7 +278,7 @@ char *yon_char_from_double(double int_to_convert) { convert_check = convert_check / 10; } - char *ch = malloc((i + 9)* sizeof(char)); + char *ch = malloc((i + 9)* sizeof(char)+ int_to_convert<0?1:0); memset(ch,0,(i + 9)* sizeof(char)); sprintf(ch, "%.2f", int_to_convert); return ch; @@ -286,7 +286,7 @@ char *yon_char_from_double(double int_to_convert) char *yon_char_from_long(long int_to_convert) { - size_t size = 20 * sizeof(char) + 1; + size_t size = 20 * sizeof(char) + 1 + int_to_convert<0?1:0; char *ch = malloc(size); memset(ch,0,size); sprintf(ch, "%ld", int_to_convert); -- 2.35.1 From 6eb6c2c88a47dbbb52e8b0d1f3b37ce3ab11b899 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Thu, 5 Feb 2026 18:46:10 +0600 Subject: [PATCH 4/4] Added new function --- source/libublsettings-char.c | 7 +++++++ source/libublsettings.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/source/libublsettings-char.c b/source/libublsettings-char.c index 73781ad..1ef29c6 100644 --- a/source/libublsettings-char.c +++ b/source/libublsettings-char.c @@ -552,6 +552,13 @@ config_str yon_char_parsed_merge(config_str array1, int size1, config_str array2 } } +int yon_char_parsed_compare(const config_str a, const config_str b){ + const config_str str_a = (const config_str)a; + const config_str str_b = (const config_str)b; + + return strcmp(*str_a,*str_b); +} + config_str yon_char_parsed_merge_no_repeats(config_str array1, int size1, config_str array2, int size2, int *final_size){ if (array1&&array2&&size1>0&&size2>0){ *final_size=0; diff --git a/source/libublsettings.h b/source/libublsettings.h index 1d38310..7e39499 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -998,6 +998,12 @@ config_str yon_char_parsed_cut(config_str parsed, int size, int pos); int yon_char_parsed_find_element(config_str parsed, int size, char *target); +/// @brief Checks if two config_str elements are equal or not for sort functions +/// @param a pinter for first compared element; +/// @param b pointer for second compared element; +/// @return -1 if ab +int yon_char_parsed_compare(const config_str a, const config_str b); + int yon_char_find_last_symbol_before_length(char *string, char target, int length); /**yon_char_wrap_to_length(char *target, unsigned int length, int *size) -- 2.35.1