diff --git a/common/test-core/unittest-support.c b/common/test-core/unittest-support.c index 86cbe44ca1..dddcef8240 100644 --- a/common/test-core/unittest-support.c +++ b/common/test-core/unittest-support.c @@ -143,6 +143,29 @@ test_clear_error_list (void) message_queue = NULL; } + +gboolean +test_list_substring_handler (const char *log_domain, GLogLevelFlags log_level, + const gchar *msg, gpointer user_data) +{ + GList *list = g_list_first (message_queue); + const guint fatal = G_LOG_FLAG_FATAL; + while (list) + { + TestErrorStruct *error = (TestErrorStruct*)list->data; + if (!g_strcmp0 (log_domain, error->log_domain) + && ((log_level | fatal) == (error->log_level | fatal)) + && g_strrstr (msg, error->msg)) + { + ++(error->hits); + return FALSE; + } + list = g_list_next (list); + } + /* No list or no matches, fall through */ + return test_checked_substring_handler (log_domain, log_level, msg, user_data); +} + static gboolean do_test_list_handler (const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data, gboolean hits) @@ -205,6 +228,27 @@ do_test_checked_handler (const char *log_domain, GLogLevelFlags log_level, } +gboolean +test_checked_substring_handler (const char *log_domain, GLogLevelFlags log_level, + const gchar *msg, gpointer user_data) +{ + TestErrorStruct *tdata = (TestErrorStruct*)user_data; + if ((tdata == NULL) + || (tdata->log_domain != NULL + && g_strcmp0 (log_domain, tdata->log_domain)) + || (tdata->log_level && tdata->log_level != log_level) + || (tdata->msg && !g_strrstr (msg, tdata->msg))) + { + gchar *level = test_log_level (log_level); + g_printf ( "<%s> (%s) %s\n", level, log_domain, msg); + g_free (level); + g_assert (log_level ^ G_LOG_FLAG_FATAL); + return FALSE; + } + ++(tdata->hits); + return FALSE; +} + gboolean test_checked_handler (const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data ) diff --git a/common/test-core/unittest-support.h b/common/test-core/unittest-support.h index 61503dbe6c..f9e4849c0c 100644 --- a/common/test-core/unittest-support.h +++ b/common/test-core/unittest-support.h @@ -178,6 +178,14 @@ GSList *test_log_set_fatal_handler (GSList *list, TestErrorStruct *error, */ void test_free_log_handler (gpointer item); +/** + * Check that the user_data error message is a substring of the + * actual error otherwise assert. Displays the error (and asserts + * if G_LOG_FLAG_FATAL is TRUE) if NULL is passed as user_data, + * but a NULL or 0 value member matches anything. + */ +gboolean test_checked_substring_handler (const char *log_domain, GLogLevelFlags log_level, + const gchar *msg, gpointer user_data); /** * Check the user_data against the actual error and assert on any * differences. Displays the error (and asserts if G_LOG_FLAG_FATAL @@ -213,6 +221,18 @@ gboolean test_null_handler (const char *log_domain, GLogLevelFlags log_level, void test_add_error (TestErrorStruct *error); void test_clear_error_list (void); +/** + * Checks received errors against the list created by + * test_add_error. Rather than checking for an exact match, this function + * checks using a substring match. If the list is empty or nothing + * matches, passes control on to test_checked_substring_handler, giving + * the opportunity for an additional check that's not in the list + * (set user_data to NULL if you want test_checked_handler to + * immediately print the error). + */ +gboolean test_list_substring_handler (const char *log_domain, GLogLevelFlags log_level, + const gchar *msg, gpointer user_data); + /** * Checks received errors against the list created by * test_add_error. If the list is empty or nothing matches, passes diff --git a/libgnucash/core-utils/gnc-glib-utils.h b/libgnucash/core-utils/gnc-glib-utils.h index 2999894f5d..a381825a93 100644 --- a/libgnucash/core-utils/gnc-glib-utils.h +++ b/libgnucash/core-utils/gnc-glib-utils.h @@ -39,6 +39,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** @name Character Sets @{ */ @@ -186,6 +190,10 @@ void gnc_gpid_kill(GPid pid); /** @} */ +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* GNC_GLIB_UTILS_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/Account.c b/libgnucash/engine/Account.cpp similarity index 96% rename from libgnucash/engine/Account.c rename to libgnucash/engine/Account.cpp index bcf5d0a952..1b32f9de13 100644 --- a/libgnucash/engine/Account.c +++ b/libgnucash/engine/Account.cpp @@ -171,7 +171,7 @@ gchar *gnc_account_name_violations_errmsg (const gchar *separator, GList* invali for ( node = invalid_account_names; node; node = g_list_next(node)) { if ( !account_list ) - account_list = node->data; + account_list = static_cast(node->data); else { gchar *tmp_list = NULL; @@ -251,9 +251,9 @@ gnc_account_init(Account* acc) priv->parent = NULL; priv->children = NULL; - priv->accountName = CACHE_INSERT(""); - priv->accountCode = CACHE_INSERT(""); - priv->description = CACHE_INSERT(""); + priv->accountName = static_cast(qof_string_cache_insert("")); + priv->accountCode = static_cast(qof_string_cache_insert("")); + priv->description = static_cast(qof_string_cache_insert("")); priv->type = ACCT_TYPE_NONE; @@ -473,10 +473,10 @@ gnc_account_set_property (GObject *object, break; case PROP_TYPE: // NEED TO BE CONVERTED TO A G_TYPE_ENUM - xaccAccountSetType(account, g_value_get_int(value)); + xaccAccountSetType(account, static_cast(g_value_get_int(value))); break; case PROP_COMMODITY: - xaccAccountSetCommodity(account, g_value_get_object(value)); + xaccAccountSetCommodity(account, static_cast(g_value_get_object(value))); break; case PROP_COMMODITY_SCU: xaccAccountSetCommoditySCU(account, g_value_get_int(value)); @@ -491,19 +491,19 @@ gnc_account_set_property (GObject *object, gnc_account_set_balance_dirty(account); break; case PROP_START_BALANCE: - number = g_value_get_boxed(value); + number = static_cast(g_value_get_boxed(value)); gnc_account_set_start_balance(account, *number); break; case PROP_START_CLEARED_BALANCE: - number = g_value_get_boxed(value); + number = static_cast(g_value_get_boxed(value)); gnc_account_set_start_cleared_balance(account, *number); break; case PROP_START_RECONCILED_BALANCE: - number = g_value_get_boxed(value); + number = static_cast(g_value_get_boxed(value)); gnc_account_set_start_reconciled_balance(account, *number); break; case PROP_POLICY: - gnc_account_set_policy(account, g_value_get_pointer(value)); + gnc_account_set_policy(account, static_cast(g_value_get_pointer(value))); break; case PROP_MARK: xaccAccountSetMark(account, g_value_get_int(value)); @@ -595,7 +595,7 @@ gnc_account_class_init (AccountClass *klass) "repeated. but no two accounts that share " "a parent may have the same name.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -606,7 +606,7 @@ gnc_account_class_init (AccountClass *klass) "all its parent account names to indicate " "a unique account.", NULL, - G_PARAM_READABLE)); + static_cast(G_PARAM_READABLE))); g_object_class_install_property (gobject_class, @@ -618,7 +618,7 @@ gnc_account_class_init (AccountClass *klass) "be reporting code that is a synonym for " "the accountName.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -630,7 +630,7 @@ gnc_account_class_init (AccountClass *klass) "to be a longer, 1-5 sentence description of " "what this account is all about.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -641,7 +641,7 @@ gnc_account_class_init (AccountClass *klass) "by the user. It is intended to highlight the " "account based on the users wishes.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -652,7 +652,7 @@ gnc_account_class_init (AccountClass *klass) "for the user to attach any other text that " "they would like to associate with the account.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -665,7 +665,7 @@ gnc_account_class_init (AccountClass *klass) ACCT_TYPE_NONE, NUM_ACCOUNT_TYPES - 1, ACCT_TYPE_BANK, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -676,7 +676,7 @@ gnc_account_class_init (AccountClass *klass) "'stuff' stored in this account, whether " "it is USD, gold, stock, etc.", GNC_TYPE_COMMODITY, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -691,7 +691,7 @@ gnc_account_class_init (AccountClass *klass) 0, G_MAXINT32, 1000000, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -704,7 +704,7 @@ gnc_account_class_init (AccountClass *klass) "mismatched values in older versions of " "GnuCash.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -719,7 +719,7 @@ gnc_account_class_init (AccountClass *klass) "affect the sort order of the account. Note: " "This value can only be set to TRUE.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -733,7 +733,7 @@ gnc_account_class_init (AccountClass *klass) "the engine to say a split has been modified. " "Note: This value can only be set to TRUE.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -749,7 +749,7 @@ gnc_account_class_init (AccountClass *klass) "the 'starting balance' will represent the " "summation of the splits up to that date.", GNC_TYPE_NUMERIC, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -766,7 +766,7 @@ gnc_account_class_init (AccountClass *klass) "balance' will represent the summation of the " "splits up to that date.", GNC_TYPE_NUMERIC, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -783,7 +783,7 @@ gnc_account_class_init (AccountClass *klass) "balance' will represent the summation of the " "splits up to that date.", GNC_TYPE_NUMERIC, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -818,7 +818,7 @@ gnc_account_class_init (AccountClass *klass) "the starting balance and all reconciled splits " "in the account.", GNC_TYPE_NUMERIC, - G_PARAM_READABLE)); + static_cast(G_PARAM_READABLE))); g_object_class_install_property (gobject_class, @@ -826,7 +826,7 @@ gnc_account_class_init (AccountClass *klass) g_param_spec_pointer ("policy", "Policy", "The account lots policy.", - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -837,7 +837,7 @@ gnc_account_class_init (AccountClass *klass) 0, G_MAXINT16, 0, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -847,7 +847,7 @@ gnc_account_class_init (AccountClass *klass) "Whether the account maps to an entry on an " "income tax document.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -859,7 +859,7 @@ gnc_account_class_init (AccountClass *klass) "United States it is used to transfer totals " "into tax preparation software.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -868,7 +868,7 @@ gnc_account_class_init (AccountClass *klass) "Tax Source", "This specifies where exported name comes from.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -880,7 +880,7 @@ gnc_account_class_init (AccountClass *klass) (gint64)1, G_MAXINT64, (gint64)1, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -890,7 +890,7 @@ gnc_account_class_init (AccountClass *klass) "Whether the account should be hidden in the " "account tree.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -900,7 +900,7 @@ gnc_account_class_init (AccountClass *klass) "Whether the account is a placeholder account which does not " "allow transactions to be created, edited or deleted.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -910,7 +910,7 @@ gnc_account_class_init (AccountClass *klass) "The account filter is a value saved to allow " "filters to be recalled.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -920,7 +920,7 @@ gnc_account_class_init (AccountClass *klass) "The account sort order is a value saved to allow " "the sort order to be recalled.", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -929,7 +929,7 @@ gnc_account_class_init (AccountClass *klass) "Account Sort Reversed", "Parameter to store whether the sort order is reversed or not.", FALSE, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -940,7 +940,7 @@ gnc_account_class_init (AccountClass *klass) (gint64)1, G_MAXINT64, (gint64)1, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -950,7 +950,7 @@ gnc_account_class_init (AccountClass *klass) "The online account which corresponds to this " "account for OFX import", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property( gobject_class, @@ -959,7 +959,7 @@ gnc_account_class_init (AccountClass *klass) "Associated income account", "Used by the OFX importer.", GNC_TYPE_GUID, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -969,7 +969,7 @@ gnc_account_class_init (AccountClass *klass) "The AqBanking account which corresponds to this " "account for AQBanking import", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, PROP_AB_BANK_CODE, @@ -978,7 +978,7 @@ gnc_account_class_init (AccountClass *klass) "The online account which corresponds to this " "account for AQBanking import", NULL, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -989,7 +989,7 @@ gnc_account_class_init (AccountClass *klass) (gint64)1, G_MAXINT64, (gint64)1, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -999,7 +999,7 @@ gnc_account_class_init (AccountClass *klass) "The time of the last transaction retrieval for this " "account.", GNC_TYPE_TIMESPEC, - G_PARAM_READWRITE)); + static_cast(G_PARAM_READWRITE))); } @@ -1028,7 +1028,7 @@ static Account * gnc_coll_get_root_account (QofCollection *col) { if (!col) return NULL; - return qof_collection_get_data (col); + return static_cast(qof_collection_get_data (col)); } static void @@ -1101,7 +1101,7 @@ xaccMallocAccount (QofBook *book) g_return_val_if_fail (book, NULL); - acc = g_object_new (GNC_TYPE_ACCOUNT, NULL); + acc = static_cast(g_object_new (GNC_TYPE_ACCOUNT, NULL)); xaccInitAccount (acc, book); qof_event_gen (&acc->inst, QOF_EVENT_CREATE, NULL); @@ -1118,7 +1118,7 @@ gnc_account_create_root (QofBook *book) rpriv = GET_PRIVATE(root); xaccAccountBeginEdit(root); rpriv->type = ACCT_TYPE_ROOT; - CACHE_REPLACE(rpriv->accountName, "Root Account"); + qof_string_cache_replace((void const **)(&rpriv->accountName), "Root Account"); mark_account (root); xaccAccountCommitEdit(root); gnc_book_set_root_account(book, root); @@ -1135,7 +1135,7 @@ xaccCloneAccount(const Account *from, QofBook *book) g_return_val_if_fail(QOF_IS_BOOK(book), NULL); ENTER (" "); - ret = g_object_new (GNC_TYPE_ACCOUNT, NULL); + ret = static_cast(g_object_new (GNC_TYPE_ACCOUNT, NULL)); g_return_val_if_fail (ret, NULL); from_priv = GET_PRIVATE(from); @@ -1147,9 +1147,9 @@ xaccCloneAccount(const Account *from, QofBook *book) * Also let caller issue the generate_event (EVENT_CREATE) */ priv->type = from_priv->type; - priv->accountName = CACHE_INSERT(from_priv->accountName); - priv->accountCode = CACHE_INSERT(from_priv->accountCode); - priv->description = CACHE_INSERT(from_priv->description); + priv->accountName = static_cast(qof_string_cache_insert(from_priv->accountName)); + priv->accountCode = static_cast(qof_string_cache_insert(from_priv->accountCode)); + priv->description = static_cast(qof_string_cache_insert(from_priv->description)); qof_instance_copy_kvp (QOF_INSTANCE (ret), QOF_INSTANCE (from)); @@ -1229,7 +1229,7 @@ xaccFreeAccount (Account *acc) for (lp = priv->lots; lp; lp = lp->next) { - GNCLot *lot = lp->data; + GNCLot *lot = static_cast(lp->data); gnc_lot_destroy (lot); } g_list_free (priv->lots); @@ -1261,15 +1261,16 @@ xaccFreeAccount (Account *acc) */ } - CACHE_REPLACE(priv->accountName, NULL); - CACHE_REPLACE(priv->accountCode, NULL); - CACHE_REPLACE(priv->description, NULL); + qof_string_cache_remove(priv->accountName); + qof_string_cache_remove(priv->accountCode); + qof_string_cache_remove(priv->description); + priv->accountName = priv->accountCode = priv->description = nullptr; /* zero out values, just in case stray * pointers are pointing here. */ - priv->parent = NULL; - priv->children = NULL; + priv->parent = nullptr; + priv->children = nullptr; priv->balance = gnc_numeric_zero(); priv->cleared_balance = gnc_numeric_zero(); @@ -1327,7 +1328,7 @@ destroy_pending_splits_for_account(QofInstance *ent, gpointer acc) Split *split; if (xaccTransIsOpen(trans)) - while ((split = xaccTransFindSplitByAccount(trans, acc))) + while ((split = xaccTransFindSplitByAccount(trans, static_cast(acc)))) xaccSplitDestroy(split); } @@ -1365,7 +1366,7 @@ xaccAccountCommitEdit (Account *acc) slist = g_list_copy(priv->splits); for (lp = slist; lp; lp = lp->next) { - Split *s = lp->data; + Split *s = static_cast(lp->data); xaccSplitDestroy (s); } g_list_free(slist); @@ -1392,7 +1393,7 @@ xaccAccountCommitEdit (Account *acc) /* the lots should be empty by now */ for (lp = priv->lots; lp; lp = lp->next) { - GNCLot *lot = lp->data; + GNCLot *lot = static_cast(lp->data); gnc_lot_destroy (lot); } } @@ -1455,7 +1456,7 @@ xaccAcctChildrenEqual(const GList *na, while (na) { - Account *aa = na->data; + Account *aa = static_cast(na->data); Account *ab; GList *node = g_list_find_custom ((GList*)nb, aa, (GCompareFunc)compare_account_by_name); @@ -1465,7 +1466,7 @@ xaccAcctChildrenEqual(const GList *na, PINFO ("Unable to find matching child account."); return FALSE; } - ab = node->data; + ab = static_cast(node->data); if (!xaccAccountEqual(aa, ab, check_guids)) { char sa[GUID_ENCODING_LENGTH + 1]; @@ -1883,7 +1884,7 @@ xaccClearMarkDown (Account *acc, short val) priv->mark = val; for (node = priv->children; node; node = node->next) { - xaccClearMarkDown(node->data, val); + xaccClearMarkDown(static_cast(node->data), val); } } @@ -2254,7 +2255,7 @@ xaccAccountSetName (Account *acc, const char *str) return; xaccAccountBeginEdit(acc); - CACHE_REPLACE(priv->accountName, str); + qof_string_cache_replace((void const **)(&priv->accountName), str); mark_account (acc); xaccAccountCommitEdit(acc); } @@ -2273,7 +2274,7 @@ xaccAccountSetCode (Account *acc, const char *str) return; xaccAccountBeginEdit(acc); - CACHE_REPLACE(priv->accountCode, str ? str : ""); + qof_string_cache_replace((void const **)(&priv->accountCode), str ? str : ""); mark_account (acc); xaccAccountCommitEdit(acc); } @@ -2292,7 +2293,7 @@ xaccAccountSetDescription (Account *acc, const char *str) return; xaccAccountBeginEdit(acc); - CACHE_REPLACE(priv->description, str ? str : ""); + qof_string_cache_replace((void const **)(&priv->description), str ? str : ""); mark_account (acc); xaccAccountCommitEdit(acc); } @@ -2691,7 +2692,7 @@ Account * gnc_account_nth_child (const Account *parent, gint num) { g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL); - return g_list_nth_data(GET_PRIVATE(parent)->children, num); + return static_cast(g_list_nth_data(GET_PRIVATE(parent)->children, num)); } gint @@ -2706,7 +2707,7 @@ gnc_account_n_descendants (const Account *account) priv = GET_PRIVATE(account); for (node = priv->children; node; node = g_list_next(node)) { - count += gnc_account_n_descendants(node->data) + 1; + count += gnc_account_n_descendants(static_cast(node->data)) + 1; } return count; } @@ -2745,7 +2746,7 @@ gnc_account_get_tree_depth (const Account *account) for (node = priv->children; node; node = g_list_next(node)) { - child_depth = gnc_account_get_tree_depth(node->data); + child_depth = gnc_account_get_tree_depth(static_cast(node->data)); depth = MAX(depth, child_depth); } return depth + 1; @@ -2768,7 +2769,7 @@ gnc_account_get_descendants (const Account *account) { descendants = g_list_append(descendants, child->data); descendants = g_list_concat(descendants, - gnc_account_get_descendants(child->data)); + gnc_account_get_descendants(static_cast(child->data))); } return descendants; } @@ -2793,7 +2794,7 @@ gnc_account_get_descendants_sorted (const Account *account) { descendants = g_list_append(descendants, child->data); descendants = g_list_concat(descendants, - gnc_account_get_descendants_sorted(child->data)); + gnc_account_get_descendants_sorted(static_cast(child->data))); } g_list_free(children); return descendants; @@ -2813,7 +2814,7 @@ gnc_account_lookup_by_name (const Account *parent, const char * name) ppriv = GET_PRIVATE(parent); for (node = ppriv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); cpriv = GET_PRIVATE(child); if (g_strcmp0(cpriv->accountName, name) == 0) return child; @@ -2823,7 +2824,7 @@ gnc_account_lookup_by_name (const Account *parent, const char * name) * Recursively search each of the child accounts next */ for (node = ppriv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); result = gnc_account_lookup_by_name (child, name); if (result) return result; @@ -2846,7 +2847,7 @@ gnc_account_lookup_by_code (const Account *parent, const char * code) ppriv = GET_PRIVATE(parent); for (node = ppriv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); cpriv = GET_PRIVATE(child); if (g_strcmp0(cpriv->accountCode, code) == 0) return child; @@ -2856,7 +2857,7 @@ gnc_account_lookup_by_code (const Account *parent, const char * code) * Recursively search each of the child accounts next */ for (node = ppriv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); result = gnc_account_lookup_by_code (child, code); if (result) return result; @@ -2884,7 +2885,7 @@ gnc_account_lookup_by_full_name_helper (const Account *parent, ppriv = GET_PRIVATE(parent); for (node = ppriv->children; node; node = node->next) { - Account *account = node->data; + Account *account = static_cast(node->data); priv = GET_PRIVATE(account); if (g_strcmp0(priv->accountName, names[0]) == 0) @@ -2950,7 +2951,7 @@ gnc_account_foreach_child (const Account *acc, priv = GET_PRIVATE(acc); for (node = priv->children; node; node = node->next) { - thunk (node->data, user_data); + thunk (static_cast(node->data), user_data); } } @@ -2969,7 +2970,7 @@ gnc_account_foreach_descendant (const Account *acc, priv = GET_PRIVATE(acc); for (node = priv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); thunk(child, user_data); gnc_account_foreach_descendant(child, thunk, user_data); } @@ -2991,7 +2992,7 @@ gnc_account_foreach_descendant_until (const Account *acc, priv = GET_PRIVATE(acc); for (node = priv->children; node; node = node->next) { - child = node->data; + child = static_cast(node->data); result = thunk(child, user_data); if (result) return(result); @@ -3040,7 +3041,6 @@ gnc_account_get_full_name(const Account *account) AccountPrivate *priv; const Account *a; char *fullname; - gchar **names; int level; /* So much for hardening the API. Too many callers to this function don't @@ -3067,7 +3067,7 @@ gnc_account_get_full_name(const Account *account) /* Get all the pointers in the right order. The root node "entry" * becomes the terminating NULL pointer for the array of strings. */ - names = g_malloc(level * sizeof(gchar *)); + gchar* names[level*sizeof(gchar*)]; names[--level] = NULL; for (a = account; level > 0; a = priv->parent) { @@ -3077,7 +3077,6 @@ gnc_account_get_full_name(const Account *account) /* Build the full name */ fullname = g_strjoinv(account_separator, names); - g_free(names); return fullname; } @@ -3267,7 +3266,7 @@ xaccAccountGetProjectedMinimumBalance (const Account *acc) today = gnc_time64_get_today_end(); for (node = g_list_last(priv->splits); node; node = node->prev) { - Split *split = node->data; + Split *split = static_cast(node->data); if (!seen_a_transaction) { @@ -3383,7 +3382,7 @@ xaccAccountGetPresentBalance (const Account *acc) today = gnc_time64_get_today_end(); for (node = g_list_last(priv->splits); node; node = node->prev) { - Split *split = node->data; + Split *split = static_cast(node->data); if (xaccTransGetDate (xaccSplitGetParent (split)) <= today) return xaccSplitGetBalance (split); @@ -3517,7 +3516,7 @@ typedef struct static void xaccAccountBalanceHelper (Account *acc, gpointer data) { - CurrencyBalance *cb = data; + CurrencyBalance *cb = static_cast(data); gnc_numeric balance; if (!cb->fn || !cb->currency) @@ -3531,7 +3530,7 @@ xaccAccountBalanceHelper (Account *acc, gpointer data) static void xaccAccountBalanceAsOfDateHelper (Account *acc, gpointer data) { - CurrencyBalance *cb = data; + CurrencyBalance *cb = static_cast(data); gnc_numeric balance; g_return_if_fail (cb->asOfDateFn && cb->currency); @@ -3768,7 +3767,7 @@ xaccAccountFindOpenLots (const Account *acc, priv = GET_PRIVATE(acc); for (lot_list = priv->lots; lot_list; lot_list = lot_list->next) { - GNCLot *lot = lot_list->data; + GNCLot *lot = static_cast(lot_list->data); /* If this lot is closed, then ignore it */ if (gnc_lot_is_closed (lot)) @@ -4111,7 +4110,7 @@ xaccAccountStringToEnum(const char* str) /********************************************************************\ \********************************************************************/ -static char * +static char const * account_type_name[NUM_ACCOUNT_TYPES] = { N_("Bank"), @@ -4763,7 +4762,7 @@ finder_help_function(const Account *acc, const char *description, priv = GET_PRIVATE(acc); for (slp = g_list_last(priv->splits); slp; slp = slp->prev) { - Split *lsplit = slp->data; + Split *lsplit = static_cast(slp->data); Transaction *ltrans = xaccSplitGetParent(lsplit); if (g_strcmp0 (description, xaccTransGetDescription (ltrans)) == 0) @@ -4821,7 +4820,7 @@ gnc_account_join_children (Account *to_parent, Account *from_parent) ENTER (" "); children = g_list_copy(from_priv->children); for (node = children; node; node = g_list_next(node)) - gnc_account_append_child(to_parent, node->data); + gnc_account_append_child(to_parent, static_cast (node->data)); g_list_free(children); LEAVE (" "); } @@ -4839,12 +4838,12 @@ gnc_account_merge_children (Account *parent) ppriv = GET_PRIVATE(parent); for (node_a = ppriv->children; node_a; node_a = node_a->next) { - Account *acc_a = node_a->data; + Account *acc_a = static_cast (node_a->data); priv_a = GET_PRIVATE(acc_a); for (node_b = node_a->next; node_b; node_b = g_list_next(node_b)) { - Account *acc_b = node_b->data; + Account *acc_b = static_cast (node_b->data); priv_b = GET_PRIVATE(acc_b); if (0 != null_strcmp(priv_a->accountName, priv_b->accountName)) @@ -4881,7 +4880,7 @@ gnc_account_merge_children (Account *parent) /* consolidate transactions */ while (priv_b->splits) - xaccSplitSetAccount (priv_b->splits->data, acc_a); + xaccSplitSetAccount (static_cast (priv_b->splits->data), acc_a); /* move back one before removal. next iteration around the loop * will get the node after node_b */ @@ -4906,7 +4905,7 @@ xaccSplitsBeginStagedTransactionTraversals (GList *splits) for (lp = splits; lp; lp = lp->next) { - Split *s = lp->data; + Split *s = static_cast (lp->data); Transaction *trans = s->parent; if (trans) @@ -4987,7 +4986,7 @@ xaccAccountStagedTransactionTraversal (const Account *acc, * a thunk removes splits from this account. */ next = g_list_next(split_p); - s = split_p->data; + s = static_cast (split_p->data); trans = s->parent; if (trans && (trans->marker < stage)) { @@ -5021,15 +5020,15 @@ gnc_account_tree_staged_transaction_traversal (const Account *acc, priv = GET_PRIVATE(acc); for (acc_p = priv->children; acc_p; acc_p = g_list_next(acc_p)) { - retval = gnc_account_tree_staged_transaction_traversal(acc_p->data, stage, - thunk, cb_data); + retval = gnc_account_tree_staged_transaction_traversal(static_cast (acc_p->data), + stage, thunk, cb_data); if (retval) return retval; } /* Now this account */ for (split_p = priv->splits; split_p; split_p = g_list_next(split_p)) { - s = split_p->data; + s = static_cast (split_p->data); trans = s->parent; if (trans && (trans->marker < stage)) { @@ -5294,7 +5293,7 @@ highestProbability(gpointer key, gpointer value, gpointer data) { /* Save the new highest probability and the assoaciated account guid */ account_i->probability = GPOINTER_TO_INT(value); - account_i->account_guid = key; + account_i->account_guid = static_cast (key); } } @@ -5370,8 +5369,8 @@ gnc_account_imap_find_account_bayes (GncImportMatchMap *imap, GList *tokens) account_c->account_guid, account_c->token_count, tokenInfo.total_count); - account_p = g_hash_table_lookup(running_probabilities, - account_c->account_guid); + account_p = static_cast ( + g_hash_table_lookup(running_probabilities, account_c->account_guid)); /* if the account exists in the list then continue * the running probablities @@ -5612,7 +5611,7 @@ build_bayes_layer_two (const char *key, const GValue *value, gpointer user_data) g_free (guid); - imapInfo_node = g_malloc(sizeof(*imapInfo_node)); + imapInfo_node = static_cast (g_malloc(sizeof(*imapInfo_node))); imapInfo_node->source_account = imapInfo->source_account; imapInfo_node->map_account = map_account; @@ -5688,7 +5687,7 @@ build_non_bayes (const char *key, const GValue *value, gpointer user_data) PINFO("build_non_bayes: kvp_path is '%s'", kvp_path); - imapInfo_node = g_malloc(sizeof(*imapInfo_node)); + imapInfo_node = static_cast (g_malloc(sizeof(*imapInfo_node))); imapInfo_node->source_account = imapInfo->source_account; imapInfo_node->map_account = xaccAccountLookup (guid, book); @@ -5810,7 +5809,7 @@ look_for_old_separator_descendants (Account *root, gchar *full_name, const gchar /* Go through list of top level accounts */ for (ptr = top_accounts; ptr; ptr = g_list_next (ptr)) { - const gchar *name = xaccAccountGetName (ptr->data); + const gchar *name = xaccAccountGetName (static_cast (ptr->data)); // we are looking for the longest top level account that matches if (g_str_has_prefix (full_name, name)) @@ -5935,7 +5934,7 @@ convert_imap_account (Account *acc) for (node = imap_list; node; node = g_list_next (node)) { Account *map_account = NULL; - GncImapInfo *imapInfo = node->data; + GncImapInfo *imapInfo = static_cast (node->data); // Lets start doing stuff map_account = look_for_old_mapping (imapInfo); @@ -5980,7 +5979,7 @@ gnc_account_imap_convert_bayes (QofBook *book) /* Go through list of accounts */ for (ptr = accts; ptr; ptr = g_list_next (ptr)) { - Account *acc = ptr->data; + Account *acc = static_cast (ptr->data); convert_imap_account (acc); } @@ -6020,7 +6019,7 @@ static QofObject account_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_ACCOUNT, DI(.type_label = ) "Account", - DI(.create = ) (gpointer)xaccMallocAccount, + DI(.create = ) (void*(*)(QofBook*)) xaccMallocAccount, DI(.book_begin = ) NULL, DI(.book_end = ) gnc_account_book_end, DI(.is_dirty = ) qof_collection_is_dirty, diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h index 13f265c888..2f80632f87 100644 --- a/libgnucash/engine/Account.h +++ b/libgnucash/engine/Account.h @@ -48,6 +48,9 @@ #include "gnc-engine.h" #include "policy.h" +#ifdef __cplusplus +extern "C" { +#endif typedef gnc_numeric (*xaccGetBalanceFn)( const Account *account ); typedef gnc_numeric (*xaccGetBalanceInCurrencyFn) ( @@ -1517,6 +1520,10 @@ const char * dxaccAccountGetQuoteTZ (const Account *account); * in the gnome-search parameter list. Be careful when you use this. */ #define ACCOUNT_MATCH_ALL_TYPE "account-match-all" +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* XACC_ACCOUNT_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/AccountP.h b/libgnucash/engine/AccountP.h index a3a2bdd642..a1ab6a0747 100644 --- a/libgnucash/engine/AccountP.h +++ b/libgnucash/engine/AccountP.h @@ -41,6 +41,10 @@ #include "Account.h" +#ifdef __cplusplus +extern "C" { +#endif + #define GNC_ID_ROOT_ACCOUNT "RootAccount" /** STRUCTS *********************************************************/ @@ -149,5 +153,8 @@ typedef struct AccountTestFunctions* _utest_account_fill_functions(void); +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif /* XACC_ACCOUNT_P_H */ diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt index eeeb7f9428..993eb5e624 100644 --- a/libgnucash/engine/CMakeLists.txt +++ b/libgnucash/engine/CMakeLists.txt @@ -136,7 +136,7 @@ ADD_CUSTOM_COMMAND ( ADD_CUSTOM_TARGET(iso-4217-c DEPENDS ${ISO_4217_C}) SET (engine_SOURCES - Account.c + Account.cpp Recurrence.c Query.c SchedXaction.c diff --git a/libgnucash/engine/Makefile.am b/libgnucash/engine/Makefile.am index 49c70ccea6..088b9b4f8e 100644 --- a/libgnucash/engine/Makefile.am +++ b/libgnucash/engine/Makefile.am @@ -18,7 +18,7 @@ AM_CPPFLAGS = \ libgncmod_engine_la_SOURCES = \ - Account.c \ + Account.cpp \ Recurrence.c \ Query.c \ SchedXaction.c \ diff --git a/libgnucash/engine/Split.h b/libgnucash/engine/Split.h index 1c450809e7..4d7f41706c 100644 --- a/libgnucash/engine/Split.h +++ b/libgnucash/engine/Split.h @@ -41,6 +41,10 @@ typedef struct _SplitClass SplitClass; #include "gnc-commodity.h" #include "gnc-engine.h" +#ifdef __cplusplus +extern "C" { +#endif + /* --- type macros --- */ #define GNC_TYPE_SPLIT (gnc_split_get_type ()) #define GNC_SPLIT(o) \ @@ -550,6 +554,10 @@ gnc_numeric xaccSplitVoidFormerValue(const Split *split); /** \deprecated */ #define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* XACC_SPLIT_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h index a196e89553..2d143898e4 100644 --- a/libgnucash/engine/Transaction.h +++ b/libgnucash/engine/Transaction.h @@ -94,6 +94,10 @@ typedef struct _TransactionClass TransactionClass; #include "gnc-engine.h" #include "Split.h" +#ifdef __cplusplus +extern "C" { +#endif + /* --- type macros --- */ #define GNC_TYPE_TRANSACTION (gnc_transaction_get_type ()) #define GNC_TRANSACTION(o) \ @@ -789,6 +793,10 @@ void xaccTransDump (const Transaction *trans, const char *tag); /** \deprecated */ #define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* XACC_TRANSACTION_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/gnc-commodity.h b/libgnucash/engine/gnc-commodity.h index 8daa83b375..b5dcc93120 100644 --- a/libgnucash/engine/gnc-commodity.h +++ b/libgnucash/engine/gnc-commodity.h @@ -53,6 +53,10 @@ typedef struct _GncCommodityNamespaceClass gnc_commodity_namespaceClass; #include #include "gnc-engine.h" +#ifdef __cplusplus +extern "C" { +#endif + /* --- type macros --- */ #define GNC_TYPE_COMMODITY (gnc_commodity_get_type ()) #define GNC_COMMODITY(o) \ @@ -1056,6 +1060,10 @@ void gnc_monetary_list_free(MonetaryList *list); /** @} */ +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* GNC_COMMODITY_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/gnc-engine.h b/libgnucash/engine/gnc-engine.h index f8f1c986ef..651cf44e52 100644 --- a/libgnucash/engine/gnc-engine.h +++ b/libgnucash/engine/gnc-engine.h @@ -39,6 +39,10 @@ #include #include "qof.h" +#ifdef __cplusplus +extern "C" { +#endif + /** \name QofLogModule identifiers */ // @{ #define GNC_MOD_ROOT "gnc" @@ -257,6 +261,9 @@ void gnc_engine_signal_commit_error( QofBackendError errcode ); #define GNC_OWNER_GUID "owner-guid" #define GNC_SX_ID "sched-xaction" +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif /** @} */ diff --git a/libgnucash/engine/gnc-features.h b/libgnucash/engine/gnc-features.h index 39f1c03233..feefe8d079 100644 --- a/libgnucash/engine/gnc-features.h +++ b/libgnucash/engine/gnc-features.h @@ -38,6 +38,10 @@ #include "qof.h" +#ifdef __cplusplus +extern "C" { +#endif + /** @name Defined features @{ */ @@ -64,6 +68,10 @@ gchar *gnc_features_test_unknown (QofBook *book); */ void gnc_features_set_used (QofBook *book, const gchar *feature); +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* GNC_FEATURES_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/gnc-lot.h b/libgnucash/engine/gnc-lot.h index 64e1dfaa0c..c725b6f8f7 100644 --- a/libgnucash/engine/gnc-lot.h +++ b/libgnucash/engine/gnc-lot.h @@ -65,6 +65,10 @@ #include "gnc-engine.h" /*#include "gnc-lot-p.h"*/ +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { QofInstanceClass parent_class; @@ -174,6 +178,11 @@ GNCLot * gnc_lot_make_default (Account * acc); #define LOT_BALANCE "balance" #define LOT_TITLE "lot-title" #define LOT_NOTES "notes" + +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* GNC_LOT_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/gnc-pricedb.h b/libgnucash/engine/gnc-pricedb.h index f7eefa3e1e..671c87ea2e 100644 --- a/libgnucash/engine/gnc-pricedb.h +++ b/libgnucash/engine/gnc-pricedb.h @@ -31,6 +31,10 @@ typedef struct _GncPriceDBClass GNCPriceDBClass; #include "gnc-commodity.h" #include "gnc-engine.h" +#ifdef __cplusplus +extern "C" { +#endif + /* --- type macros --- */ #define GNC_TYPE_PRICE (gnc_price_get_type ()) #define GNC_PRICE(o) \ @@ -662,6 +666,10 @@ void gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f); /** @} */ +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* GNC_PRICEDB_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/policy.h b/libgnucash/engine/policy.h index 42dc812ce7..71e4c0ed8e 100644 --- a/libgnucash/engine/policy.h +++ b/libgnucash/engine/policy.h @@ -37,6 +37,10 @@ #ifndef XACC_POLICY_H #define XACC_POLICY_H +#ifdef __cplusplus +extern "C" { +#endif + typedef struct gncpolicy_s GNCPolicy; /** Valid Policy List @@ -83,6 +87,10 @@ GNCPolicy *xaccGetFIFOPolicy (void); */ GNCPolicy *xaccGetLIFOPolicy (void); +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* XACC_POLICY_H */ /** @} */ /** @} */ diff --git a/libgnucash/engine/qof-string-cache.cpp b/libgnucash/engine/qof-string-cache.cpp index 70e79d7e6d..7390a63e03 100644 --- a/libgnucash/engine/qof-string-cache.cpp +++ b/libgnucash/engine/qof-string-cache.cpp @@ -132,4 +132,11 @@ qof_string_cache_insert(gconstpointer key) return NULL; } +void +qof_string_cache_replace(gconstpointer * dst, gconstpointer src) +{ + gpointer tmp {qof_string_cache_insert(src)}; + qof_string_cache_remove(&dst); + *dst = tmp; +} /* ************************ END OF FILE ***************************** */ diff --git a/libgnucash/engine/qof-string-cache.h b/libgnucash/engine/qof-string-cache.h index 4aaa485a6d..2fd52740af 100644 --- a/libgnucash/engine/qof-string-cache.h +++ b/libgnucash/engine/qof-string-cache.h @@ -86,6 +86,10 @@ void qof_string_cache_remove(gconstpointer key); */ gpointer qof_string_cache_insert(gconstpointer key); +/** Same as CACHE_REPLACE below, but safe to call from C++. + */ +void qof_string_cache_replace(gconstpointer * dst, gconstpointer src); + #define CACHE_INSERT(str) qof_string_cache_insert((gconstpointer)(str)) #define CACHE_REMOVE(str) qof_string_cache_remove((str)) diff --git a/libgnucash/engine/test/utest-Account.cpp b/libgnucash/engine/test/utest-Account.cpp index 06dae62c04..3007907053 100644 --- a/libgnucash/engine/test/utest-Account.cpp +++ b/libgnucash/engine/test/utest-Account.cpp @@ -467,13 +467,7 @@ test_gnc_account_list_name_violations (Fixture *fixture, gconstpointer pData) { auto log_level = static_cast(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL); auto log_domain = "gnc.engine"; -#ifdef USE_CLANG_FUNC_SIG -#define _func "GList *gnc_account_list_name_violations(QofBook *, const gchar *)" -#else -#define _func "gnc_account_list_name_violations" -#endif - auto msg = _func ": assertion 'separator != NULL' failed"; -#undef _func + auto msg = ": assertion 'separator != NULL' failed"; auto check = test_error_struct_new(log_domain, log_level, msg); GList *results, *res_iter; auto sep = ":"; @@ -482,7 +476,7 @@ test_gnc_account_list_name_violations (Fixture *fixture, gconstpointer pData) * affect the test_log_fatal_handler */ GLogFunc oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, check); - g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, check); + g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_substring_handler, check); g_assert (gnc_account_list_name_violations (NULL, NULL) == NULL); g_assert_cmpint (check->hits, ==, 1); g_assert (gnc_account_list_name_violations (book, NULL) == NULL); @@ -759,19 +753,13 @@ test_xaccCloneAccount (Fixture *fixture, gconstpointer pData) Account *clone; QofBook *book = gnc_account_get_book (fixture->acct); auto loglevel = static_cast(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL); -#ifdef USE_CLANG_FUNC_SIG -#define _func "Account *xaccCloneAccount(const Account *, QofBook *)" -#else -#define _func "xaccCloneAccount" -#endif - auto msg1 = _func ": assertion 'GNC_IS_ACCOUNT(from)' failed"; - auto msg2 = _func ": assertion 'QOF_IS_BOOK(book)' failed"; -#undef _func + auto msg1 = ": assertion 'GNC_IS_ACCOUNT(from)' failed"; + auto msg2 = ": assertion 'QOF_IS_BOOK(book)' failed"; auto check = test_error_struct_new("gnc.engine", loglevel, msg1); AccountPrivate *acct_p, *clone_p; auto oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, check); - g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, check); + g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_substring_handler, check); clone = xaccCloneAccount (NULL, book); g_assert (clone == NULL); g_assert_cmpint (check->hits, ==, 1); @@ -1095,14 +1083,8 @@ test_gnc_account_insert_remove_split (Fixture *fixture, gconstpointer pData) Split *split3 = xaccMallocSplit (book); TestSignal sig1, sig2, sig3; AccountPrivate *priv = fixture->func->get_private (fixture->acct); -#ifdef USE_CLANG_FUNC_SIG -#define _func "gboolean gnc_account_insert_split(Account *, Split *)" -#else -#define _func "gnc_account_insert_split" -#endif - auto msg1 = _func ": assertion 'GNC_IS_ACCOUNT(acc)' failed"; - auto msg2 = _func ": assertion 'GNC_IS_SPLIT(s)' failed"; -#undef _func + auto msg1 = ": assertion 'GNC_IS_ACCOUNT(acc)' failed"; + auto msg2 = ": assertion 'GNC_IS_SPLIT(s)' failed"; auto loglevel = static_cast(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL); // auto log_domain = "gnc.engine"; auto check1 = test_error_struct_new("gnc.engine", loglevel, msg1); @@ -1116,7 +1098,7 @@ test_gnc_account_insert_remove_split (Fixture *fixture, gconstpointer pData) test_add_error (check2); logger = g_log_set_handler ("gnc.engine", loglevel, (GLogFunc)test_null_handler, check3); - g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL); + g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_substring_handler, NULL); /* Check that the call fails with invalid account and split (throws) */ g_assert (!gnc_account_insert_split (NULL, split1)); diff --git a/po/POTFILES.in b/po/POTFILES.in index bced61f5a2..190bd219a6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -608,7 +608,7 @@ libgnucash/core-utils/gnc-locale-utils.c libgnucash/core-utils/gnc-path.c libgnucash/core-utils/gnc-prefs.c libgnucash/doc/doxygen_main_page.c -libgnucash/engine/Account.c +libgnucash/engine/Account.cpp libgnucash/engine/business-core.scm libgnucash/engine/cap-gains.c libgnucash/engine/cashobjects.c