gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Wed Sep 15 09:09:17 EDT 2021
Updated via https://github.com/Gnucash/gnucash/commit/a5d101d1 (commit)
via https://github.com/Gnucash/gnucash/commit/73ad5b12 (commit)
via https://github.com/Gnucash/gnucash/commit/aa0668f9 (commit)
from https://github.com/Gnucash/gnucash/commit/134de3ab (commit)
commit a5d101d1bef6939d029075a5863065b08cba9e05
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Sep 15 20:25:56 2021 +0800
[utest-Account] test gnc_account_get_map_entry
diff --git a/libgnucash/engine/test/utest-Account.cpp b/libgnucash/engine/test/utest-Account.cpp
index 9fca144cd..2759c38f0 100644
--- a/libgnucash/engine/test/utest-Account.cpp
+++ b/libgnucash/engine/test/utest-Account.cpp
@@ -1220,6 +1220,52 @@ test_gnc_account_kvp_setters_getters (Fixture *fixture, gconstpointer pData)
xaccAccountDestroy (account);
}
+static void
+set_kvp_string_path (Account *acc, std::vector<std::string> const & path,
+ const char *value)
+{
+ xaccAccountBeginEdit(acc);
+ if (value)
+ {
+ GValue v = G_VALUE_INIT;
+ g_value_init (&v, G_TYPE_STRING);
+ g_value_set_string (&v, value);
+ qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, path);
+ g_value_unset (&v);
+ }
+ else
+ qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, path);
+
+ xaccAccountCommitEdit(acc);
+}
+
+static void
+test_gnc_account_get_map_entry (Fixture *fixture, gconstpointer pData)
+{
+ Account *account = xaccMallocAccount (gnc_account_get_book (fixture->acct));
+
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", NULL), ==, nullptr);
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "two"), ==, nullptr);
+
+ set_kvp_string_path (account, {"one"}, "uno");
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", NULL), ==, "uno");
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "two"), ==, nullptr);
+
+ set_kvp_string_path (account, {"one", "two"}, "dos");
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "tw0"), ==, nullptr);
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "two"), ==, "dos");
+
+ set_kvp_string_path (account, {"one"}, nullptr);
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", NULL), ==, nullptr);
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "two"), ==, nullptr);
+
+ set_kvp_string_path (account, {"one", "two"}, "dos");
+ g_assert_cmpstr (gnc_account_get_map_entry (account, "one", "two"), ==, "dos");
+
+ xaccAccountBeginEdit (account);
+ xaccAccountDestroy (account);
+}
+
static void
test_gnc_account_insert_remove_split (Fixture *fixture, gconstpointer pData)
{
@@ -2703,6 +2749,7 @@ test_suite_account (void)
// GNC_TEST_ADD (suitename, "xaccAcctChildrenEqual", Fixture, NULL, setup, test_xaccAcctChildrenEqual, teardown );
// GNC_TEST_ADD (suitename, "xaccAccountEqual", Fixture, NULL, setup, test_xaccAccountEqual, teardown );
GNC_TEST_ADD (suitename, "gnc account kvp getters & setters", Fixture, NULL, setup, test_gnc_account_kvp_setters_getters, teardown );
+ GNC_TEST_ADD (suitename, "test_gnc_account_get_map_entry", Fixture, NULL, setup, test_gnc_account_get_map_entry, teardown );
GNC_TEST_ADD (suitename, "gnc account insert & remove split", Fixture, NULL, setup, test_gnc_account_insert_remove_split, teardown );
GNC_TEST_ADD (suitename, "xaccAccount Insert and Remove Lot", Fixture, &good_data, setup, test_xaccAccountInsertRemoveLot, teardown );
GNC_TEST_ADD (suitename, "xaccAccountRecomputeBalance", Fixture, &some_data, setup, test_xaccAccountRecomputeBalance, teardown );
commit 73ad5b1265bf2f7e3f0bfeea04d5eeea4cf117ee
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Sep 15 20:40:19 2021 +0800
[gnc-glib-utils] use g_stpcpy instead of gnc_strcat
g_stpcpy will use stpcpy wherever available.
diff --git a/libgnucash/core-utils/gnc-glib-utils.c b/libgnucash/core-utils/gnc-glib-utils.c
index c15e1dd8d..e79cf7e02 100644
--- a/libgnucash/core-utils/gnc-glib-utils.c
+++ b/libgnucash/core-utils/gnc-glib-utils.c
@@ -328,14 +328,6 @@ void gnc_gpid_kill(GPid pid)
#endif /* G_OS_WIN32 */
}
-static inline char*
-gnc_strcat (char* dest, const char* src)
-{
- while (*dest) dest++;
- while ((*dest++ = *src++));
- return --dest;
-}
-
gchar *
gnc_g_list_stringjoin (GList *list_of_strings, const gchar *sep)
{
@@ -352,9 +344,9 @@ gnc_g_list_stringjoin (GList *list_of_strings, const gchar *sep)
p = retval = (gchar*) g_malloc0 (length * sizeof (gchar) + 1);
for (GList *n = list_of_strings; n; n = n->next)
{
- p = gnc_strcat (p, (gchar*)n->data);
+ p = g_stpcpy (p, (gchar*)n->data);
if (n->next && sep)
- p = gnc_strcat (p, sep);
+ p = g_stpcpy (p, sep);
}
return retval;
commit aa0668f9e64ab6d02bc66f57971896c064192ef2
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Sep 15 20:39:55 2021 +0800
Revert "[account.cpp] deprecate old dxacc* functions"
This reverts commit d290c3c45d0dbcebfa8c953b04bad01633bcffcf. These
functions are not deprecated after all.
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index cad33174d..f6ac68f38 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2715,7 +2715,6 @@ DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
gnc_commodity *commodity;
gnc_commodity_table *table;
- PWARN ("this function is deprecated and will be removed in 5.x");
if ((!acc) || (!currency)) return;
g_value_init (&v, G_TYPE_STRING);
g_value_set_string (&v, s);
@@ -3374,7 +3373,6 @@ DxaccAccountGetCurrency (const Account *acc)
const char *s = NULL;
gnc_commodity_table *table;
- PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-currency"});
if (G_VALUE_HOLDS_STRING (&v))
@@ -4985,7 +4983,6 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
void
dxaccAccountSetPriceSrc(Account *acc, const char *src)
{
- PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return;
if (xaccAccountIsPriced(acc))
@@ -5014,7 +5011,6 @@ const char*
dxaccAccountGetPriceSrc(const Account *acc)
{
GValue v = G_VALUE_INIT;
- PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
if (!xaccAccountIsPriced(acc)) return NULL;
@@ -5030,7 +5026,6 @@ void
dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
{
GValue v = G_VALUE_INIT;
- PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return;
if (!xaccAccountIsPriced(acc)) return;
xaccAccountBeginEdit(acc);
@@ -5048,7 +5043,6 @@ const char*
dxaccAccountGetQuoteTZ(const Account *acc)
{
GValue v = G_VALUE_INIT;
- PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
if (!xaccAccountIsPriced(acc)) return NULL;
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, {"old-quote-tz"});
Summary of changes:
libgnucash/core-utils/gnc-glib-utils.c | 12 ++------
libgnucash/engine/Account.cpp | 6 ----
libgnucash/engine/test/utest-Account.cpp | 47 ++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list