gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Fri Nov 10 05:58:59 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/8f7eecd3 (commit)
via https://github.com/Gnucash/gnucash/commit/ae58c126 (commit)
via https://github.com/Gnucash/gnucash/commit/8a54bf26 (commit)
via https://github.com/Gnucash/gnucash/commit/ab7ead39 (commit)
from https://github.com/Gnucash/gnucash/commit/e6a30f77 (commit)
commit 8f7eecd3e94df935549a7e8cecd155ba99ad122a
Merge: e6a30f7708 ae58c12601
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Nov 10 18:58:35 2023 +0800
Merge branch 'icu-list-formatter' into stable #1791
commit ae58c12601d4a89643080744e5abe32574c7b59d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Nov 10 18:56:07 2023 +0800
[import-main-matcher] don't quote account fullnames
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 003cb229de..ef2991d523 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1871,9 +1871,8 @@ get_peer_acct_names (Split *split)
(g_list_find (accounts_seen, account)))
continue;
gchar *name = gnc_account_get_full_name (account);
- names = g_list_prepend (names, g_strdup_printf ("\"%s\"", name));
+ names = g_list_prepend (names, name);
accounts_seen = g_list_prepend (accounts_seen, account);
- g_free (name);
}
names = g_list_sort (names, (GCompareFunc)g_utf8_collate);
auto retval = gnc_list_formatter (names);
commit 8a54bf26580cb138f32f8386646806d5383c068e
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 2 12:28:29 2023 +0800
use gnc_list_formatter instead of gnc_g_list_stringjoin (..., ", ");
diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index c9bee2493e..fe902f69a8 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -3230,7 +3230,7 @@ gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page)
if (show)
{
- char *str = gnc_g_list_stringjoin (show, ", ");
+ char *str = gnc_list_formatter (show);
t_list = g_list_prepend
(t_list, g_strdup_printf ("%s %s", _("Show:"), str));
g_free (str);
@@ -3238,7 +3238,7 @@ gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page)
if (hide)
{
- char *str = gnc_g_list_stringjoin (hide, ", ");
+ char *str = gnc_list_formatter (hide);
t_list = g_list_prepend
(t_list, g_strdup_printf ("%s %s", _("Hide:"), str));
g_free (str);
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 5a8eb41ca2..003cb229de 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1876,7 +1876,7 @@ get_peer_acct_names (Split *split)
g_free (name);
}
names = g_list_sort (names, (GCompareFunc)g_utf8_collate);
- gchar *retval = gnc_g_list_stringjoin (names, ", ");
+ auto retval = gnc_list_formatter (names);
g_list_free_full (names, g_free);
g_list_free (accounts_seen);
return retval;
commit ab7ead39ca8426079318ac28bb4bdd3b7140cd25
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 2 12:28:09 2023 +0800
use icu::ListFormatter to combine a list strings into a string
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index c44912efa7..7abbddaf8a 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -46,6 +46,7 @@
#include <cinttypes>
#include <unicode/calendar.h>
+#include <unicode/listformatter.h>
#include "gnc-date.h"
#include "gnc-date-p.h"
@@ -1652,3 +1653,29 @@ gnc_date_load_funcs (void)
Testfuncs *tf = g_slice_new (Testfuncs);
return tf;
}
+
+
+gchar*
+gnc_list_formatter (GList *strings)
+{
+ g_return_val_if_fail (strings, nullptr);
+
+ UErrorCode status = U_ZERO_ERROR;
+ auto formatter = icu::ListFormatter::createInstance(status);
+ std::vector<icu::UnicodeString> strvec;
+ icu::UnicodeString result;
+ std::string retval;
+
+ for (auto n = strings; n; n = g_list_next (n))
+ strvec.push_back (static_cast<char*>(n->data));
+
+ formatter->format (strvec.data(), strvec.size(), result, status);
+
+ if (U_FAILURE(status))
+ PERR ("Unicode error");
+ else
+ result.toUTF8String(retval);
+
+ delete formatter;
+ return g_strdup (retval.c_str());
+}
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 2193d0de10..fcf2ff5f55 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -813,6 +813,17 @@ void gnc_gdate_set_prev_fiscal_year_start (GDate *date, const GDate *year_end);
* fiscal year. The year field of this argument is ignored. */
void gnc_gdate_set_prev_fiscal_year_end (GDate *date, const GDate *year_end);
+
+
+/** This function takes a GList of char*, and uses locale-sensitive
+ * list formatter.
+ *
+ * @param strings The GList* of char*.
+ *
+ * @returns a newly allocated char*
+ */
+gchar* gnc_list_formatter (GList* strings);
+
//@}
//@}
Summary of changes:
gnucash/gnome/gnc-plugin-page-register.c | 4 ++--
gnucash/import-export/import-main-matcher.cpp | 5 ++---
libgnucash/engine/gnc-date.cpp | 27 +++++++++++++++++++++++++++
libgnucash/engine/gnc-date.h | 11 +++++++++++
4 files changed, 42 insertions(+), 5 deletions(-)
More information about the gnucash-changes
mailing list