From dab32807ef9968c020a55c0ae16577169d87b3d0 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 18 Mar 2024 06:11:48 +0800 Subject: [PATCH] [engine/*.cpp] NULL -> nullptr changes It's the done thing --- libgnucash/engine/Account.cpp | 320 +++++++++---------- libgnucash/engine/Split.cpp | 194 +++++------ libgnucash/engine/Transaction.cpp | 216 ++++++------- libgnucash/engine/gnc-budget.cpp | 84 ++--- libgnucash/engine/gnc-commodity.cpp | 210 ++++++------ libgnucash/engine/gnc-date.cpp | 42 +-- libgnucash/engine/gnc-lot.cpp | 84 ++--- libgnucash/engine/gnc-pricedb.cpp | 230 ++++++------- libgnucash/engine/guid.cpp | 8 +- libgnucash/engine/qofbook.cpp | 102 +++--- libgnucash/engine/qofinstance.cpp | 80 ++--- libgnucash/engine/qoflog.cpp | 56 ++-- libgnucash/engine/qofobject.cpp | 34 +- libgnucash/engine/qofquery.cpp | 164 +++++----- libgnucash/engine/qofquerycore.cpp | 130 ++++---- libgnucash/engine/test/utest-Account.cpp | 2 +- libgnucash/engine/test/utest-Split.cpp | 4 +- libgnucash/engine/test/utest-Transaction.cpp | 2 +- 18 files changed, 981 insertions(+), 981 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index 378aff1a46..be3b56ab59 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -233,10 +233,10 @@ gnc_set_account_separator (const gchar *separator) gchar *gnc_account_name_violations_errmsg (const gchar *separator, GList* invalid_account_names) { - gchar *message = NULL; + gchar *message = nullptr; if ( !invalid_account_names ) - return NULL; + return nullptr; auto account_list {gnc_g_list_stringjoin (invalid_account_names, "\n")}; @@ -271,7 +271,7 @@ check_acct_name (Account *acct, gpointer user_data) GList *gnc_account_list_name_violations (QofBook *book, const gchar *separator) { - g_return_val_if_fail (separator != NULL, nullptr); + g_return_val_if_fail (separator != nullptr, nullptr); if (!book) return nullptr; ViolationData cb = { nullptr, separator }; gnc_account_foreach_descendant (gnc_book_get_root_account (book), @@ -301,8 +301,8 @@ gnc_account_init(Account* acc) AccountPrivate *priv; priv = GET_PRIVATE(acc); - priv->parent = NULL; - priv->children = NULL; + priv->parent = nullptr; + priv->children = nullptr; priv->accountName = qof_string_cache_insert(""); priv->accountCode = qof_string_cache_insert(""); @@ -313,9 +313,9 @@ gnc_account_init(Account* acc) priv->mark = 0; priv->policy = xaccGetFIFOPolicy(); - priv->lots = NULL; + priv->lots = nullptr; - priv->commodity = NULL; + priv->commodity = nullptr; priv->commodity_scu = 0; priv->non_standard_scu = FALSE; @@ -335,7 +335,7 @@ gnc_account_init(Account* acc) priv->lower_balance_cached = false; priv->include_sub_account_balances = TriState::Unset; - priv->splits = NULL; + priv->splits = nullptr; priv->sort_dirty = FALSE; } @@ -661,7 +661,7 @@ gnc_account_class_init (AccountClass *klass) "account mnemonic. Account names may be " "repeated. but no two accounts that share " "a parent may have the same name.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -672,7 +672,7 @@ gnc_account_class_init (AccountClass *klass) "The name of the account concatenated with " "all its parent account names to indicate " "a unique account.", - NULL, + nullptr, static_cast(G_PARAM_READABLE))); g_object_class_install_property @@ -684,7 +684,7 @@ gnc_account_class_init (AccountClass *klass) "assigned by the user. It is intended to " "be reporting code that is a synonym for " "the accountName.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -696,7 +696,7 @@ gnc_account_class_init (AccountClass *klass) "string assigned by the user. It is intended " "to be a longer, 1-5 sentence description of " "what this account is all about.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -707,7 +707,7 @@ gnc_account_class_init (AccountClass *klass) "The account color is a color string assigned " "by the user. It is intended to highlight the " "account based on the users wishes.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -718,7 +718,7 @@ gnc_account_class_init (AccountClass *klass) "The account notes is an arbitrary provided " "for the user to attach any other text that " "they would like to associate with the account.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -963,7 +963,7 @@ gnc_account_class_init (AccountClass *klass) "specific entry on a taxable document. In the " "United States it is used to transfer totals " "into tax preparation software.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -972,7 +972,7 @@ gnc_account_class_init (AccountClass *klass) g_param_spec_string ("tax-source", "Tax Source", "This specifies where exported name comes from.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -1024,7 +1024,7 @@ gnc_account_class_init (AccountClass *klass) "Account Filter", "The account filter is a value saved to allow " "filters to be recalled.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -1034,7 +1034,7 @@ gnc_account_class_init (AccountClass *klass) "Account Sort Order", "The account sort order is a value saved to allow " "the sort order to be recalled.", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -1064,7 +1064,7 @@ gnc_account_class_init (AccountClass *klass) "Online Account ID", "The online account which corresponds to this " "account for OFX import", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -1093,7 +1093,7 @@ gnc_account_class_init (AccountClass *klass) "AQBanking Account ID", "The AqBanking account which corresponds to this " "account for AQBanking import", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property (gobject_class, @@ -1102,7 +1102,7 @@ gnc_account_class_init (AccountClass *klass) "AQBanking Bank Code", "The online account which corresponds to this " "account for AQBanking import", - NULL, + nullptr, static_cast(G_PARAM_READWRITE))); g_object_class_install_property @@ -1143,7 +1143,7 @@ xaccInitAccount (Account * acc, QofBook *book) QofBook * gnc_account_get_book(const Account *account) { - if (!account) return NULL; + if (!account) return nullptr; return qof_instance_get_book(QOF_INSTANCE(account)); } @@ -1153,7 +1153,7 @@ gnc_account_get_book(const Account *account) static Account * gnc_coll_get_root_account (QofCollection *col) { - if (!col) return NULL; + if (!col) return nullptr; return static_cast(qof_collection_get_data (col)); } @@ -1193,10 +1193,10 @@ gnc_book_get_root_account (QofBook *book) QofCollection *col; Account *root; - if (!book) return NULL; + if (!book) return nullptr; col = qof_book_get_collection (book, GNC_ID_ROOT_ACCOUNT); root = gnc_coll_get_root_account (col); - if (root == NULL && !qof_book_shutting_down(book)) + if (root == nullptr && !qof_book_shutting_down(book)) root = gnc_account_create_root(book); return root; } @@ -1225,11 +1225,11 @@ xaccMallocAccount (QofBook *book) { Account *acc; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); - acc = static_cast(g_object_new (GNC_TYPE_ACCOUNT, NULL)); + acc = static_cast(g_object_new (GNC_TYPE_ACCOUNT, nullptr)); xaccInitAccount (acc, book); - qof_event_gen (&acc->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&acc->inst, QOF_EVENT_CREATE, nullptr); return acc; } @@ -1257,12 +1257,12 @@ xaccCloneAccount(const Account *from, QofBook *book) Account *ret; AccountPrivate *from_priv, *priv; - g_return_val_if_fail(GNC_IS_ACCOUNT(from), NULL); - g_return_val_if_fail(QOF_IS_BOOK(book), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(from), nullptr); + g_return_val_if_fail(QOF_IS_BOOK(book), nullptr); ENTER (" "); - ret = static_cast(g_object_new (GNC_TYPE_ACCOUNT, NULL)); - g_return_val_if_fail (ret, NULL); + ret = static_cast(g_object_new (GNC_TYPE_ACCOUNT, nullptr)); + g_return_val_if_fail (ret, nullptr); from_priv = GET_PRIVATE(from); priv = GET_PRIVATE(ret); @@ -1314,13 +1314,13 @@ xaccFreeAccountChildren (Account *acc) /* Copy the list since it will be modified */ priv = GET_PRIVATE(acc); children = g_list_copy(priv->children); - g_list_foreach(children, (GFunc)xaccFreeOneChildAccount, NULL); + g_list_foreach(children, (GFunc)xaccFreeOneChildAccount, nullptr); g_list_free(children); /* The foreach should have removed all the children already. */ if (priv->children) g_list_free(priv->children); - priv->children = NULL; + priv->children = nullptr; } /* The xaccFreeAccount() routine releases memory associated with the @@ -1336,7 +1336,7 @@ xaccFreeAccount (Account *acc) g_return_if_fail(GNC_IS_ACCOUNT(acc)); priv = GET_PRIVATE(acc); - qof_event_gen (&acc->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&acc->inst, QOF_EVENT_DESTROY, nullptr); /* Otherwise the lists below get munged while we're iterating * them, possibly crashing. @@ -1365,7 +1365,7 @@ xaccFreeAccount (Account *acc) gnc_lot_destroy (lot); } g_list_free (priv->lots); - priv->lots = NULL; + priv->lots = nullptr; } /* Next, clean up the splits */ @@ -1388,8 +1388,8 @@ xaccFreeAccount (Account *acc) xaccSplitDestroy (s); } g_list_free(slist); -/* Nothing here (or in xaccAccountCommitEdit) NULLs priv->splits, so this asserts every time. - g_assert(priv->splits == NULL); +/* Nothing here (or in xaccAccountCommitEdit) nullptrs priv->splits, so this asserts every time. + g_assert(priv->splits == nullptr); */ } @@ -1419,7 +1419,7 @@ xaccFreeAccount (Account *acc) priv->type = ACCT_TYPE_NONE; gnc_commodity_decrement_usage_count(priv->commodity); - priv->commodity = NULL; + priv->commodity = nullptr; priv->balance_dirty = FALSE; priv->sort_dirty = FALSE; @@ -1442,7 +1442,7 @@ xaccAccountBeginEdit (Account *acc) static void on_done(QofInstance *inst) { /* old event style */ - qof_event_gen (inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (inst, QOF_EVENT_MODIFY, nullptr); } static void on_err (QofInstance *inst, QofBackendError errcode) @@ -1515,7 +1515,7 @@ xaccAccountCommitEdit (Account *acc) else { g_list_free(priv->splits); - priv->splits = NULL; + priv->splits = nullptr; } /* It turns out there's a case where this assertion does not hold: @@ -1523,7 +1523,7 @@ xaccAccountCommitEdit (Account *acc) deleting all the splits in it. The splits will just get recreated and put right back into the same account! - g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book)); + g_assert(priv->splits == nullptr || qof_book_shutting_down(acc->inst.book)); */ if (!qof_book_shutting_down(book)) @@ -1539,7 +1539,7 @@ xaccAccountCommitEdit (Account *acc) } } g_list_free(priv->lots); - priv->lots = NULL; + priv->lots = nullptr; qof_instance_set_dirty(&acc->inst); qof_instance_decrease_editlevel(acc); @@ -1853,7 +1853,7 @@ xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids) lb = lb->next; } - if ((la != NULL) || (lb != NULL)) + if ((la != nullptr) || (lb != nullptr)) { PWARN ("number of splits differs"); return(FALSE); @@ -1952,7 +1952,7 @@ gnc_account_insert_split (Account *acc, Split *s) } //FIXME: find better event - qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr); /* Also send an event based on the account */ qof_event_gen(&acc->inst, GNC_EVENT_ITEM_ADDED, s); @@ -1973,12 +1973,12 @@ gnc_account_remove_split (Account *acc, Split *s) priv = GET_PRIVATE(acc); node = g_list_find(priv->splits, s); - if (NULL == node) + if (nullptr == node) return FALSE; priv->splits = g_list_delete_link(priv->splits, node); //FIXME: find better event type - qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, nullptr); // And send the account-based event, too qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s); @@ -2037,7 +2037,7 @@ Account * xaccAccountLookup (const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_ACCOUNT); return (Account *) qof_collection_lookup_entity (col, guid); } @@ -2089,7 +2089,7 @@ xaccClearMarkDown (Account *acc, short val) GNCPolicy * gnc_account_get_policy (Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return GET_PRIVATE(acc)->policy; } @@ -2121,8 +2121,8 @@ xaccAccountRemoveLot (Account *acc, GNCLot *lot) ENTER ("(acc=%p, lot=%p)", acc, lot); priv->lots = g_list_remove(priv->lots, lot); - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_REMOVE, NULL); - qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_REMOVE, nullptr); + qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr); LEAVE ("(acc=%p, lot=%p)", acc, lot); } @@ -2130,7 +2130,7 @@ void xaccAccountInsertLot (Account *acc, GNCLot *lot) { AccountPrivate *priv, *opriv; - Account * old_acc = NULL; + Account * old_acc = nullptr; Account* lot_account; /* errors */ @@ -2161,8 +2161,8 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot) * called from gnc_book_close_period since xaccAccountInsertSplit * will try to balance capital gains and things aren't ready for that. */ - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, NULL); - qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, nullptr); + qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr); LEAVE ("(acc=%p, lot=%p)", acc, lot); } @@ -2207,7 +2207,7 @@ xaccAccountMoveAllSplits (Account *accfrom, Account *accto) xaccAccountBeginEdit(accfrom); xaccAccountBeginEdit(accto); /* Begin editing both accounts and all transactions in accfrom. */ - g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, NULL); + g_list_foreach(from_priv->splits, (GFunc)xaccPreSplitMove, nullptr); /* Concatenate accfrom's lists of splits and lots to accto's lists. */ //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits); @@ -2227,8 +2227,8 @@ xaccAccountMoveAllSplits (Account *accfrom, Account *accto) g_list_foreach(from_priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto); /* Finally empty accfrom. */ - g_assert(from_priv->splits == NULL); - g_assert(from_priv->lots == NULL); + g_assert(from_priv->splits == nullptr); + g_assert(from_priv->lots == nullptr); xaccAccountCommitEdit(accfrom); xaccAccountCommitEdit(accto); @@ -2274,7 +2274,7 @@ xaccAccountRecomputeBalance (Account * acc) gnc_numeric reconciled_balance; GList *lp; - if (NULL == acc) return; + if (nullptr == acc) return; priv = GET_PRIVATE(acc); if (qof_instance_get_editlevel(acc) > 0) return; @@ -2503,7 +2503,7 @@ set_kvp_string_path (Account *acc, std::vector const & path, } else { - qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, path); + qof_instance_set_path_kvp (QOF_INSTANCE (acc), nullptr, path); } mark_account (acc); xaccAccountCommitEdit(acc); @@ -2520,9 +2520,9 @@ get_kvp_string_path (const Account *acc, std::vector const & path, GValue *v) { *v = G_VALUE_INIT; - if (acc == NULL) return NULL; // how to check path is valid?? + if (acc == nullptr) return nullptr; // how to check path is valid?? qof_instance_get_path_kvp (QOF_INSTANCE (acc), v, path); - return G_VALUE_HOLDS_STRING (v) ? g_value_get_string (v) : NULL; + return G_VALUE_HOLDS_STRING (v) ? g_value_get_string (v) : nullptr; } static const char* @@ -2552,7 +2552,7 @@ xaccAccountSetSortOrder (Account *acc, const char *str) void xaccAccountSetSortReversed (Account *acc, gboolean sortreversed) { - set_kvp_string_tag (acc, "sort-reversed", sortreversed ? "true" : NULL); + set_kvp_string_tag (acc, "sort-reversed", sortreversed ? "true" : nullptr); } static void @@ -2815,11 +2815,11 @@ gnc_account_append_child (Account *new_parent, Account *child) */ PWARN ("reparenting accounts across books is not correctly supported\n"); - qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&child->inst, QOF_EVENT_DESTROY, nullptr); col = qof_book_get_collection (qof_instance_get_book(new_parent), GNC_ID_ACCOUNT); qof_collection_insert_entity (col, &child->inst); - qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&child->inst, QOF_EVENT_CREATE, nullptr); } } cpriv->parent = new_parent; @@ -2831,8 +2831,8 @@ gnc_account_append_child (Account *new_parent, Account *child) * to send a MODIFY event. If the gtktreemodelfilter code gets the * MODIFY before it gets the ADD, it gets very confused and thinks * that two nodes have been added. */ - qof_event_gen (&child->inst, QOF_EVENT_ADD, NULL); - // qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&child->inst, QOF_EVENT_ADD, nullptr); + // qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, nullptr); xaccAccountCommitEdit (child); // xaccAccountCommitEdit(new_parent); @@ -2869,15 +2869,15 @@ gnc_account_remove_child (Account *parent, Account *child) qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed); /* clear the account's parent pointer after REMOVE event generation. */ - cpriv->parent = NULL; + cpriv->parent = nullptr; - qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, nullptr); } Account * gnc_account_get_parent (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return GET_PRIVATE(acc)->parent; } @@ -2886,7 +2886,7 @@ gnc_account_get_root (Account *acc) { AccountPrivate *priv; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); priv = GET_PRIVATE(acc); while (priv->parent) @@ -2902,13 +2902,13 @@ gboolean gnc_account_is_root (const Account *account) { g_return_val_if_fail(GNC_IS_ACCOUNT(account), FALSE); - return (GET_PRIVATE(account)->parent == NULL); + return (GET_PRIVATE(account)->parent == nullptr); } GList * gnc_account_get_children (const Account *account) { - g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(account), nullptr); return g_list_copy(GET_PRIVATE(account)->children); } @@ -2918,12 +2918,12 @@ gnc_account_get_children_sorted (const Account *account) AccountPrivate *priv; /* errors */ - g_return_val_if_fail(GNC_IS_ACCOUNT(account), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(account), nullptr); /* optimizations */ priv = GET_PRIVATE(account); if (!priv->children) - return NULL; + return nullptr; return g_list_sort(g_list_copy(priv->children), (GCompareFunc)xaccAccountOrder); } @@ -2945,7 +2945,7 @@ gnc_account_child_index (const Account *parent, const Account *child) Account * gnc_account_nth_child (const Account *parent, gint num) { - g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(parent), nullptr); return static_cast(g_list_nth_data(GET_PRIVATE(parent)->children, num)); } @@ -3104,8 +3104,8 @@ gnc_account_lookup_by_full_name_helper (const Account *parent, Account *found; GList *node; - g_return_val_if_fail(GNC_IS_ACCOUNT(parent), NULL); - g_return_val_if_fail(names, NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(parent), nullptr); + g_return_val_if_fail(names, nullptr); /* Look for the first name in the children. */ ppriv = GET_PRIVATE(parent); @@ -3116,25 +3116,25 @@ gnc_account_lookup_by_full_name_helper (const Account *parent, priv = GET_PRIVATE(account); if (g_strcmp0(priv->accountName, names[0]) == 0) { - /* We found an account. If the next entry is NULL, there is + /* We found an account. If the next entry is nullptr, there is * nothing left in the name, so just return the account. */ - if (names[1] == NULL) + if (names[1] == nullptr) return account; /* No children? We're done. */ if (!priv->children) - return NULL; + return nullptr; /* There's stuff left to search for. Search recursively. */ found = gnc_account_lookup_by_full_name_helper(account, &names[1]); - if (found != NULL) + if (found != nullptr) { return found; } } } - return NULL; + return nullptr; } @@ -3147,8 +3147,8 @@ gnc_account_lookup_by_full_name (const Account *any_acc, Account *found; gchar **names; - g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), NULL); - g_return_val_if_fail(name, NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), nullptr); + g_return_val_if_fail(name, nullptr); root = any_acc; rpriv = GET_PRIVATE(root); @@ -3264,7 +3264,7 @@ xaccAccountGetType (const Account *acc) static const char* qofAccountGetTypeString (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return xaccAccountTypeEnumAsString(GET_PRIVATE(acc)->type); } @@ -3279,7 +3279,7 @@ qofAccountSetType (Account *acc, const char *type_string) const char * xaccAccountGetName (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return GET_PRIVATE(acc)->accountName; } @@ -3293,8 +3293,8 @@ gnc_account_get_full_name(const Account *account) int level; /* So much for hardening the API. Too many callers to this function don't - * bother to check if they have a non-NULL pointer before calling. */ - if (NULL == account) + * bother to check if they have a non-nullptr pointer before calling. */ + if (nullptr == account) return g_strdup(""); /* errors */ @@ -3315,9 +3315,9 @@ 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. */ + * becomes the terminating nullptr pointer for the array of strings. */ names = (const gchar **)g_malloc(level * sizeof(gchar *)); - names[--level] = NULL; + names[--level] = nullptr; for (a = account; level > 0; a = priv->parent) { priv = GET_PRIVATE(a); @@ -3334,14 +3334,14 @@ gnc_account_get_full_name(const Account *account) const char * xaccAccountGetCode (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return GET_PRIVATE(acc)->accountCode; } const char * xaccAccountGetDescription (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return GET_PRIVATE(acc)->description; } @@ -3349,7 +3349,7 @@ const char * xaccAccountGetColor (const Account *acc) { GValue v = G_VALUE_INIT; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); auto rv = get_kvp_string_tag (acc, "color", &v); g_value_unset (&v); return rv; @@ -3388,7 +3388,7 @@ xaccAccountGetSortReversed (const Account *acc) const char * xaccAccountGetNotes (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); GValue v = G_VALUE_INIT; auto rv = get_kvp_string_tag (acc, "notes", &v); g_value_unset (&v); @@ -3421,11 +3421,11 @@ gnc_commodity * DxaccAccountGetCurrency (const Account *acc) { GValue v = G_VALUE_INIT; - const char *s = NULL; + const char *s = nullptr; gnc_commodity_table *table; - gnc_commodity *retval = NULL; + gnc_commodity *retval = nullptr; - if (!acc) return NULL; + if (!acc) return nullptr; qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-currency"}); if (G_VALUE_HOLDS_STRING (&v)) s = g_value_get_string (&v); @@ -3443,14 +3443,14 @@ gnc_commodity * xaccAccountGetCommodity (const Account *acc) { if (!GNC_IS_ACCOUNT(acc)) - return NULL; + return nullptr; return GET_PRIVATE(acc)->commodity; } gnc_commodity * gnc_account_get_currency_or_parent(const Account* account) { gnc_commodity * commodity; - g_return_val_if_fail (account, NULL); + g_return_val_if_fail (account, nullptr); commodity = xaccAccountGetCommodity (account); if (gnc_commodity_is_currency(commodity)) @@ -3477,7 +3477,7 @@ gnc_commodity * gnc_account_get_currency_or_parent(const Account* account) } while (parent_account); } - return NULL; // no suitable commodity found. + return nullptr; // no suitable commodity found. } /********************************************************************\ @@ -3809,7 +3809,7 @@ xaccAccountBalanceAsOfDateHelper (Account *acc, gpointer data) * 'fn' for extracting the balance. This function may extract the * current value, the reconciled value, etc. * - * If 'report_commodity' is NULL, just use the account's commodity. + * If 'report_commodity' is nullptr, just use the account's commodity. * If 'include_children' is FALSE, this function doesn't recurse at all. */ static gnc_numeric @@ -3836,10 +3836,10 @@ xaccAccountGetXxxBalanceInCurrencyRecursive (const Account *acc, /* MSVC compiler: Somehow, the struct initialization containing a gnc_numeric doesn't work. As an exception, we hand-initialize that member afterwards. */ - CurrencyBalance cb = { report_commodity, { 0 }, fn, NULL, 0 }; + CurrencyBalance cb = { report_commodity, { 0 }, fn, nullptr, 0 }; cb.balance = balance; #else - CurrencyBalance cb = { report_commodity, balance, fn, NULL, 0 }; + CurrencyBalance cb = { report_commodity, balance, fn, nullptr, 0 }; #endif gnc_account_foreach_descendant (acc, xaccAccountBalanceHelper, &cb); @@ -3873,10 +3873,10 @@ xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive ( /* MSVC compiler: Somehow, the struct initialization containing a gnc_numeric doesn't work. As an exception, we hand-initialize that member afterwards. */ - CurrencyBalance cb = { report_commodity, 0, NULL, fn, date }; + CurrencyBalance cb = { report_commodity, 0, nullptr, fn, date }; cb.balance = balance; #else - CurrencyBalance cb = { report_commodity, balance, NULL, fn, date }; + CurrencyBalance cb = { report_commodity, balance, nullptr, fn, date }; #endif gnc_account_foreach_descendant (acc, xaccAccountBalanceAsOfDateHelper, &cb); @@ -3967,8 +3967,8 @@ xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 t1, time64 t2, { gnc_numeric b1, b2; - b1 = xaccAccountGetBalanceAsOfDateInCurrency(acc, t1, NULL, recurse); - b2 = xaccAccountGetBalanceAsOfDateInCurrency(acc, t2, NULL, recurse); + b1 = xaccAccountGetBalanceAsOfDateInCurrency(acc, t1, nullptr, recurse); + b2 = xaccAccountGetBalanceAsOfDateInCurrency(acc, t2, nullptr, recurse); return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED); } @@ -3978,8 +3978,8 @@ xaccAccountGetNoclosingBalanceChangeForPeriod (Account *acc, time64 t1, { gnc_numeric b1, b2; - b1 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t1, NULL, recurse); - b2 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t2, NULL, recurse); + b1 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t1, nullptr, recurse); + b2 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t2, nullptr, recurse); return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED); } @@ -4045,7 +4045,7 @@ xaccAccountGetNoclosingBalanceChangeInCurrencyForPeriod (Account *acc, time64 t1 SplitList * xaccAccountGetSplitList (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); xaccAccountSortSplits((Account*)acc, FALSE); // normally a noop return GET_PRIVATE(acc)->splits; } @@ -4067,7 +4067,7 @@ gboolean gnc_account_and_descendants_empty (Account *acc) LotList * xaccAccountGetLotList (const Account *acc) { - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); return g_list_copy(GET_PRIVATE(acc)->lots); } @@ -4079,9 +4079,9 @@ xaccAccountFindOpenLots (const Account *acc, { AccountPrivate *priv; GList *lot_list; - GList *retval = NULL; + GList *retval = nullptr; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); priv = GET_PRIVATE(acc); for (lot_list = priv->lots; lot_list; lot_list = lot_list->next) @@ -4111,10 +4111,10 @@ xaccAccountForEachLot(const Account *acc, { AccountPrivate *priv; LotList *node; - gpointer result = NULL; + gpointer result = nullptr; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); - g_return_val_if_fail(proc, NULL); + g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr); + g_return_val_if_fail(proc, nullptr); priv = GET_PRIVATE(acc); for (node = priv->lots; node; node = node->next) @@ -4178,7 +4178,7 @@ xaccAccountGetTaxUSCode (const Account *acc) GValue v = G_VALUE_INIT; g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "code"}); - return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; } void @@ -4193,7 +4193,7 @@ xaccAccountGetTaxUSPayerNameSource (const Account *acc) GValue v = G_VALUE_INIT; g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "payer-name-source"}); - return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; } void @@ -4374,7 +4374,7 @@ xaccAccountIsHidden (const Account *acc) if (xaccAccountGetHidden(acc)) return TRUE; priv = GET_PRIVATE(acc); - while ((acc = priv->parent) != NULL) + while ((acc = priv->parent) != nullptr) { priv = GET_PRIVATE(acc); if (xaccAccountGetHidden(acc)) @@ -4438,7 +4438,7 @@ xaccAccountTypeEnumAsString(GNCAccountType type) PERR ("asked to translate unknown account type %d.\n", type); break; } - return(NULL); + return(nullptr); } #undef GNC_RETURN_ENUM_AS_STRING @@ -4940,7 +4940,7 @@ xaccAccountGetLastNum (const Account *acc) GValue v = G_VALUE_INIT; g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"last-num"}); - return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; } /********************************************************************\ @@ -5212,13 +5212,13 @@ GetOrMakeOrphanAccount (Account *root, gnc_commodity * currency) char * accname; Account * acc; - g_return_val_if_fail (root, NULL); + g_return_val_if_fail (root, nullptr); /* build the account name */ if (!currency) { PERR ("No currency specified!"); - return NULL; + return nullptr; } accname = g_strconcat (_("Orphaned Gains"), "-", @@ -5227,7 +5227,7 @@ GetOrMakeOrphanAccount (Account *root, gnc_commodity * currency) /* See if we've got one of these going already ... */ acc = gnc_account_lookup_by_name(root, accname); - if (acc == NULL) + if (acc == nullptr) { /* Guess not. We'll have to build one. */ acc = xaccMallocAccount (gnc_account_get_book(root)); @@ -5257,14 +5257,14 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr) GValue v = G_VALUE_INIT; std::vector path {KEY_LOT_MGMT, "gains-acct", gnc_commodity_get_unique_name (curr)}; - GncGUID *guid = NULL; + GncGUID *guid = nullptr; Account *gains_account; - g_return_val_if_fail (acc != NULL, NULL); + g_return_val_if_fail (acc != nullptr, nullptr); qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, path); if (G_VALUE_HOLDS_BOXED (&v)) guid = (GncGUID*)g_value_get_boxed (&v); - if (guid == NULL) /* No gains account for this currency */ + if (guid == nullptr) /* No gains account for this currency */ { gains_account = GetOrMakeOrphanAccount (gnc_account_get_root (acc), curr); @@ -5307,9 +5307,9 @@ const char* dxaccAccountGetPriceSrc(const Account *acc) { static char *source = nullptr; - if (!acc) return NULL; + if (!acc) return nullptr; - if (!xaccAccountIsPriced(acc)) return NULL; + if (!xaccAccountIsPriced(acc)) return nullptr; g_free (source); @@ -5336,8 +5336,8 @@ dxaccAccountSetQuoteTZ(Account *acc, const char *tz) const char* dxaccAccountGetQuoteTZ(const Account *acc) { - if (!acc) return NULL; - if (!xaccAccountIsPriced(acc)) return NULL; + if (!acc) return nullptr; + if (!xaccAccountIsPriced(acc)) return nullptr; GValue v = G_VALUE_INIT; auto rv = get_kvp_string_tag (acc, "old-quote-tz", &v); g_value_unset (&v); @@ -5402,12 +5402,12 @@ finder_help_function(const Account *acc, const char *description, AccountPrivate *priv; GList *slp; - /* First, make sure we set the data to NULL BEFORE we start */ - if (split) *split = NULL; - if (trans) *trans = NULL; + /* First, make sure we set the data to nullptr BEFORE we start */ + if (split) *split = nullptr; + if (trans) *trans = nullptr; /* Then see if we have any work to do */ - if (acc == NULL) return; + if (acc == nullptr) return; /* Why is this loop iterated backwards ?? Presumably because the split * list is in date order, and the most recent matches should be @@ -5433,7 +5433,7 @@ xaccAccountFindSplitByDesc(const Account *acc, const char *description) Split *split; /* Get the split which has a transaction matching the description. */ - finder_help_function(acc, description, &split, NULL); + finder_help_function(acc, description, &split, nullptr); return split; } @@ -5448,7 +5448,7 @@ xaccAccountFindTransByDesc(const Account *acc, const char *description) Transaction *trans; /* Get the translation matching the description. */ - finder_help_function(acc, description, NULL, &trans); + finder_help_function(acc, description, nullptr, &trans); return trans; } @@ -5524,8 +5524,8 @@ gnc_account_merge_children (Account *parent) gnc_account_append_child (acc_a, (Account *)worker->data); g_list_free(work); - qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, NULL); - qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, nullptr); + qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, nullptr); } /* recurse to do the children's children */ @@ -5581,7 +5581,7 @@ xaccAccountBeginStagedTransactionTraversals (const Account *account) gboolean xaccTransactionTraverse (Transaction *trans, int stage) { - if (trans == NULL) return FALSE; + if (trans == nullptr) return FALSE; if (trans->marker < stage) { @@ -5601,7 +5601,7 @@ static void do_one_split (Split *s, gpointer data) static void do_one_account (Account *account, gpointer data) { AccountPrivate *priv = GET_PRIVATE(account); - g_list_foreach(priv->splits, (GFunc)do_one_split, NULL); + g_list_foreach(priv->splits, (GFunc)do_one_split, nullptr); } /* Replacement for xaccGroupBeginStagedTransactionTraversals */ @@ -5611,7 +5611,7 @@ gnc_account_tree_begin_staged_transaction_traversals (Account *account) GList *descendants; descendants = gnc_account_get_descendants(account); - g_list_foreach(descendants, (GFunc)do_one_account, NULL); + g_list_foreach(descendants, (GFunc)do_one_account, nullptr); g_list_free(descendants); } @@ -5737,9 +5737,9 @@ gnc_account_imap_find_account (Account *acc, const char *key) { GValue v = G_VALUE_INIT; - GncGUID * guid = NULL; + GncGUID * guid = nullptr; Account *retval; - if (!acc || !key) return NULL; + if (!acc || !key) return nullptr; std::vector path {IMAP_FRAME}; if (category) path.push_back (category); @@ -5755,7 +5755,7 @@ gnc_account_imap_find_account (Account *acc, Account* gnc_account_imap_find_any (QofBook *book, const char* category, const char *key) { - Account *account = NULL; + Account *account = nullptr; /* Get list of Accounts */ auto root = gnc_book_get_root_account (book); @@ -6189,7 +6189,7 @@ gnc_account_imap_add_account_bayes (Account *acc, } check_import_map_data (gnc_account_get_book(acc)); - g_return_if_fail (added_acc != NULL); + g_return_if_fail (added_acc != nullptr); account_fullname = gnc_account_get_full_name(added_acc); xaccAccountBeginEdit (acc); @@ -6230,8 +6230,8 @@ build_non_bayes (const char *key, const GValue *value, gpointer user_data) if (!G_VALUE_HOLDS_BOXED (value)) return; QofBook *book; - GncGUID *guid = NULL; - gchar *guid_string = NULL; + GncGUID *guid = nullptr; + gchar *guid_string = nullptr; auto imapInfo = (GncImapInfo*)user_data; // Get the book book = qof_instance_get_book (imapInfo->source_account); @@ -6305,7 +6305,7 @@ gnc_account_imap_get_info_bayes (Account *acc) GList * gnc_account_imap_get_info (Account *acc, const char *category) { - GList *list = NULL; + GList *list = nullptr; GncImapInfo imapInfo; @@ -6347,7 +6347,7 @@ void gnc_account_delete_map_entry (Account *acc, char *head, char *category, char *match_string, gboolean empty) { - if (acc != NULL) + if (acc != nullptr) { std::vector path {head}; if (category) @@ -6373,7 +6373,7 @@ gnc_account_delete_map_entry (Account *acc, char *head, char *category, void gnc_account_delete_all_bayes_maps (Account *acc) { - if (acc != NULL) + if (acc != nullptr) { auto slots = qof_instance_get_slots_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES); if (!slots.size()) return; @@ -6431,7 +6431,7 @@ static QofObject account_object_def = DI(.e_type = ) GNC_ID_ACCOUNT, DI(.type_label = ) "Account", DI(.create = ) (void*(*)(QofBook*)) xaccMallocAccount, - DI(.book_begin = ) NULL, + DI(.book_begin = ) nullptr, DI(.book_end = ) gnc_account_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, @@ -6486,19 +6486,19 @@ gboolean xaccAccountRegister (void) }, { ACCOUNT_PRESENT_, QOF_TYPE_NUMERIC, - (QofAccessFunc) xaccAccountGetPresentBalance, NULL + (QofAccessFunc) xaccAccountGetPresentBalance, nullptr }, { ACCOUNT_BALANCE_, QOF_TYPE_NUMERIC, - (QofAccessFunc) xaccAccountGetBalance, NULL + (QofAccessFunc) xaccAccountGetBalance, nullptr }, { ACCOUNT_CLEARED_, QOF_TYPE_NUMERIC, - (QofAccessFunc) xaccAccountGetClearedBalance, NULL + (QofAccessFunc) xaccAccountGetClearedBalance, nullptr }, { ACCOUNT_RECONCILED_, QOF_TYPE_NUMERIC, - (QofAccessFunc) xaccAccountGetReconciledBalance, NULL + (QofAccessFunc) xaccAccountGetReconciledBalance, nullptr }, { ACCOUNT_TYPE_, QOF_TYPE_STRING, @@ -6507,7 +6507,7 @@ gboolean xaccAccountRegister (void) }, { ACCOUNT_FUTURE_MINIMUM_, QOF_TYPE_NUMERIC, - (QofAccessFunc) xaccAccountGetProjectedMinimumBalance, NULL + (QofAccessFunc) xaccAccountGetProjectedMinimumBalance, nullptr }, { ACCOUNT_TAX_RELATED, QOF_TYPE_BOOLEAN, @@ -6536,13 +6536,13 @@ gboolean xaccAccountRegister (void) }, { QOF_PARAM_BOOK, QOF_ID_BOOK, - (QofAccessFunc) qof_instance_get_book, NULL + (QofAccessFunc) qof_instance_get_book, nullptr }, { QOF_PARAM_GUID, QOF_TYPE_GUID, - (QofAccessFunc) qof_instance_get_guid, NULL + (QofAccessFunc) qof_instance_get_guid, nullptr }, - { NULL }, + { nullptr }, }; qof_class_register (GNC_ID_ACCOUNT, (QofSortFunc) qof_xaccAccountOrder, params); diff --git a/libgnucash/engine/Split.cpp b/libgnucash/engine/Split.cpp index 88b4101da2..f8cec19a0e 100644 --- a/libgnucash/engine/Split.cpp +++ b/libgnucash/engine/Split.cpp @@ -108,10 +108,10 @@ static void gnc_split_init(Split* split) { /* fill in some sane defaults */ - split->acc = NULL; - split->orig_acc = NULL; - split->parent = NULL; - split->lot = NULL; + split->acc = nullptr; + split->orig_acc = nullptr; + split->parent = nullptr; + split->lot = nullptr; split->action = CACHE_INSERT(""); split->memo = CACHE_INSERT(""); @@ -127,7 +127,7 @@ gnc_split_init(Split* split) split->noclosing_balance = gnc_numeric_zero(); split->gains = GAINS_STATUS_UNKNOWN; - split->gains_split = NULL; + split->gains_split = nullptr; } static void @@ -231,7 +231,7 @@ gnc_split_set_property(GObject *object, g_return_if_fail(GNC_IS_SPLIT(object)); split = GNC_SPLIT(object); - if (prop_id < PROP_RUNTIME_0 && split->parent != NULL) + if (prop_id < PROP_RUNTIME_0 && split->parent != nullptr) g_assert (qof_instance_get_editlevel(split->parent)); switch (prop_id) @@ -315,7 +315,7 @@ gnc_split_class_init(SplitClass* klass) "by the user. It is intended to be a short " "string that contains extra information about " "this split.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -327,7 +327,7 @@ gnc_split_class_init(SplitClass* klass) "by the user. It is intended to be a short " "string that describes the purpose of " "this split.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -396,7 +396,7 @@ gnc_split_class_init(SplitClass* klass) "The formula used to calculate the actual debit " "amount when a real split is generated from this " "SX split.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -417,7 +417,7 @@ gnc_split_class_init(SplitClass* klass) "The formula used to calculate the actual credit " "amount when a real split is generated from this " "SX split.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -441,7 +441,7 @@ gnc_split_class_init(SplitClass* klass) "Scheduled Transaction Shares", "Numeric value of shares to insert in a new split when " "it's generated from this SX split.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -460,7 +460,7 @@ gnc_split_class_init(SplitClass* klass) "Online Account ID", "The online account which corresponds to this " "account for OFX/HCBI import", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -500,10 +500,10 @@ void xaccSplitReinit(Split * split) { /* fill in some sane defaults */ - split->acc = NULL; - split->orig_acc = NULL; - split->parent = NULL; - split->lot = NULL; + split->acc = nullptr; + split->orig_acc = nullptr; + split->parent = nullptr; + split->lot = nullptr; CACHE_REPLACE(split->action, ""); CACHE_REPLACE(split->memo, ""); @@ -521,7 +521,7 @@ xaccSplitReinit(Split * split) qof_instance_set_idata(split, 0); split->gains = GAINS_STATUS_UNKNOWN; - split->gains_split = NULL; + split->gains_split = nullptr; } /********************************************************************\ @@ -531,9 +531,9 @@ Split * xaccMallocSplit(QofBook *book) { Split *split; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); - split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); + split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr)); xaccInitSplit (split, book); return split; @@ -551,13 +551,13 @@ xaccMallocSplit(QofBook *book) Split * xaccDupeSplit (const Split *s) { - Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); + Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr)); /* Trash the entity table. We don't want to mistake the cloned * splits as something official. If we ever use this split, we'll * have to fix this up. */ - split->inst.e_type = NULL; + split->inst.e_type = nullptr; qof_instance_copy_guid(split, s); qof_instance_copy_book(split, s); @@ -589,9 +589,9 @@ xaccDupeSplit (const Split *s) Split * xaccSplitCloneNoKvp (const Split *s) { - Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); + Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr)); - split->parent = NULL; + split->parent = nullptr; split->memo = CACHE_INSERT(s->memo); split->action = CACHE_INSERT(s->action); split->reconciled = s->reconciled; @@ -604,7 +604,7 @@ xaccSplitCloneNoKvp (const Split *s) split->noclosing_balance = s->noclosing_balance; split->gains = GAINS_STATUS_UNKNOWN; - split->gains_split = NULL; + split->gains_split = nullptr; qof_instance_init_data(&split->inst, GNC_ID_SPLIT, qof_instance_get_book(s)); @@ -622,7 +622,7 @@ xaccSplitCopyKvp (const Split *from, Split *to) { qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from)); /* But not the online-id */ - qof_instance_set (QOF_INSTANCE (to), "online-id", NULL, NULL); + qof_instance_set (QOF_INSTANCE (to), "online-id", nullptr, nullptr); } /*################## Added for Reg2 #################*/ @@ -738,14 +738,14 @@ xaccFreeSplit (Split *split) /* Just in case someone looks up freed memory ... */ split->memo = (char *) 1; - split->action = NULL; + split->action = nullptr; split->reconciled = NREC; split->amount = gnc_numeric_zero(); split->value = gnc_numeric_zero(); - split->parent = NULL; - split->lot = NULL; - split->acc = NULL; - split->orig_acc = NULL; + split->parent = nullptr; + split->lot = nullptr; + split->acc = nullptr; + split->orig_acc = nullptr; split->date_reconciled = 0; G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split)); @@ -753,9 +753,9 @@ xaccFreeSplit (Split *split) if (split->gains_split) { Split *other = xaccSplitGetOtherSplit(split->gains_split); - split->gains_split->gains_split = NULL; + split->gains_split->gains_split = nullptr; if (other) - other->gains_split = NULL; + other->gains_split = nullptr; } g_object_unref(split); @@ -765,7 +765,7 @@ void mark_split (Split *s) { if (s->acc) { - g_object_set(s->acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL); + g_object_set(s->acc, "sort-dirty", TRUE, "balance-dirty", TRUE, nullptr); } /* set dirty flag on lot too. */ @@ -809,7 +809,7 @@ xaccSplitEqual(const Split *sa, const Split *sb, if (!sa || !sb) { - PINFO ("one is NULL"); + PINFO ("one is nullptr"); return FALSE; } @@ -933,8 +933,8 @@ xaccSplitEqual(const Split *sa, const Split *sb, GList * xaccSplitListGetUniqueTransactionsReversed (const GList *splits) { - GHashTable *txn_hash = g_hash_table_new (NULL, NULL); - GList *transList = NULL; + GHashTable *txn_hash = g_hash_table_new (nullptr, nullptr); + GList *transList = nullptr; const GList *snode; for (snode = splits; snode; snode = snode->next) @@ -944,7 +944,7 @@ xaccSplitListGetUniqueTransactionsReversed (const GList *splits) if (g_hash_table_contains (txn_hash, trans)) continue; - g_hash_table_insert (txn_hash, trans, NULL); + g_hash_table_insert (txn_hash, trans, nullptr); transList = g_list_prepend (transList, trans); } g_hash_table_destroy (txn_hash); @@ -967,7 +967,7 @@ xaccSplitListGetUniqueTransactions(const GList *splits) Account * xaccSplitGetAccount (const Split *s) { - return s ? s->acc : NULL; + return s ? s->acc : nullptr; } void @@ -999,8 +999,8 @@ static void commit_err (QofInstance *inst, QofBackendError errcode) void xaccSplitCommitEdit(Split *s) { - Account *acc = NULL; - Account *orig_acc = NULL; + Account *acc = nullptr; + Account *orig_acc = nullptr; g_return_if_fail(s); if (!qof_instance_is_dirty(QOF_INSTANCE(s))) @@ -1032,7 +1032,7 @@ xaccSplitCommitEdit(Split *s) { /* If the split's lot belonged to some other account, we leave it so. */ - if (s->lot && (NULL == gnc_lot_get_account(s->lot))) + if (s->lot && (nullptr == gnc_lot_get_account(s->lot))) xaccAccountInsertLot (acc, s->lot); } else @@ -1047,12 +1047,12 @@ xaccSplitCommitEdit(Split *s) //FIXME: find better event if (s->orig_parent) qof_event_gen(&s->orig_parent->inst, QOF_EVENT_MODIFY, - NULL); + nullptr); } if (s->lot) { /* A change of value/amnt affects gains display, etc. */ - qof_event_gen (QOF_INSTANCE(s->lot), QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(s->lot), QOF_EVENT_MODIFY, nullptr); } /* Important: we save off the original parent transaction and account @@ -1060,12 +1060,12 @@ xaccSplitCommitEdit(Split *s) original and new transactions, for the _next_ begin/commit cycle. */ s->orig_acc = s->acc; s->orig_parent = s->parent; - if (!qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, NULL, do_destroy)) + if (!qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, nullptr, do_destroy)) return; if (acc) { - g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL); + g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, nullptr); xaccAccountRecomputeBalance(acc); } } @@ -1075,7 +1075,7 @@ void xaccSplitRollbackEdit(Split *s) { - /* Don't use setters because we want to allow NULL. This is legit + /* Don't use setters because we want to allow nullptr. This is legit only because we don't emit events for changing accounts until the final commit. */ if (s->acc != s->orig_acc) @@ -1103,7 +1103,7 @@ Split * xaccSplitLookup (const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_SPLIT); return (Split *) qof_collection_lookup_entity (col, guid); } @@ -1123,7 +1123,7 @@ xaccSplitDetermineGainStatus (Split *split) { Split *other; GValue v = G_VALUE_INIT; - GncGUID *guid = NULL; + GncGUID *guid = nullptr; if (GAINS_STATUS_UNKNOWN != split->gains) return; @@ -1618,7 +1618,7 @@ xaccSplitOrderDateOnly (const Split *sa, const Split *sb) static gboolean get_corr_account_split(const Split *sa, const Split **retval) { - *retval = NULL; + *retval = nullptr; g_return_val_if_fail(sa, FALSE); if (xaccTransCountSplits (sa->parent) > 2) @@ -1635,7 +1635,7 @@ get_corr_account_split(const Split *sa, const Split **retval) const char * xaccSplitGetCorrAccountName(const Split *sa) { - static const char *split_const = NULL; + static const char *split_const = nullptr; const Split *other_split; if (!get_corr_account_split(sa, &other_split)) @@ -1652,7 +1652,7 @@ xaccSplitGetCorrAccountName(const Split *sa) char * xaccSplitGetCorrAccountFullName(const Split *sa) { - static const char *split_const = NULL; + static const char *split_const = nullptr; const Split *other_split; if (!get_corr_account_split(sa, &other_split)) @@ -1668,7 +1668,7 @@ xaccSplitGetCorrAccountFullName(const Split *sa) const char * xaccSplitGetCorrAccountCode(const Split *sa) { - static const char *split_const = NULL; + static const char *split_const = nullptr; const Split *other_split; if (!get_corr_account_split(sa, &other_split)) @@ -1864,7 +1864,7 @@ xaccSplitGetDateReconciled (const Split * split) Transaction * xaccSplitGetParent (const Split *split) { - return split ? split->parent : NULL; + return split ? split->parent : nullptr; } void @@ -1901,7 +1901,7 @@ xaccSplitSetParent(Split *s, Transaction *t) xaccSplitSetValue(s, xaccSplitGetValue(s)); /* add ourselves to the new transaction's list of pending splits. */ - if (NULL == g_list_find(t->splits, s)) + if (nullptr == g_list_find(t->splits, s)) t->splits = g_list_append(t->splits, s); ed.idx = -1; /* unused */ @@ -1914,7 +1914,7 @@ xaccSplitSetParent(Split *s, Transaction *t) GNCLot * xaccSplitGetLot (const Split *split) { - return split ? split->lot : NULL; + return split ? split->lot : nullptr; } void @@ -1929,13 +1929,13 @@ xaccSplitSetLot(Split* split, GNCLot* lot) const char * xaccSplitGetMemo (const Split *split) { - return split ? split->memo : NULL; + return split ? split->memo : nullptr; } const char * xaccSplitGetAction (const Split *split) { - return split ? split->action : NULL; + return split ? split->action : nullptr; } char @@ -2004,12 +2004,12 @@ xaccSplitGetBook (const Split *split) const char * xaccSplitGetType(const Split *s) { - if (!s) return NULL; + if (!s) return nullptr; GValue v = G_VALUE_INIT; const char* type; qof_instance_get_kvp (QOF_INSTANCE (s), &v, 1, "split-type"); - type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; const char *rv; if (!type || !g_strcmp0 (type, split_type_normal)) rv = split_type_normal; @@ -2049,13 +2049,13 @@ xaccSplitAddPeerSplit (Split *split, const Split *other_split, { const GncGUID* guid; - g_return_if_fail (split != NULL); - g_return_if_fail (other_split != NULL); + g_return_if_fail (split != nullptr); + g_return_if_fail (other_split != nullptr); guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); xaccTransBeginEdit (split->parent); qof_instance_kvp_add_guid (QOF_INSTANCE (split), "lot-split", - gnc_time(NULL), "peer_guid", guid_copy(guid)); + gnc_time(nullptr), "peer_guid", guid_copy(guid)); mark_split (split); qof_instance_set_dirty (QOF_INSTANCE (split)); xaccTransCommitEdit (split->parent); @@ -2072,8 +2072,8 @@ xaccSplitIsPeerSplit (const Split *split, const Split *other_split) { const GncGUID* guid; - g_return_val_if_fail (split != NULL, FALSE); - g_return_val_if_fail (other_split != NULL, FALSE); + g_return_val_if_fail (split != nullptr, FALSE); + g_return_val_if_fail (other_split != nullptr, FALSE); guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); return qof_instance_kvp_has_guid (QOF_INSTANCE (split), "lot-split", @@ -2085,8 +2085,8 @@ xaccSplitRemovePeerSplit (Split *split, const Split *other_split) { const GncGUID* guid; - g_return_if_fail (split != NULL); - g_return_if_fail (other_split != NULL); + g_return_if_fail (split != nullptr); + g_return_if_fail (other_split != nullptr); guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); xaccTransBeginEdit (split->parent); @@ -2124,11 +2124,11 @@ Split * xaccSplitGetOtherSplit (const Split *split) { Transaction *trans; - Split *other = NULL; + Split *other = nullptr; - if (!split) return NULL; + if (!split) return nullptr; trans = split->parent; - if (!trans) return NULL; + if (!trans) return nullptr; for (GList *n = xaccTransGetSplitList (trans); n; n = n->next) { @@ -2140,7 +2140,7 @@ xaccSplitGetOtherSplit (const Split *split) continue; if (other) - return NULL; + return nullptr; other = s; } @@ -2154,7 +2154,7 @@ gnc_numeric xaccSplitVoidFormerAmount(const Split *split) { GValue v = G_VALUE_INIT; - gnc_numeric *num = NULL; + gnc_numeric *num = nullptr; gnc_numeric retval; g_return_val_if_fail(split, gnc_numeric_zero()); qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str); @@ -2169,7 +2169,7 @@ gnc_numeric xaccSplitVoidFormerValue(const Split *split) { GValue v = G_VALUE_INIT; - gnc_numeric *num = NULL; + gnc_numeric *num = nullptr; gnc_numeric retval; g_return_val_if_fail(split, gnc_numeric_zero()); qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str); @@ -2208,8 +2208,8 @@ xaccSplitUnvoid(Split *split) xaccSplitSetAmount (split, xaccSplitVoidFormerAmount(split)); xaccSplitSetValue (split, xaccSplitVoidFormerValue(split)); xaccSplitSetReconcile(split, NREC); - qof_instance_set_kvp (QOF_INSTANCE (split), NULL, 1, void_former_amt_str); - qof_instance_set_kvp (QOF_INSTANCE (split), NULL, 1, void_former_val_str); + qof_instance_set_kvp (QOF_INSTANCE (split), nullptr, 1, void_former_amt_str); + qof_instance_set_kvp (QOF_INSTANCE (split), nullptr, 1, void_former_val_str); qof_instance_set_dirty (QOF_INSTANCE (split)); } @@ -2232,8 +2232,8 @@ static QofObject split_object_def = DI(.e_type = ) GNC_ID_SPLIT, DI(.type_label = ) "Split", DI(.create = ) (void* (*)(QofBook*))xaccMallocSplit, - DI(.book_begin = ) NULL, - DI(.book_end = ) NULL, + DI(.book_begin = ) nullptr, + DI(.book_end = ) nullptr, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, DI(.foreach = ) qof_collection_foreach, @@ -2247,9 +2247,9 @@ split_account_guid_getter (gpointer obj, const QofParam *p) Split *s = GNC_SPLIT(obj); Account *acc; - if (!s) return NULL; + if (!s) return nullptr; acc = xaccSplitGetAccount (s); - if (!acc) return NULL; + if (!acc) return nullptr; return ((gpointer)xaccAccountGetGUID (acc)); } @@ -2297,23 +2297,23 @@ gboolean xaccSplitRegister (void) * queries, should be removed from old queries. */ { "d-share-amount", QOF_TYPE_DOUBLE, - (QofAccessFunc)DxaccSplitGetShareAmount, NULL + (QofAccessFunc)DxaccSplitGetShareAmount, nullptr }, { "d-share-int64", QOF_TYPE_INT64, - (QofAccessFunc)qof_entity_get_guid, NULL + (QofAccessFunc)qof_entity_get_guid, nullptr }, { SPLIT_BALANCE, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccSplitGetBalance, NULL + (QofAccessFunc)xaccSplitGetBalance, nullptr }, { SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccSplitGetClearedBalance, NULL + (QofAccessFunc)xaccSplitGetClearedBalance, nullptr }, { SPLIT_RECONCILED_BALANCE, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccSplitGetReconciledBalance, NULL + (QofAccessFunc)xaccSplitGetReconciledBalance, nullptr }, { SPLIT_MEMO, QOF_TYPE_STRING, @@ -2341,16 +2341,16 @@ gboolean xaccSplitRegister (void) SPLIT_VALUE, QOF_TYPE_DEBCRED, (QofAccessFunc)xaccSplitGetValue, (QofSetterFunc)qofSplitSetValue }, - { SPLIT_TYPE, QOF_TYPE_STRING, (QofAccessFunc)xaccSplitGetType, NULL }, + { SPLIT_TYPE, QOF_TYPE_STRING, (QofAccessFunc)xaccSplitGetType, nullptr }, { SPLIT_VOIDED_AMOUNT, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccSplitVoidFormerAmount, NULL + (QofAccessFunc)xaccSplitVoidFormerAmount, nullptr }, { SPLIT_VOIDED_VALUE, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccSplitVoidFormerValue, NULL + (QofAccessFunc)xaccSplitVoidFormerValue, nullptr }, - { SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot, NULL }, + { SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot, nullptr }, { SPLIT_TRANS, GNC_ID_TRANS, (QofAccessFunc)xaccSplitGetParent, @@ -2360,28 +2360,28 @@ gboolean xaccSplitRegister (void) SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QofAccessFunc)xaccSplitGetAccount, (QofSetterFunc)qofSplitSetAccount }, - { SPLIT_ACCOUNT_GUID, QOF_TYPE_GUID, split_account_guid_getter, NULL }, + { SPLIT_ACCOUNT_GUID, QOF_TYPE_GUID, split_account_guid_getter, nullptr }, /* these are no-ops to register the parameter names (for sorting) but they return an allocated object which getters cannot do. */ - { SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op, NULL }, - { SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op, NULL }, - { SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op, NULL }, - { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL }, + { SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op, nullptr }, + { SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op, nullptr }, + { SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op, nullptr }, + { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, nullptr }, { QOF_PARAM_GUID, QOF_TYPE_GUID, - (QofAccessFunc)qof_entity_get_guid, NULL + (QofAccessFunc)qof_entity_get_guid, nullptr }, - { NULL }, + { nullptr }, }; qof_class_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitOrder, params); qof_class_register (SPLIT_ACCT_FULLNAME, - (QofSortFunc)xaccSplitCompareAccountFullNames, NULL); + (QofSortFunc)xaccSplitCompareAccountFullNames, nullptr); qof_class_register (SPLIT_CORR_ACCT_NAME, (QofSortFunc)xaccSplitCompareOtherAccountFullNames, - NULL); + nullptr); qof_class_register (SPLIT_CORR_ACCT_CODE, - (QofSortFunc)xaccSplitCompareOtherAccountCodes, NULL); + (QofSortFunc)xaccSplitCompareOtherAccountCodes, nullptr); return qof_object_register (&split_object_def); } diff --git a/libgnucash/engine/Transaction.cpp b/libgnucash/engine/Transaction.cpp index 5b0938507a..84f36add04 100644 --- a/libgnucash/engine/Transaction.cpp +++ b/libgnucash/engine/Transaction.cpp @@ -251,7 +251,7 @@ void gen_event_trans (Transaction *trans) if (lot) { /* A change of transaction date might affect opening date of lot */ - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr); } } } @@ -266,12 +266,12 @@ gnc_transaction_init(Transaction* trans) /* Fill in some sane defaults */ trans->num = CACHE_INSERT(""); trans->description = CACHE_INSERT(""); - trans->common_currency = NULL; - trans->splits = NULL; + trans->common_currency = nullptr; + trans->splits = nullptr; trans->date_entered = 0; trans->date_posted = 0; trans->marker = 0; - trans->orig = NULL; + trans->orig = nullptr; trans->txn_type = TXN_TYPE_UNCACHED; LEAVE (" "); } @@ -409,7 +409,7 @@ gnc_transaction_class_init(TransactionClass* klass) "by the register. For checks, it is usually the " "check number. For other types of transactions, " "it can be any string.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -421,7 +421,7 @@ gnc_transaction_class_init(TransactionClass* klass) "assigned by the user. It is usually the customer, " "vendor or other organization associated with the " "transaction.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -478,7 +478,7 @@ gnc_transaction_class_init(TransactionClass* klass) "Online Account ID", "The online account which corresponds to this " "account for OFX/HCBI import", - NULL, + nullptr, G_PARAM_READWRITE)); } @@ -503,11 +503,11 @@ xaccMallocTransaction (QofBook *book) { Transaction *trans; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); - trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, NULL)); + trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, nullptr)); xaccInitTransaction (trans, book); - qof_event_gen (&trans->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&trans->inst, QOF_EVENT_CREATE, nullptr); return trans; } @@ -557,7 +557,7 @@ xaccTransDump (const Transaction *trans, const char *tag) void xaccTransSortSplits (Transaction *trans) { - GList *node, *new_list = NULL; + GList *node, *new_list = nullptr; Split *split; /* first debits */ @@ -597,7 +597,7 @@ dupe_trans (const Transaction *from) Transaction *to; GList *node; - to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL)); + to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr)); CACHE_REPLACE (to->num, from->num); CACHE_REPLACE (to->description, from->description); @@ -611,7 +611,7 @@ dupe_trans (const Transaction *from) to->date_entered = from->date_entered; to->date_posted = from->date_posted; qof_instance_copy_version(to, from); - to->orig = NULL; + to->orig = nullptr; to->common_currency = from->common_currency; @@ -619,7 +619,7 @@ dupe_trans (const Transaction *from) * the cloned transaction as something official. If we ever * use this transaction, we'll have to fix this up. */ - to->inst.e_type = NULL; + to->inst.e_type = nullptr; qof_instance_set_guid(to, guid_null()); qof_instance_copy_book(to, from); qof_instance_copy_kvp (QOF_INSTANCE(to), QOF_INSTANCE(from)); @@ -640,7 +640,7 @@ xaccTransCloneNoKvp (const Transaction *from) GList *node; qof_event_suspend(); - to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL)); + to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr)); to->date_entered = from->date_entered; to->date_posted = from->date_posted; @@ -650,7 +650,7 @@ xaccTransCloneNoKvp (const Transaction *from) qof_instance_copy_version(to, from); qof_instance_copy_version_check(to, from); - to->orig = NULL; + to->orig = nullptr; qof_instance_init_data (&to->inst, GNC_ID_TRANS, qof_instance_get_book(from)); @@ -678,14 +678,14 @@ xaccTransClone (const Transaction *from) { PERR ("Cloned transaction has different number of splits from original"); xaccTransDestroy (to); - return NULL; + return nullptr; } xaccTransBeginEdit (to); qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from)); /* But not the online-id! */ - qof_instance_set (QOF_INSTANCE (to), "online-id", NULL, NULL); + qof_instance_set (QOF_INSTANCE (to), "online-id", nullptr, nullptr); for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto; lfrom = g_list_next (lfrom), lto = g_list_next (lto)) @@ -707,7 +707,7 @@ Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans) Transaction *to_trans; if (!from_trans) - return NULL; + return nullptr; to_trans = dupe_trans(from_trans); return to_trans; @@ -720,7 +720,7 @@ Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans) void xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans) { - xaccTransCopyFromClipBoard(from_trans, to_trans, NULL, NULL, TRUE); + xaccTransCopyFromClipBoard(from_trans, to_trans, nullptr, nullptr, TRUE); } /********************************************************************\ @@ -758,7 +758,7 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans, xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans)); xaccTransSetDescription(to_trans, xaccTransGetDescription(from_trans)); - if ((xaccTransGetNum(to_trans) == NULL) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0)) + if ((xaccTransGetNum(to_trans) == nullptr) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0)) xaccTransSetNum(to_trans, xaccTransGetNum(from_trans)); xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans)); @@ -800,7 +800,7 @@ xaccFreeTransaction (Transaction *trans) /* free up the destination splits */ g_list_free_full (trans->splits, (GDestroyNotify)xaccFreeSplit); - trans->splits = NULL; + trans->splits = nullptr; /* free up transaction strings */ CACHE_REMOVE(trans->num); @@ -808,13 +808,13 @@ xaccFreeTransaction (Transaction *trans) /* Just in case someone looks up freed memory ... */ trans->num = (char *) 1; - trans->description = NULL; + trans->description = nullptr; trans->date_entered = 0; trans->date_posted = 0; if (trans->orig) { xaccFreeTransaction (trans->orig); - trans->orig = NULL; + trans->orig = nullptr; } /* qof_instance_release (&trans->inst); */ @@ -859,7 +859,7 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb, if (!ta || !tb) { - PINFO ("one is NULL"); + PINFO ("one is nullptr"); return FALSE; } @@ -1018,7 +1018,7 @@ Transaction * xaccTransLookup (const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_TRANS); return (Transaction *) qof_collection_lookup_entity (col, guid); } @@ -1049,7 +1049,7 @@ xaccTransGetImbalance (const Transaction * trans) split or (2) all the splits are in the same currency. If there are no non-currency splits and not all splits are in the same currency then imbal_list is used to compute the imbalance. */ - MonetaryList *imbal_list = NULL; + MonetaryList *imbal_list = nullptr; gnc_numeric imbal_value = gnc_numeric_zero(); gboolean trading_accts; @@ -1122,7 +1122,7 @@ xaccTransIsBalanced (const Transaction *trans) gnc_numeric imbal = gnc_numeric_zero(); gnc_numeric imbal_trading = gnc_numeric_zero(); - if (trans == NULL) return FALSE; + if (trans == nullptr) return FALSE; if (xaccTransUseTradingAccounts(trans)) { @@ -1155,7 +1155,7 @@ xaccTransIsBalanced (const Transaction *trans) return TRUE; imbal_list = xaccTransGetImbalance(trans); - result = imbal_list == NULL; + result = imbal_list == nullptr; gnc_monetary_list_free(imbal_list); return result; } @@ -1199,7 +1199,7 @@ xaccTransGetRateForCommodity(const Transaction *trans, GList *splits; gnc_commodity *trans_curr; - if (trans == NULL || split_com == NULL || split == NULL) + if (trans == nullptr || split_com == nullptr || split == nullptr) return FALSE; trans_curr = xaccTransGetCurrency (trans); @@ -1305,7 +1305,7 @@ xaccTransGetAccountBalance (const Transaction *trans, const Account *account) { GList *node; - Split *last_split = NULL; + Split *last_split = nullptr; // Not really the appropriate error value. g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG)); @@ -1341,7 +1341,7 @@ xaccTransGetAccountBalance (const Transaction *trans, gnc_commodity * xaccTransGetCurrency (const Transaction *trans) { - return trans ? trans->common_currency : NULL; + return trans ? trans->common_currency : nullptr; } /* Helper functions for xaccTransSetCurrency */ @@ -1350,7 +1350,7 @@ find_new_rate(Transaction *trans, gnc_commodity *curr) { GList *node; gnc_numeric rate = gnc_numeric_zero(); - for (node = trans->splits; node != NULL; node = g_list_next (node)) + for (node = trans->splits; node != nullptr; node = g_list_next (node)) { Split *split = GNC_SPLIT(node->data); gnc_commodity *split_com = @@ -1405,7 +1405,7 @@ xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr) xaccTransBeginEdit(trans); trans->common_currency = curr; - if (old_curr != NULL && trans->splits != NULL) + if (old_curr != nullptr && trans->splits != nullptr) { gnc_numeric rate = find_new_rate(trans, curr); if (!gnc_numeric_zero_p (rate)) @@ -1477,7 +1477,7 @@ destroy_gains (Transaction *trans) { Transaction *t = s->gains_split->parent; xaccTransDestroy (t); - s->gains_split = NULL; + s->gains_split = nullptr; } } } @@ -1498,7 +1498,7 @@ do_destroy (QofInstance* inst) if (!shutting_down && !qof_book_is_readonly(qof_instance_get_book(trans))) xaccTransWriteLog (trans, 'D'); - qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, nullptr); /* xaccFreeTransaction will also clean up the splits but without * emitting GNC_EVENT_ITEM_REMOVED. */ @@ -1578,8 +1578,8 @@ static void trans_cleanup_commit(QofInstance *inst) { /* Split was either added, destroyed or just changed */ if (qof_instance_get_destroying(s)) - qof_event_gen(&s->inst, QOF_EVENT_DESTROY, NULL); - else qof_event_gen(&s->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen(&s->inst, QOF_EVENT_DESTROY, nullptr); + else qof_event_gen(&s->inst, QOF_EVENT_MODIFY, nullptr); xaccSplitCommitEdit(s); } } @@ -1592,7 +1592,7 @@ static void trans_cleanup_commit(QofInstance *inst) * so we don't need it any more. */ PINFO ("get rid of rollback trans=%p", trans->orig); xaccFreeTransaction (trans->orig); - trans->orig = NULL; + trans->orig = nullptr; /* Sort the splits. Why do we need to do this ?? */ /* Good question. Who knows? */ @@ -1603,7 +1603,7 @@ static void trans_cleanup_commit(QofInstance *inst) g_assert(qof_instance_get_editlevel(trans) == 0); gen_event_trans (trans); //TODO: could be conditional - qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, nullptr); } void @@ -1644,12 +1644,12 @@ xaccTransCommitEdit (Transaction *trans) * Call the trans scrub routine to fix it. Indirectly, this * routine also performs a number of other transaction fixes too. */ - xaccTransScrubImbalance (trans, NULL, NULL); + xaccTransScrubImbalance (trans, nullptr, nullptr); /* Get the cap gains into a consistent state as well. */ /* Lot Scrubbing is temporarily disabled. */ - if (g_getenv("GNC_AUTO_SCRUB_LOTS") != NULL) - xaccTransScrubGains (trans, NULL); + if (g_getenv("GNC_AUTO_SCRUB_LOTS") != nullptr) + xaccTransScrubGains (trans, nullptr); /* Allow scrubbing in transaction commit again */ scrub_data = 1; @@ -1658,7 +1658,7 @@ xaccTransCommitEdit (Transaction *trans) /* Record the time of last modification */ if (0 == trans->date_entered) { - trans->date_entered = gnc_time(NULL); + trans->date_entered = gnc_time(nullptr); qof_instance_set_dirty(QOF_INSTANCE(trans)); } @@ -1692,7 +1692,7 @@ xaccTransRollbackEdit (Transaction *trans) * there should be a stack of transaction states that are popped off * and restored at each level -- but it does prevent restoring to the * editlevel 0 state until one is returning to editlevel 0, and - * thereby prevents a crash caused by trans->orig getting NULLed too + * thereby prevents a crash caused by trans->orig getting nullptred too * soon. */ if (!qof_instance_get_editlevel (QOF_INSTANCE (trans))) return; @@ -1724,7 +1724,7 @@ xaccTransRollbackEdit (Transaction *trans) num_preexist = g_list_length(orig->splits); slist = g_list_copy(trans->splits); for (i = 0, node = slist, onode = orig->splits; node; - i++, node = node->next, onode = onode ? onode->next : NULL) + i++, node = node->next, onode = onode ? onode->next : nullptr) { Split *s = GNC_SPLIT(node->data); @@ -1766,7 +1766,7 @@ xaccTransRollbackEdit (Transaction *trans) belongs to the engine. Specifically, it's freed by the transaction to which it was added. Don't add the Split to more than one transaction during the begin/commit block! */ - if (NULL == xaccSplitGetParent(s)) + if (nullptr == xaccSplitGetParent(s)) { xaccFreeSplit(s); // a newly malloc'd split } @@ -1776,7 +1776,7 @@ xaccTransRollbackEdit (Transaction *trans) // orig->splits may still have duped splits so free them g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit); - orig->splits = NULL; + orig->splits = nullptr; /* Now that the engine copy is back to its original version, * get the backend to fix it in the database */ @@ -1825,7 +1825,7 @@ xaccTransRollbackEdit (Transaction *trans) xaccFreeTransaction (trans->orig); - trans->orig = NULL; + trans->orig = nullptr; qof_instance_set_destroying(trans, FALSE); /* Put back to zero. */ @@ -1849,7 +1849,7 @@ xaccTransIsOpen (const Transaction *trans) int xaccTransOrder (const Transaction *ta, const Transaction *tb) { - return xaccTransOrder_num_action (ta, NULL, tb, NULL); + return xaccTransOrder_num_action (ta, nullptr, tb, nullptr); } /* Order a pair of potentially numeric string as numbers if both @@ -1865,7 +1865,7 @@ xaccTransOrder (const Transaction *ta, const Transaction *tb) static int order_by_int64_or_string (const char* a, const char* b) { - char *end_a = NULL, *end_b = NULL; + char *end_a = nullptr, *end_b = nullptr; int cmp = 0; uint64_t na = strtoull(a, &end_a, 10); uint64_t nb = strtoull(b, &end_b, 10); @@ -1905,7 +1905,7 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna, } /* otherwise, sort on number string */ - if (actna && actnb) /* split action string, if not NULL */ + if (actna && actnb) /* split action string, if not nullptr */ { retval = order_by_int64_or_string (actna, actnb); } @@ -2067,7 +2067,7 @@ void xaccTransClearReadOnly (Transaction *trans) if (trans) { xaccTransBeginEdit(trans); - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, TRANS_READ_ONLY_REASON); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, TRANS_READ_ONLY_REASON); qof_instance_set_dirty(QOF_INSTANCE(trans)); xaccTransCommitEdit(trans); } @@ -2141,7 +2141,7 @@ xaccTransSetDocLink (Transaction *trans, const char *doclink) xaccTransBeginEdit(trans); if (doclink[0] == '\0') { - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, doclink_uri_str); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, doclink_uri_str); } else { @@ -2193,7 +2193,7 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing) } else { - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, trans_is_closing_str); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, trans_is_closing_str); } qof_instance_set_dirty(QOF_INSTANCE(trans)); xaccTransCommitEdit(trans); @@ -2239,10 +2239,10 @@ Split * xaccTransGetSplit (const Transaction *trans, int i) { int j = 0; - if (!trans || i < 0) return NULL; + if (!trans || i < 0) return nullptr; FOR_EACH_SPLIT(trans, { if (i == j) return s; j++; }); - return NULL; + return nullptr; } int @@ -2258,13 +2258,13 @@ xaccTransGetSplitIndex(const Transaction *trans, const Split *split) SplitList * xaccTransGetSplitList (const Transaction *trans) { - return trans ? trans->splits : NULL; + return trans ? trans->splits : nullptr; } SplitList * xaccTransGetPaymentAcctSplitList (const Transaction *trans) { - GList *pay_splits = NULL; + GList *pay_splits = nullptr; FOR_EACH_SPLIT (trans, const Account *account = xaccSplitGetAccount(s); if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account))) @@ -2278,8 +2278,8 @@ xaccTransGetPaymentAcctSplitList (const Transaction *trans) SplitList * xaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict) { - GList *apar_splits = NULL; - if (!trans) return NULL; + GList *apar_splits = nullptr; + if (!trans) return nullptr; FOR_EACH_SPLIT (trans, const Account *account = xaccSplitGetAccount(s); @@ -2312,7 +2312,7 @@ Split *xaccTransGetFirstPaymentAcctSplit(const Transaction *trans) return s; ); - return NULL; + return nullptr; } Split *xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict) @@ -2335,14 +2335,14 @@ Split *xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict } ); - return NULL; + return nullptr; } int xaccTransCountSplits (const Transaction *trans) { gint i = 0; - g_return_val_if_fail (trans != NULL, 0); + g_return_val_if_fail (trans != nullptr, 0); FOR_EACH_SPLIT(trans, i++); return i; } @@ -2350,23 +2350,23 @@ xaccTransCountSplits (const Transaction *trans) const char * xaccTransGetNum (const Transaction *trans) { - return trans ? trans->num : NULL; + return trans ? trans->num : nullptr; } const char * xaccTransGetDescription (const Transaction *trans) { - return trans ? trans->description : NULL; + return trans ? trans->description : nullptr; } const char * xaccTransGetDocLink (const Transaction *trans) { - g_return_val_if_fail (trans, NULL); + g_return_val_if_fail (trans, nullptr); GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, doclink_uri_str); - const char* doclink = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char* doclink = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return doclink; @@ -2375,11 +2375,11 @@ xaccTransGetDocLink (const Transaction *trans) const char * xaccTransGetNotes (const Transaction *trans) { - g_return_val_if_fail (trans, NULL); + g_return_val_if_fail (trans, nullptr); GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str); - const char *notes = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *notes = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return notes; @@ -2526,12 +2526,12 @@ const char * xaccTransGetReadOnly (Transaction *trans) { if (!trans) - return NULL; + return nullptr; GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_READ_ONLY_REASON); const char *readonly_reason = G_VALUE_HOLDS_STRING (&v) ? - g_value_get_string (&v) : NULL; + g_value_get_string (&v) : nullptr; g_value_unset (&v); return readonly_reason; } @@ -2540,17 +2540,17 @@ static gboolean xaccTransIsSXTemplate (const Transaction * trans) { Split *split0 = xaccTransGetSplit (trans, 0); - if (split0 != NULL) + if (split0 != nullptr) { - char* formula = NULL; - g_object_get (split0, "sx-debit-formula", &formula, NULL); - if (formula != NULL) + char* formula = nullptr; + g_object_get (split0, "sx-debit-formula", &formula, nullptr); + if (formula != nullptr) { g_free (formula); return TRUE; } - g_object_get (split0, "sx-credit-formula", &formula, NULL); - if (formula != NULL) + g_object_get (split0, "sx-credit-formula", &formula, nullptr); + if (formula != nullptr) { g_free (formula); return TRUE; @@ -2649,7 +2649,7 @@ xaccTransHasReconciledSplitsByAccount (const Transaction *trans, gboolean xaccTransHasReconciledSplits (const Transaction *trans) { - return xaccTransHasReconciledSplitsByAccount (trans, NULL); + return xaccTransHasReconciledSplitsByAccount (trans, nullptr); } @@ -2679,7 +2679,7 @@ xaccTransHasSplitsInStateByAccount (const Transaction *trans, gboolean xaccTransHasSplitsInState (const Transaction *trans, const char state) { - return xaccTransHasSplitsInStateByAccount (trans, state, NULL); + return xaccTransHasSplitsInStateByAccount (trans, state, nullptr); } @@ -2736,7 +2736,7 @@ xaccTransVoid(Transaction *trans, const char *reason) g_value_set_static_string (&v, reason); qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str); - gnc_time64_to_iso8601_buff (gnc_time(NULL), iso8601_str); + gnc_time64_to_iso8601_buff (gnc_time(nullptr), iso8601_str); g_value_set_static_string (&v, iso8601_str); qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str); g_value_unset (&v); @@ -2758,11 +2758,11 @@ xaccTransGetVoidStatus(const Transaction *trans) const char * xaccTransGetVoidReason(const Transaction *trans) { - g_return_val_if_fail (trans, NULL); + g_return_val_if_fail (trans, nullptr); GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str); - const char *void_reason = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *void_reason = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return void_reason; @@ -2772,7 +2772,7 @@ time64 xaccTransGetVoidTime(const Transaction *tr) { GValue v = G_VALUE_INIT; - const char *s = NULL; + const char *s = nullptr; time64 void_time = 0; g_return_val_if_fail(tr, void_time); @@ -2791,19 +2791,19 @@ void xaccTransUnvoid (Transaction *trans) { GValue v = G_VALUE_INIT; - const char *s = NULL; + const char *s = nullptr; g_return_if_fail(trans); s = xaccTransGetVoidReason (trans); - if (s == NULL) return; /* Transaction isn't voided. Bail. */ + if (s == nullptr) return; /* Transaction isn't voided. Bail. */ xaccTransBeginEdit(trans); qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_former_notes_str); if (G_VALUE_HOLDS_STRING (&v)) qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str); - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_former_notes_str); - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_reason_str); - qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_time_str); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_former_notes_str); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_reason_str); + qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_time_str); g_value_unset (&v); FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s)); @@ -2818,7 +2818,7 @@ xaccTransReverse (Transaction *orig) { Transaction *trans; GValue v = G_VALUE_INIT; - g_return_val_if_fail(orig, NULL); + g_return_val_if_fail(orig, nullptr); /* First edit, dirty, and commit orig to ensure that any trading * splits are correctly balanced. @@ -2828,7 +2828,7 @@ xaccTransReverse (Transaction *orig) xaccTransCommitEdit (orig); trans = xaccTransClone(orig); - g_return_val_if_fail (trans, NULL); + g_return_val_if_fail (trans, nullptr); xaccTransBeginEdit(trans); /* Reverse the values on each split. Clear per-split info. */ @@ -2857,8 +2857,8 @@ Transaction * xaccTransGetReversedBy(const Transaction *trans) { GValue v = G_VALUE_INIT; - Transaction *retval = NULL; - g_return_val_if_fail(trans, NULL); + Transaction *retval = nullptr; + g_return_val_if_fail(trans, nullptr); qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY); if (G_VALUE_HOLDS_BOXED (&v)) { @@ -2956,9 +2956,9 @@ restart: Split * xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc) { - if (!trans || !acc) return NULL; + if (!trans || !acc) return nullptr; FOR_EACH_SPLIT(trans, if (xaccSplitGetAccount(s) == acc) return s); - return NULL; + return nullptr; } static void @@ -3080,7 +3080,7 @@ gnc_transaction_book_end(QofBook* book) QofCollection *col; col = qof_book_get_collection(book, GNC_ID_TRANS); - qof_collection_foreach(col, destroy_tx_on_book_close, NULL); + qof_collection_foreach(col, destroy_tx_on_book_close, nullptr); } #ifdef _MSC_VER @@ -3098,7 +3098,7 @@ static QofObject trans_object_def = DI(.e_type = ) GNC_ID_TRANS, DI(.type_label = ) "Transaction", DI(.create = ) (void* (*)(QofBook*))xaccMallocTransaction, - DI(.book_begin = ) NULL, + DI(.book_begin = ) nullptr, DI(.book_end = ) gnc_transaction_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, @@ -3140,11 +3140,11 @@ gboolean xaccTransRegister (void) }, { TRANS_DATE_DUE, QOF_TYPE_DATE, - (QofAccessFunc)xaccTransRetDateDue, NULL + (QofAccessFunc)xaccTransRetDateDue, nullptr }, { TRANS_IMBALANCE, QOF_TYPE_NUMERIC, - (QofAccessFunc)xaccTransGetImbalanceValue, NULL + (QofAccessFunc)xaccTransGetImbalanceValue, nullptr }, { TRANS_NOTES, QOF_TYPE_STRING, @@ -3158,11 +3158,11 @@ gboolean xaccTransRegister (void) }, { TRANS_IS_CLOSING, QOF_TYPE_BOOLEAN, - (QofAccessFunc)xaccTransGetIsClosingTxn, NULL + (QofAccessFunc)xaccTransGetIsClosingTxn, nullptr }, { TRANS_IS_BALANCED, QOF_TYPE_BOOLEAN, - (QofAccessFunc)trans_is_balanced_p, NULL + (QofAccessFunc)trans_is_balanced_p, nullptr }, { TRANS_TYPE, QOF_TYPE_CHAR, @@ -3171,29 +3171,29 @@ gboolean xaccTransRegister (void) }, { TRANS_VOID_STATUS, QOF_TYPE_BOOLEAN, - (QofAccessFunc)xaccTransGetVoidStatus, NULL + (QofAccessFunc)xaccTransGetVoidStatus, nullptr }, { TRANS_VOID_REASON, QOF_TYPE_STRING, - (QofAccessFunc)xaccTransGetVoidReason, NULL + (QofAccessFunc)xaccTransGetVoidReason, nullptr }, { TRANS_VOID_TIME, QOF_TYPE_DATE, - (QofAccessFunc)xaccTransGetVoidTime, NULL + (QofAccessFunc)xaccTransGetVoidTime, nullptr }, { TRANS_SPLITLIST, GNC_ID_SPLIT, - (QofAccessFunc)xaccTransGetSplitList, NULL + (QofAccessFunc)xaccTransGetSplitList, nullptr }, { QOF_PARAM_BOOK, QOF_ID_BOOK, - (QofAccessFunc)qof_instance_get_book, NULL + (QofAccessFunc)qof_instance_get_book, nullptr }, { QOF_PARAM_GUID, QOF_TYPE_GUID, - (QofAccessFunc)qof_entity_get_guid, NULL + (QofAccessFunc)qof_entity_get_guid, nullptr }, - { NULL }, + { nullptr }, }; qof_class_register (GNC_ID_TRANS, (QofSortFunc)xaccTransOrder, params); diff --git a/libgnucash/engine/gnc-budget.cpp b/libgnucash/engine/gnc-budget.cpp index e64233d63f..737c241e5a 100644 --- a/libgnucash/engine/gnc-budget.cpp +++ b/libgnucash/engine/gnc-budget.cpp @@ -219,7 +219,7 @@ gnc_budget_class_init(GncBudgetClass* klass) "to be a short, 5 to 30 character long string " "that is displayed by the GUI as the " "budget mnemonic", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property( @@ -231,7 +231,7 @@ gnc_budget_class_init(GncBudgetClass* klass) "assigned by the user. It is intended " "to be a longer, 1-5 sentence description of " "what the budget is all about.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property( @@ -266,7 +266,7 @@ gnc_budget_free(QofInstance *inst) GncBudget *budget; GncBudgetPrivate* priv; - if (inst == NULL) + if (inst == nullptr) return; g_return_if_fail(GNC_IS_BUDGET(inst)); @@ -276,7 +276,7 @@ gnc_budget_free(QofInstance *inst) /* We first send the message that this object is about to be * destroyed so that any GUI elements can remove it before it is * actually gone. */ - qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, nullptr); CACHE_REMOVE(priv->name); CACHE_REMOVE(priv->description); @@ -305,14 +305,14 @@ gnc_budget_commit_edit(GncBudget *bgt) GncBudget* gnc_budget_new(QofBook *book) { - g_return_val_if_fail(book, NULL); + g_return_val_if_fail(book, nullptr); ENTER(" "); auto budget { static_cast(g_object_new(GNC_TYPE_BUDGET, nullptr)) }; qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book); - qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL); + qof_event_gen( &budget->inst, QOF_EVENT_CREATE , nullptr); LEAVE(" "); return budget; @@ -359,7 +359,7 @@ gnc_budget_clone(const GncBudget* old_b) Account* root; CloneBudgetData_t clone_data; - g_return_val_if_fail(old_b != NULL, NULL); + g_return_val_if_fail(old_b != nullptr, nullptr); ENTER(" "); @@ -398,13 +398,13 @@ gnc_budget_set_name(GncBudget* budget, const gchar* name) qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } const gchar* gnc_budget_get_name(const GncBudget* budget) { - g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); + g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr); return GET_PRIVATE(budget)->name; } @@ -423,13 +423,13 @@ gnc_budget_set_description(GncBudget* budget, const gchar* description) qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } const gchar* gnc_budget_get_description(const GncBudget* budget) { - g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); + g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr); return GET_PRIVATE(budget)->description; } @@ -446,21 +446,21 @@ gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r) qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen(&budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen(&budget->inst, QOF_EVENT_MODIFY, nullptr); } const Recurrence * gnc_budget_get_recurrence(const GncBudget *budget) { - g_return_val_if_fail(budget, NULL); + g_return_val_if_fail(budget, nullptr); return (&GET_PRIVATE(budget)->recurrence); } const GncGUID* gnc_budget_get_guid(const GncBudget* budget) { - g_return_val_if_fail(budget, NULL); - g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); + g_return_val_if_fail(budget, nullptr); + g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr); return qof_instance_get_guid(QOF_INSTANCE(budget)); } @@ -486,7 +486,7 @@ gnc_budget_set_num_periods(GncBudget* budget, guint num_periods) qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } guint @@ -522,8 +522,8 @@ void gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account, guint period_num) { - g_return_if_fail (budget != NULL); - g_return_if_fail (account != NULL); + g_return_if_fail (budget != nullptr); + g_return_if_fail (account != nullptr); g_return_if_fail (period_num < GET_PRIVATE(budget)->num_periods); auto& data = get_perioddata (budget, account, period_num); @@ -536,7 +536,7 @@ gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account, qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } @@ -554,8 +554,8 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account, return; } - g_return_if_fail (budget != NULL); - g_return_if_fail (account != NULL); + g_return_if_fail (budget != nullptr); + g_return_if_fail (account != nullptr); auto& perioddata = get_perioddata (budget, account, period_num); auto budget_kvp { QOF_INSTANCE (budget)->kvp_data }; @@ -576,7 +576,7 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account, qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } @@ -613,15 +613,15 @@ gnc_budget_set_account_period_note(GncBudget *budget, const Account *account, return; } - g_return_if_fail (budget != NULL); - g_return_if_fail (account != NULL); + g_return_if_fail (budget != nullptr); + g_return_if_fail (account != nullptr); auto& perioddata = get_perioddata (budget, account, period_num); auto budget_kvp { QOF_INSTANCE (budget)->kvp_data }; auto path = make_period_note_path (account, period_num); gnc_budget_begin_edit(budget); - if (note == NULL) + if (note == nullptr) { delete budget_kvp->set_path (path, nullptr); perioddata.note.clear (); @@ -636,7 +636,7 @@ gnc_budget_set_account_period_note(GncBudget *budget, const Account *account, qof_instance_set_dirty(&budget->inst); gnc_budget_commit_edit(budget); - qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr); } @@ -710,8 +710,8 @@ gnc_budget_lookup (const GncGUID *guid, const QofBook *book) { QofCollection *col; - g_return_val_if_fail(guid, NULL); - g_return_val_if_fail(book, NULL); + g_return_val_if_fail(guid, nullptr); + g_return_val_if_fail(book, nullptr); col = qof_book_get_collection (book, GNC_ID_BUDGET); return GNC_BUDGET(qof_collection_lookup_entity (col, guid)); } @@ -726,14 +726,14 @@ GncBudget* gnc_budget_get_default (QofBook *book) { QofCollection *col; - GncBudget *bgt = NULL; - GncGUID *default_budget_guid = NULL; + GncBudget *bgt = nullptr; + GncGUID *default_budget_guid = nullptr; - g_return_val_if_fail(book, NULL); + g_return_val_if_fail(book, nullptr); qof_instance_get (QOF_INSTANCE (book), "default-budget", &default_budget_guid, - NULL); + nullptr); if (default_budget_guid) { col = qof_book_get_collection(book, GNC_ID_BUDGET); @@ -743,7 +743,7 @@ gnc_budget_get_default (QofBook *book) /* Revert to 2.2.x behavior if the book has no default budget. */ - if ( bgt == NULL ) + if ( bgt == nullptr ) { col = qof_book_get_collection(book, GNC_ID_BUDGET); if (qof_collection_count(col) > 0) @@ -774,7 +774,7 @@ gnc_budget_book_end(QofBook* book) QofCollection *col; col = qof_book_get_collection(book, GNC_ID_BUDGET); - qof_collection_foreach(col, destroy_budget_on_book_close, NULL); + qof_collection_foreach(col, destroy_budget_on_book_close, nullptr); } #ifdef _MSC_VER @@ -792,7 +792,7 @@ static QofObject budget_object_def = DI(.e_type = ) GNC_ID_BUDGET, DI(.type_label = ) "Budget", DI(.create = ) (void*(*)(QofBook*)) gnc_budget_new, - DI(.book_begin = ) NULL, + DI(.book_begin = ) nullptr, DI(.book_end = ) gnc_budget_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, @@ -833,19 +833,19 @@ gboolean gnc_budget_register (void) }, { "recurrence_period_type", QOF_TYPE_INT32, - (QofAccessFunc) gnc_budget_get_rec_pt, NULL + (QofAccessFunc) gnc_budget_get_rec_pt, nullptr }, /* Signedness problem: Should be unsigned. */ { "recurrence_multiplier", QOF_TYPE_INT32, - (QofAccessFunc) gnc_budget_get_rec_mult, NULL + (QofAccessFunc) gnc_budget_get_rec_mult, nullptr }, /* This is the same way that SchedXaction.c uses QOF_TYPE_DATE but I don't think QOF actually supports a GDate, so I think this is wrong. */ { "recurrence_date", QOF_TYPE_DATE, - (QofAccessFunc) gnc_budget_get_rec_time, NULL + (QofAccessFunc) gnc_budget_get_rec_time, nullptr }, /* Signedness problem: Should be unsigned. */ { @@ -855,15 +855,15 @@ gboolean gnc_budget_register (void) }, { QOF_PARAM_BOOK, QOF_ID_BOOK, - (QofAccessFunc) qof_instance_get_book, NULL + (QofAccessFunc) qof_instance_get_book, nullptr }, { QOF_PARAM_GUID, QOF_TYPE_GUID, - (QofAccessFunc) qof_instance_get_guid, NULL + (QofAccessFunc) qof_instance_get_guid, nullptr }, - { NULL }, + { nullptr }, }; - qof_class_register(GNC_ID_BUDGET, (QofSortFunc) NULL, params); + qof_class_register(GNC_ID_BUDGET, (QofSortFunc) nullptr, params); return qof_object_register(&budget_object_def); } diff --git a/libgnucash/engine/gnc-commodity.cpp b/libgnucash/engine/gnc-commodity.cpp index 18c84ce27f..b0b2a6fd3a 100644 --- a/libgnucash/engine/gnc-commodity.cpp +++ b/libgnucash/engine/gnc-commodity.cpp @@ -303,7 +303,7 @@ gnc_quote_source_fq_installed (void) * gnc_quote_source_fq_version * * This function the version of the Finance::Quote module installed - * on a user's computer or NULL if no installation is found. + * on a user's computer or nullptr if no installation is found. ********************************************************************/ const char* gnc_quote_source_fq_version (void) @@ -553,7 +553,7 @@ static void mark_commodity_dirty (gnc_commodity *cm) { qof_instance_set_dirty(&cm->inst); - qof_event_gen (&cm->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen (&cm->inst, QOF_EVENT_MODIFY, nullptr); } static void @@ -587,13 +587,13 @@ gnc_commodity_init(gnc_commodity* com) priv = GET_PRIVATE(com); - priv->name_space = NULL; + priv->name_space = nullptr; priv->fullname = CACHE_INSERT(""); priv->mnemonic = CACHE_INSERT(""); priv->cusip = CACHE_INSERT(""); priv->fraction = 10000; priv->quote_flag = 0; - priv->quote_source = NULL; + priv->quote_source = nullptr; priv->quote_tz = CACHE_INSERT(""); reset_printname(priv); @@ -737,7 +737,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass) "Full Commodity Name", "The fullname is the official full name of" "the currency.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property(gobject_class, PROP_MNEMONIC, @@ -745,21 +745,21 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass) "Commodity Mnemonic", "The mnemonic is the official abbreviated" "designation for the currency.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property(gobject_class, PROP_PRINTNAME, g_param_spec_string ("printname", "Commodity Print Name", "Printable form of the commodity name.", - NULL, + nullptr, G_PARAM_READABLE)); g_object_class_install_property(gobject_class, PROP_CUSIP, g_param_spec_string ("cusip", "Commodity CUSIP Code", "?????", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property(gobject_class, PROP_FRACTION, @@ -777,7 +777,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass) "Commodity Unique Name", "Unique form of the commodity name which combines " "the namespace name and the commodity name.", - NULL, + nullptr, G_PARAM_READABLE)); g_object_class_install_property(gobject_class, PROP_QUOTE_FLAG, @@ -798,7 +798,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass) g_param_spec_string ("quote-tz", "Commodity Quote Timezone", "?????", - NULL, + nullptr, G_PARAM_READWRITE)); } @@ -807,12 +807,12 @@ gnc_commodity_new(QofBook *book, const char * fullname, const char * name_space, const char * mnemonic, const char * cusip, int fraction) { - auto retval = GNC_COMMODITY(g_object_new(GNC_TYPE_COMMODITY, NULL)); + auto retval = GNC_COMMODITY(g_object_new(GNC_TYPE_COMMODITY, nullptr)); qof_instance_init_data (&retval->inst, GNC_ID_COMMODITY, book); gnc_commodity_begin_edit(retval); - if ( name_space != NULL ) + if ( name_space != nullptr ) { /* Prevent setting anything except template in namespace template. */ if (g_strcmp0 (name_space, GNC_COMMODITY_NS_TEMPLATE) == 0 && @@ -836,7 +836,7 @@ gnc_commodity_new(QofBook *book, const char * fullname, mark_commodity_dirty (retval); gnc_commodity_commit_edit(retval); - qof_event_gen (&retval->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&retval->inst, QOF_EVENT_CREATE, nullptr); return retval; } @@ -860,24 +860,24 @@ commodity_free(gnc_commodity * cm) gnc_commodity_table_remove(table, cm); priv = GET_PRIVATE(cm); - qof_event_gen (&cm->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&cm->inst, QOF_EVENT_DESTROY, nullptr); /* Set at creation */ CACHE_REMOVE (priv->fullname); CACHE_REMOVE (priv->cusip); CACHE_REMOVE (priv->mnemonic); CACHE_REMOVE (priv->quote_tz); - priv->name_space = NULL; + priv->name_space = nullptr; /* Set through accessor functions */ - priv->quote_source = NULL; + priv->quote_source = nullptr; /* Automatically generated */ g_free(priv->printname); - priv->printname = NULL; + priv->printname = nullptr; g_free(priv->unique_name); - priv->unique_name = NULL; + priv->unique_name = nullptr; #ifdef ACCOUNTS_CLEANED_UP /* Account objects are not actually cleaned up when a book is closed (in fact @@ -926,7 +926,7 @@ gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book) gnc_commodityPrivate* src_priv; gnc_commodityPrivate* dest_priv; - auto dest = GNC_COMMODITY (g_object_new(GNC_TYPE_COMMODITY, NULL)); + auto dest = GNC_COMMODITY (g_object_new(GNC_TYPE_COMMODITY, nullptr)); qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book); src_priv = GET_PRIVATE(src); dest_priv = GET_PRIVATE(dest); @@ -958,7 +958,7 @@ gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book) const char * gnc_commodity_get_mnemonic(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->mnemonic; } @@ -969,7 +969,7 @@ gnc_commodity_get_mnemonic(const gnc_commodity * cm) const char * gnc_commodity_get_printname(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->printname; } @@ -981,14 +981,14 @@ gnc_commodity_get_printname(const gnc_commodity * cm) const char * gnc_commodity_get_namespace(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return gnc_commodity_namespace_get_name(GET_PRIVATE(cm)->name_space); } gnc_commodity_namespace * gnc_commodity_get_namespace_ds(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->name_space; } @@ -999,7 +999,7 @@ gnc_commodity_get_namespace_ds(const gnc_commodity * cm) const char * gnc_commodity_get_fullname(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->fullname; } @@ -1011,7 +1011,7 @@ gnc_commodity_get_fullname(const gnc_commodity * cm) const char * gnc_commodity_get_unique_name(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->unique_name; } @@ -1023,7 +1023,7 @@ gnc_commodity_get_unique_name(const gnc_commodity * cm) const char * gnc_commodity_get_cusip(const gnc_commodity * cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->cusip; } @@ -1077,7 +1077,7 @@ gnc_commodity_get_quote_source(const gnc_commodity *cm) { gnc_commodityPrivate* priv; - if (!cm) return NULL; + if (!cm) return nullptr; priv = GET_PRIVATE(cm); if (!priv->quote_source && gnc_commodity_is_iso(cm)) return ¤cy_quote_sources[0]; @@ -1100,7 +1100,7 @@ gnc_commodity_get_default_quote_source(const gnc_commodity *cm) const char* gnc_commodity_get_quote_tz(const gnc_commodity *cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->quote_tz; } @@ -1110,11 +1110,11 @@ gnc_commodity_get_quote_tz(const gnc_commodity *cm) const char* gnc_commodity_get_user_symbol(const gnc_commodity *cm) { - g_return_val_if_fail (GNC_IS_COMMODITY (cm), NULL); + g_return_val_if_fail (GNC_IS_COMMODITY (cm), nullptr); GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol"); - const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return rv; } @@ -1125,7 +1125,7 @@ gnc_commodity_get_user_symbol(const gnc_commodity *cm) const char* gnc_commodity_get_default_symbol(const gnc_commodity *cm) { - if (!cm) return NULL; + if (!cm) return nullptr; return GET_PRIVATE(cm)->default_symbol; } @@ -1137,7 +1137,7 @@ gnc_commodity_get_nice_symbol (const gnc_commodity *cm) { const char *nice_symbol; struct lconv *lc; - if (!cm) return NULL; + if (!cm) return nullptr; nice_symbol = gnc_commodity_get_user_symbol(cm); if (nice_symbol && *nice_symbol) @@ -1284,7 +1284,7 @@ gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm, } gnc_commodity_begin_edit(cm); if (flag) - qof_instance_set_kvp (QOF_INSTANCE (cm), NULL, 1, "auto_quote_control"); + qof_instance_set_kvp (QOF_INSTANCE (cm), nullptr, 1, "auto_quote_control"); else { g_value_init (&v, G_TYPE_STRING); @@ -1411,14 +1411,14 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol) lc = gnc_localeconv(); if (!user_symbol || !*user_symbol) - user_symbol = NULL; + user_symbol = nullptr; else if (!g_strcmp0(lc->int_curr_symbol, gnc_commodity_get_mnemonic(cm)) && !g_strcmp0(lc->currency_symbol, user_symbol)) /* if the user gives the ISO symbol for the locale currency or the * default symbol, actually remove the user symbol */ - user_symbol = NULL; + user_symbol = nullptr; else if (!g_strcmp0(user_symbol, gnc_commodity_get_default_symbol(cm))) - user_symbol = NULL; + user_symbol = nullptr; gnc_commodity_begin_edit (cm); @@ -1432,7 +1432,7 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol) } else { - qof_instance_set_kvp (QOF_INSTANCE(cm), NULL, 1, "user_symbol"); + qof_instance_set_kvp (QOF_INSTANCE(cm), nullptr, 1, "user_symbol"); } mark_commodity_dirty(cm); @@ -1581,16 +1581,16 @@ int gnc_commodity_compare_void(const void * a, const void * b) const char * gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns) { - if (ns == NULL) - return NULL; + if (ns == nullptr) + return nullptr; return ns->name; } const char * gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns) { - if (ns == NULL) - return NULL; + if (ns == nullptr) + return nullptr; if (g_strcmp0 (ns->name, GNC_COMMODITY_NS_CURRENCY) == 0) return GNC_COMMODITY_NS_ISO_GUI; return ns->name; @@ -1600,7 +1600,7 @@ GList * gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space) { if (!name_space) - return NULL; + return nullptr; return name_space->cm_list; } @@ -1630,7 +1630,7 @@ gnc_commodity_table_new(void) { gnc_commodity_table * retval = g_new0(gnc_commodity_table, 1); retval->ns_table = g_hash_table_new(&g_str_hash, &g_str_equal); - retval->ns_list = NULL; + retval->ns_list = nullptr; return retval; } @@ -1641,7 +1641,7 @@ gnc_commodity_table_new(void) gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book) { - if (!book) return NULL; + if (!book) return nullptr; return static_cast(qof_book_get_data (book, GNC_COMMODITY_TABLE)); } @@ -1652,9 +1652,9 @@ gnc_commodity_obtain_twin (const gnc_commodity *from, QofBook *book) const char * ucom; gnc_commodity_table * comtbl; - if (!from) return NULL; + if (!from) return nullptr; comtbl = gnc_commodity_table_get_table (book); - if (!comtbl) return NULL; + if (!comtbl) return nullptr; ucom = gnc_commodity_get_unique_name (from); twin = gnc_commodity_table_lookup_unique (comtbl, ucom); @@ -1709,9 +1709,9 @@ gnc_commodity * gnc_commodity_table_lookup(const gnc_commodity_table * table, const char * name_space, const char * mnemonic) { - gnc_commodity_namespace * nsp = NULL; + gnc_commodity_namespace * nsp = nullptr; - if (!table || !name_space || !mnemonic) return NULL; + if (!table || !name_space || !mnemonic) return nullptr; nsp = gnc_commodity_table_find_namespace(table, name_space); @@ -1731,7 +1731,7 @@ gnc_commodity_table_lookup(const gnc_commodity_table * table, } else { - return NULL; + return nullptr; } } @@ -1748,14 +1748,14 @@ gnc_commodity_table_lookup_unique(const gnc_commodity_table *table, char *mnemonic; gnc_commodity *commodity; - if (!table || !unique_name) return NULL; + if (!table || !unique_name) return nullptr; name_space = g_strdup (unique_name); mnemonic = strstr (name_space, "::"); if (!mnemonic) { g_free (name_space); - return NULL; + return nullptr; } *mnemonic = '\0'; @@ -1778,12 +1778,12 @@ gnc_commodity_table_find_full(const gnc_commodity_table * table, const char * name_space, const char * fullname) { - gnc_commodity * retval = NULL; + gnc_commodity * retval = nullptr; GList * all; GList * iterator; if (!fullname || (fullname[0] == '\0')) - return NULL; + return nullptr; all = gnc_commodity_table_get_commodities(table, name_space); @@ -1813,20 +1813,20 @@ gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table, gnc_commodity * comm) { - gnc_commodity_namespace * nsp = NULL; + gnc_commodity_namespace * nsp = nullptr; gnc_commodity *c; const char *ns_name; gnc_commodityPrivate* priv; QofBook *book; - if (!table) return NULL; - if (!comm) return NULL; + if (!table) return nullptr; + if (!comm) return nullptr; priv = GET_PRIVATE(comm); ENTER ("(table=%p, comm=%p) %s %s", table, comm, - (priv->mnemonic == NULL ? "(null)" : priv->mnemonic), - (priv->fullname == NULL ? "(null)" : priv->fullname)); + (priv->mnemonic == nullptr ? "(null)" : priv->mnemonic), + (priv->fullname == nullptr ? "(null)" : priv->fullname)); ns_name = gnc_commodity_namespace_get_name(priv->name_space); c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic); @@ -1873,7 +1873,7 @@ gnc_commodity_table_insert(gnc_commodity_table * table, (gpointer)comm); nsp->cm_list = g_list_append(nsp->cm_list, comm); - qof_event_gen (&comm->inst, QOF_EVENT_ADD, NULL); + qof_event_gen (&comm->inst, QOF_EVENT_ADD, nullptr); LEAVE ("(table=%p, comm=%p)", table, comm); return comm; } @@ -1900,7 +1900,7 @@ gnc_commodity_table_remove(gnc_commodity_table * table, c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic); if (c != comm) return; - qof_event_gen (&comm->inst, QOF_EVENT_REMOVE, NULL); + qof_event_gen (&comm->inst, QOF_EVENT_REMOVE, nullptr); nsp = gnc_commodity_table_find_namespace(table, ns_name); if (!nsp) return; @@ -1919,7 +1919,7 @@ int gnc_commodity_table_has_namespace(const gnc_commodity_table * table, const char * name_space) { - gnc_commodity_namespace * nsp = NULL; + gnc_commodity_namespace * nsp = nullptr; if (!table || !name_space) { @@ -1947,7 +1947,7 @@ hash_keys_helper(gpointer key, gpointer value, gpointer data) static GList * g_hash_table_keys(GHashTable * table) { - GList * l = NULL; + GList * l = nullptr; g_hash_table_foreach(table, &hash_keys_helper, (gpointer) &l); return l; } @@ -1962,7 +1962,7 @@ hash_values_helper(gpointer key, gpointer value, gpointer data) static GList * g_hash_table_values(GHashTable * table) { - GList * l = NULL; + GList * l = nullptr; g_hash_table_foreach(table, &hash_values_helper, (gpointer) &l); return l; } @@ -1976,7 +1976,7 @@ GList * gnc_commodity_table_get_namespaces(const gnc_commodity_table * table) { if (!table) - return NULL; + return nullptr; return g_hash_table_keys(table->ns_table); } @@ -1985,7 +1985,7 @@ GList * gnc_commodity_table_get_namespaces_list(const gnc_commodity_table * table) { if (!table) - return NULL; + return nullptr; return table->ns_list; } @@ -2027,11 +2027,11 @@ gnc_commodity_is_currency(const gnc_commodity *cm) static CommodityList* commodity_table_get_all_noncurrency_commodities(const gnc_commodity_table* table) { - GList *node = NULL, *nslist = gnc_commodity_table_get_namespaces(table); - CommodityList *retval = NULL; + GList *node = nullptr, *nslist = gnc_commodity_table_get_namespaces(table); + CommodityList *retval = nullptr; for (node = nslist; node; node=g_list_next(node)) { - gnc_commodity_namespace *ns = NULL; + gnc_commodity_namespace *ns = nullptr; if (g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_CURRENCY) == 0 || g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_TEMPLATE) == 0) continue; @@ -2048,15 +2048,15 @@ CommodityList * gnc_commodity_table_get_commodities(const gnc_commodity_table * table, const char * name_space) { - gnc_commodity_namespace * ns = NULL; + gnc_commodity_namespace * ns = nullptr; if (!table) - return NULL; + return nullptr; if (g_strcmp0(name_space, GNC_COMMODITY_NS_NONISO_GUI) == 0) return commodity_table_get_all_noncurrency_commodities(table); ns = gnc_commodity_table_find_namespace(table, name_space); if (!ns) - return NULL; + return nullptr; return g_hash_table_values(ns->cm_table); } @@ -2093,30 +2093,30 @@ get_quotables_helper2 (gnc_commodity *comm, gpointer data) CommodityList * gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table) { - gnc_commodity_namespace * ns = NULL; + gnc_commodity_namespace * ns = nullptr; const char *name_space; GList * nslist, * tmp; - GList * l = NULL; + GList * l = nullptr; regex_t pattern; const char *expression = gnc_prefs_get_namespace_regexp(); ENTER("table=%p, expression=%s", table, expression); if (!table) - return NULL; + return nullptr; if (expression && *expression) { if (regcomp(&pattern, expression, REG_EXTENDED | REG_ICASE) != 0) { LEAVE("Cannot compile regex"); - return NULL; + return nullptr; } nslist = gnc_commodity_table_get_namespaces(table); for (tmp = nslist; tmp; tmp = tmp->next) { name_space = static_cast(tmp->data); - if (regexec(&pattern, name_space, 0, NULL, 0) == 0) + if (regexec(&pattern, name_space, 0, nullptr, 0) == 0) { DEBUG("Running list of %s commodities", name_space); ns = gnc_commodity_table_find_namespace(table, name_space); @@ -2166,26 +2166,26 @@ gnc_commodity_table_add_namespace(gnc_commodity_table * table, const char * name_space, QofBook *book) { - gnc_commodity_namespace * ns = NULL; + gnc_commodity_namespace * ns = nullptr; - if (!table) return NULL; + if (!table) return nullptr; name_space = gnc_commodity_table_map_namespace(name_space); ns = gnc_commodity_table_find_namespace(table, name_space); if (!ns) { - ns = static_cast(g_object_new(GNC_TYPE_COMMODITY_NAMESPACE, NULL)); + ns = static_cast(g_object_new(GNC_TYPE_COMMODITY_NAMESPACE, nullptr)); ns->cm_table = g_hash_table_new(g_str_hash, g_str_equal); ns->name = CACHE_INSERT(static_cast(name_space)); ns->iso4217 = gnc_commodity_namespace_is_iso(name_space); qof_instance_init_data (&ns->inst, GNC_ID_COMMODITY_NAMESPACE, book); - qof_event_gen (&ns->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&ns->inst, QOF_EVENT_CREATE, nullptr); g_hash_table_insert(table->ns_table, (gpointer) ns->name, (gpointer) ns); table->ns_list = g_list_append(table->ns_list, ns); - qof_event_gen (&ns->inst, QOF_EVENT_ADD, NULL); + qof_event_gen (&ns->inst, QOF_EVENT_ADD, nullptr); } return ns; } @@ -2196,7 +2196,7 @@ gnc_commodity_table_find_namespace(const gnc_commodity_table * table, const char * name_space) { if (!table || !name_space) - return NULL; + return nullptr; name_space = gnc_commodity_table_map_namespace(name_space); return static_cast(g_hash_table_lookup(table->ns_table, (gpointer)name_space)); @@ -2207,7 +2207,7 @@ gnc_commodity * gnc_commodity_find_commodity_by_guid(const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_COMMODITY); return (gnc_commodity *) qof_collection_lookup_entity (col, guid); } @@ -2238,18 +2238,18 @@ gnc_commodity_table_delete_namespace(gnc_commodity_table * table, if (!ns) return; - qof_event_gen (&ns->inst, QOF_EVENT_REMOVE, NULL); + qof_event_gen (&ns->inst, QOF_EVENT_REMOVE, nullptr); g_hash_table_remove(table->ns_table, name_space); table->ns_list = g_list_remove(table->ns_list, ns); g_list_free(ns->cm_list); - ns->cm_list = NULL; + ns->cm_list = nullptr; - g_hash_table_foreach_remove(ns->cm_table, ns_helper, NULL); + g_hash_table_foreach_remove(ns->cm_table, ns_helper, nullptr); g_hash_table_destroy(ns->cm_table); CACHE_REMOVE(ns->name); - qof_event_gen (&ns->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&ns->inst, QOF_EVENT_DESTROY, nullptr); /* qof_instance_release(&ns->inst); */ g_object_unref(ns); } @@ -2326,9 +2326,9 @@ gnc_commodity_table_destroy(gnc_commodity_table * t) } g_list_free(t->ns_list); - t->ns_list = NULL; + t->ns_list = nullptr; g_hash_table_destroy(t->ns_table); - t->ns_table = NULL; + t->ns_table = nullptr; LEAVE ("table=%p", t); g_free(t); } @@ -2382,9 +2382,9 @@ static QofObject commodity_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_COMMODITY, DI(.type_label = ) "Commodity", - DI(.create = ) NULL, - DI(.book_begin = ) NULL, - DI(.book_end = ) NULL, + DI(.create = ) nullptr, + DI(.book_begin = ) nullptr, + DI(.book_end = ) nullptr, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, DI(.foreach = ) qof_collection_foreach, @@ -2396,13 +2396,13 @@ static QofObject namespace_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_COMMODITY_NAMESPACE, DI(.type_label = ) "Namespace", - DI(.create = ) NULL, - DI(.book_begin = ) NULL, - DI(.book_end = ) NULL, - DI(.is_dirty = ) NULL, - DI(.mark_clean = ) NULL, - DI(.foreach = ) NULL, - DI(.printable = ) NULL, + DI(.create = ) nullptr, + DI(.book_begin = ) nullptr, + DI(.book_end = ) nullptr, + DI(.is_dirty = ) nullptr, + DI(.mark_clean = ) nullptr, + DI(.foreach = ) nullptr, + DI(.printable = ) nullptr, }; static void @@ -2431,7 +2431,7 @@ commodity_table_book_end (QofBook *book) gnc_commodity_table *ct; ct = gnc_commodity_table_get_table (book); - qof_book_set_data (book, GNC_COMMODITY_TABLE, NULL); + qof_book_set_data (book, GNC_COMMODITY_TABLE, nullptr); gnc_commodity_table_destroy (ct); } @@ -2440,14 +2440,14 @@ static QofObject commodity_table_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_COMMODITY_TABLE, DI(.type_label = ) "CommodityTable", - DI(.create = ) NULL, + DI(.create = ) nullptr, DI(.book_begin = ) commodity_table_book_begin, DI(.book_end = ) commodity_table_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, - DI(.foreach = ) NULL, - DI(.printable = ) NULL, - DI(.version_cmp = ) NULL, + DI(.foreach = ) nullptr, + DI(.printable = ) nullptr, + DI(.version_cmp = ) nullptr, }; gboolean @@ -2481,7 +2481,7 @@ gnc_monetary_list_add_monetary(MonetaryList *list, gnc_monetary add_mon) } /* See if we found an entry, and add one if not */ - if (tmp == NULL) + if (tmp == nullptr) { auto new_mon = static_cast(g_new0(gnc_monetary, 1)); *new_mon = add_mon; diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp index ab6ef981c2..8c8cf49baa 100644 --- a/libgnucash/engine/gnc-date.cpp +++ b/libgnucash/engine/gnc-date.cpp @@ -102,10 +102,10 @@ struct tm* gnc_localtime (const time64 *secs) { auto time = static_cast(calloc(1, sizeof(struct tm))); - if (gnc_localtime_r (secs, time) == NULL) + if (gnc_localtime_r (secs, time) == nullptr) { gnc_tm_free (time); - return NULL; + return nullptr; } return time; } @@ -120,7 +120,7 @@ gnc_localtime_r (const time64 *secs, struct tm* time) } catch(std::invalid_argument&) { - return NULL; + return nullptr; } } @@ -185,7 +185,7 @@ gnc_gmtime (const time64 *secs) } catch(std::invalid_argument&) { - return NULL; + return nullptr; } } @@ -262,7 +262,7 @@ gnc_time (time64 *tbuf) { GncDateTime gncdt; auto time = static_cast(gncdt); - if (tbuf != NULL) + if (tbuf != nullptr) *tbuf = time; return time; } @@ -297,7 +297,7 @@ gnc_date_dateformat_to_string(QofDateFormat format) case QOF_DATE_FORMAT_UNSET: return "unset"; default: - return NULL; + return nullptr; } } @@ -342,7 +342,7 @@ gnc_date_monthformat_to_string(GNCDateMonthFormat format) case GNCDATE_MONTH_NAME: return "name"; default: - return NULL; + return nullptr; } } @@ -702,9 +702,9 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year, dupe = g_strdup (buff); tmp = dupe; - first_field = NULL; - second_field = NULL; - third_field = NULL; + first_field = nullptr; + second_field = nullptr; + third_field = nullptr; /* Use strtok to find delimiters */ if (tmp) @@ -714,10 +714,10 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year, first_field = strtok (tmp, delims); if (first_field) { - second_field = strtok (NULL, delims); + second_field = strtok (nullptr, delims); if (second_field) { - third_field = strtok (NULL, delims); + third_field = strtok (nullptr, delims); } } } @@ -948,7 +948,7 @@ char dateSeparator (void) time64 secs; gchar *s; - secs = gnc_time (NULL); + secs = gnc_time (nullptr); gnc_localtime_r(&secs, &tm); auto normalized_fmt = normalize_format(qof_date_format_get_string(dateFormat)); @@ -969,9 +969,9 @@ gchar * qof_time_format_from_utf8(const gchar *utf8_format) { gchar *retval; - GError *error = NULL; + GError *error = nullptr; - retval = g_locale_from_utf8(utf8_format, -1, NULL, NULL, &error); + retval = g_locale_from_utf8(utf8_format, -1, nullptr, nullptr, &error); if (!retval) { @@ -986,9 +986,9 @@ gchar * qof_formatted_time_to_utf8(const gchar *locale_string) { gchar *retval; - GError *error = NULL; + GError *error = nullptr; - retval = g_locale_to_utf8(locale_string, -1, NULL, NULL, &error); + retval = g_locale_to_utf8(locale_string, -1, nullptr, nullptr, &error); if (!retval) { @@ -1011,7 +1011,7 @@ qof_format_time(const gchar *format, const struct tm *tm) locale_format = qof_time_format_from_utf8(format); if (!locale_format) - return NULL; + return nullptr; tmpbufsize = MAX(128, strlen(locale_format) * 2); while (TRUE) @@ -1035,7 +1035,7 @@ qof_format_time(const gchar *format, const struct tm *tm) "exceeded: giving up"); g_free(locale_format); - return NULL; + return nullptr; } } else @@ -1075,7 +1075,7 @@ qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm) { /* Ensure only whole characters are copied into the buffer. */ gchar *end = g_utf8_find_prev_char(convbuf, convbuf + max); - g_assert(end != NULL); + g_assert(end != nullptr); convlen = end - convbuf; /* Return 0 because the buffer isn't large enough. */ @@ -1138,7 +1138,7 @@ gnc_iso8601_to_time64_gmt(const char *cstr) char * gnc_time64_to_iso8601_buff (time64 time, char * buff) { - if (! buff) return NULL; + if (!buff) return nullptr; try { GncDateTime gncdt(time); diff --git a/libgnucash/engine/gnc-lot.cpp b/libgnucash/engine/gnc-lot.cpp index 22f1012535..84f47f1dfd 100644 --- a/libgnucash/engine/gnc-lot.cpp +++ b/libgnucash/engine/gnc-lot.cpp @@ -115,9 +115,9 @@ gnc_lot_init(GNCLot* lot) GNCLotPrivate* priv; priv = GET_PRIVATE(lot); - priv->account = NULL; - priv->splits = NULL; - priv->cached_invoice = NULL; + priv->account = nullptr; + priv->splits = nullptr; + priv->cached_invoice = nullptr; priv->is_closed = LOT_CLOSED_UNKNOWN; priv->marker = 0; } @@ -267,11 +267,11 @@ GNCLot * gnc_lot_new (QofBook *book) { GNCLot *lot; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); - lot = GNC_LOT(g_object_new (GNC_TYPE_LOT, NULL)); + lot = GNC_LOT(g_object_new (GNC_TYPE_LOT, nullptr)); qof_instance_init_data(QOF_INSTANCE(lot), GNC_ID_LOT, book); - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_CREATE, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_CREATE, nullptr); return lot; } @@ -283,20 +283,20 @@ gnc_lot_free(GNCLot* lot) if (!lot) return; ENTER ("(lot=%p)", lot); - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_DESTROY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_DESTROY, nullptr); priv = GET_PRIVATE(lot); for (node = priv->splits; node; node = node->next) { Split *s = GNC_SPLIT(node->data); - s->lot = NULL; + s->lot = nullptr; } g_list_free (priv->splits); if (priv->account && !qof_instance_get_destroying(priv->account)) xaccAccountRemoveLot (priv->account, lot); - priv->account = NULL; + priv->account = nullptr; priv->is_closed = TRUE; /* qof_instance_release (&lot->inst); */ g_object_unref (lot); @@ -350,7 +350,7 @@ GNCLot * gnc_lot_lookup (const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_LOT); return (GNCLot *) qof_collection_lookup_entity (col, guid); } @@ -377,14 +377,14 @@ Account * gnc_lot_get_account (const GNCLot *lot) { GNCLotPrivate* priv; - if (!lot) return NULL; + if (!lot) return nullptr; priv = GET_PRIVATE(lot); return priv->account; } GncInvoice * gnc_lot_get_cached_invoice (const GNCLot *lot) { - if (!lot) return NULL; + if (!lot) return nullptr; else { GNCLotPrivate *priv = GET_PRIVATE(lot); @@ -402,7 +402,7 @@ gnc_lot_set_cached_invoice(GNCLot* lot, GncInvoice *invoice) void gnc_lot_set_account(GNCLot* lot, Account* account) { - if (lot != NULL) + if (lot != nullptr) { GNCLotPrivate* priv; priv = GET_PRIVATE(lot); @@ -414,7 +414,7 @@ void gnc_lot_set_closed_unknown(GNCLot* lot) { GNCLotPrivate* priv; - if (lot != NULL) + if (lot != nullptr) { priv = GET_PRIVATE(lot); priv->is_closed = LOT_CLOSED_UNKNOWN; @@ -425,7 +425,7 @@ SplitList * gnc_lot_get_split_list (const GNCLot *lot) { GNCLotPrivate* priv; - if (!lot) return NULL; + if (!lot) return nullptr; priv = GET_PRIVATE(lot); return priv->splits; } @@ -444,11 +444,11 @@ gint gnc_lot_count_splits (const GNCLot *lot) const char * gnc_lot_get_title (const GNCLot *lot) { - if (!lot) return NULL; + if (!lot) return nullptr; GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "title"); - const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return rv; @@ -457,11 +457,11 @@ gnc_lot_get_title (const GNCLot *lot) const char * gnc_lot_get_notes (const GNCLot *lot) { - if (!lot) return NULL; + if (!lot) return nullptr; GValue v = G_VALUE_INIT; qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "notes"); - const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr; g_value_unset (&v); return rv; } @@ -552,7 +552,7 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split, *amount = amt; *value = val; - if (lot == NULL) return; + if (lot == nullptr) return; priv = GET_PRIVATE(lot); if (priv->splits) @@ -563,14 +563,14 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split, its transaction for the comparison. Gains splits are in separate transactions that may sort after non-gains transactions. */ target = xaccSplitGetGainsSourceSplit (split); - if (target == NULL) + if (target == nullptr) target = split; tb = xaccSplitGetParent (target); for (node = priv->splits; node; node = node->next) { Split *s = GNC_SPLIT(node->data); Split *source = xaccSplitGetGainsSourceSplit (s); - if (source == NULL) + if (source == nullptr) source = s; ta = xaccSplitGetParent (source); if ((ta == tb && source != target) || @@ -605,7 +605,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split) gnc_lot_begin_edit(lot); acc = xaccSplitGetAccount (split); qof_instance_set_dirty(QOF_INSTANCE(lot)); - if (NULL == priv->account) + if (nullptr == priv->account) { xaccAccountInsertLot (acc, lot); } @@ -638,7 +638,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split) priv->is_closed = LOT_CLOSED_UNKNOWN; gnc_lot_commit_edit(lot); - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr); LEAVE("added to lot"); } @@ -653,16 +653,16 @@ gnc_lot_remove_split (GNCLot *lot, Split *split) gnc_lot_begin_edit(lot); qof_instance_set_dirty(QOF_INSTANCE(lot)); priv->splits = g_list_remove (priv->splits, split); - xaccSplitSetLot(split, NULL); + xaccSplitSetLot(split, nullptr); priv->is_closed = LOT_CLOSED_UNKNOWN; /* force an is-closed computation */ if (!priv->splits && priv->account) { xaccAccountRemoveLot (priv->account, lot); - priv->account = NULL; + priv->account = nullptr; } gnc_lot_commit_edit(lot); - qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); + qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr); LEAVE("removed from lot"); } @@ -673,9 +673,9 @@ Split * gnc_lot_get_earliest_split (GNCLot *lot) { GNCLotPrivate* priv; - if (!lot) return NULL; + if (!lot) return nullptr; priv = GET_PRIVATE(lot); - if (! priv->splits) return NULL; + if (! priv->splits) return nullptr; priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly); return GNC_SPLIT(priv->splits->data); } @@ -687,9 +687,9 @@ gnc_lot_get_latest_split (GNCLot *lot) GNCLotPrivate* priv; SplitList *node; - if (!lot) return NULL; + if (!lot) return nullptr; priv = GET_PRIVATE(lot); - if (! priv->splits) return NULL; + if (! priv->splits) return nullptr; priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly); for (node = priv->splits; node->next; node = node->next) @@ -714,7 +714,7 @@ gnc_lot_book_end(QofBook* book) QofCollection *col; col = qof_book_get_collection(book, GNC_ID_LOT); - qof_collection_foreach(col, destroy_lot_on_book_close, NULL); + qof_collection_foreach(col, destroy_lot_on_book_close, nullptr); } #ifdef _MSC_VER @@ -730,12 +730,12 @@ static QofObject gncLotDesc = DI(.e_type = ) GNC_ID_LOT, DI(.type_label = ) "Lot", DI(.create = ) (void* (*)(QofBook*))gnc_lot_new, - DI(.book_begin = ) NULL, + DI(.book_begin = ) nullptr, DI(.book_end = ) gnc_lot_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, DI(.foreach = ) qof_collection_foreach, - DI(.printable = ) NULL, + DI(.printable = ) nullptr, DI(.version_cmp = ) (int (*)(gpointer, gpointer))qof_instance_version_cmp, }; @@ -756,24 +756,24 @@ gboolean gnc_lot_register (void) }, { QOF_PARAM_GUID, QOF_TYPE_GUID, - (QofAccessFunc) qof_entity_get_guid, NULL + (QofAccessFunc) qof_entity_get_guid, nullptr }, { QOF_PARAM_BOOK, QOF_ID_BOOK, - (QofAccessFunc) gnc_lot_get_book, NULL + (QofAccessFunc) gnc_lot_get_book, nullptr }, { LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, - (QofAccessFunc) gnc_lot_is_closed, NULL + (QofAccessFunc) gnc_lot_is_closed, nullptr }, { LOT_BALANCE, QOF_TYPE_NUMERIC, - (QofAccessFunc) gnc_lot_get_balance, NULL + (QofAccessFunc) gnc_lot_get_balance, nullptr }, - { NULL }, + { nullptr }, }; - qof_class_register (GNC_ID_LOT, NULL, params); + qof_class_register (GNC_ID_LOT, nullptr, params); return qof_object_register(&gncLotDesc); } @@ -787,11 +787,11 @@ GNCLot * gnc_lot_make_default (Account *acc) /* Provide a reasonable title for the new lot */ xaccAccountBeginEdit (acc); - qof_instance_get (QOF_INSTANCE (acc), "lot-next-id", &id, NULL); + qof_instance_get (QOF_INSTANCE (acc), "lot-next-id", &id, nullptr); buff = g_strdup_printf ("%s %" G_GINT64_FORMAT, _("Lot"), id); gnc_lot_set_title (lot, buff); id ++; - qof_instance_set (QOF_INSTANCE (acc), "lot-next-id", id, NULL); + qof_instance_set (QOF_INSTANCE (acc), "lot-next-id", id, nullptr); xaccAccountCommitEdit (acc); g_free (buff); return lot; diff --git a/libgnucash/engine/gnc-pricedb.cpp b/libgnucash/engine/gnc-pricedb.cpp index 7d335ebe10..43306fd16a 100644 --- a/libgnucash/engine/gnc-pricedb.cpp +++ b/libgnucash/engine/gnc-pricedb.cpp @@ -89,7 +89,7 @@ gnc_price_init(GNCPrice* price) { price->refcount = 1; price->value = gnc_numeric_zero(); - price->type = NULL; + price->type = nullptr; price->source = PRICE_SOURCE_INVALID; } @@ -250,7 +250,7 @@ gnc_price_class_init(GNCPriceClass *klass) " the price was created. This property works on the" " string values in source_names for SQL database" " compatibility.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -262,7 +262,7 @@ gnc_price_class_init(GNCPriceClass *klass) "type of a price quote. Types possible now " "are 'bid', 'ask', 'last', 'nav', 'transaction', " "and 'unknown'.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -294,13 +294,13 @@ gnc_price_create (QofBook *book) { GNCPrice *p; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); ENTER(" "); - p = static_cast(g_object_new(GNC_TYPE_PRICE, NULL)); + p = static_cast(g_object_new(GNC_TYPE_PRICE, nullptr)); qof_instance_init_data (&p->inst, GNC_ID_PRICE, book); - qof_event_gen (&p->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&p->inst, QOF_EVENT_CREATE, nullptr); LEAVE ("price created %p", p); return p; } @@ -309,7 +309,7 @@ static void gnc_price_destroy (GNCPrice *p) { ENTER("destroy price %p", p); - qof_event_gen (&p->inst, QOF_EVENT_DESTROY, NULL); + qof_event_gen (&p->inst, QOF_EVENT_DESTROY, nullptr); if (p->type) CACHE_REMOVE(p->type); @@ -338,7 +338,7 @@ gnc_price_unref(GNCPrice *p) if (p->refcount <= 0) { - if (NULL != p->db) + if (nullptr != p->db) { PERR("last unref while price in database"); } @@ -354,21 +354,21 @@ gnc_price_clone (GNCPrice* p, QofBook *book) /* the clone doesn't belong to a PriceDB */ GNCPrice *new_p; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); ENTER ("pr=%p", p); if (!p) { - LEAVE ("return NULL"); - return NULL; + LEAVE ("return nullptr"); + return nullptr; } new_p = gnc_price_create(book); if (!new_p) { - LEAVE ("return NULL"); - return NULL; + LEAVE ("return nullptr"); + return nullptr; } qof_instance_copy_version(new_p, p); @@ -448,7 +448,7 @@ static void gnc_price_set_dirty (GNCPrice *p) { qof_instance_set_dirty(&p->inst); - qof_event_gen(&p->inst, QOF_EVENT_MODIFY, NULL); + qof_event_gen(&p->inst, QOF_EVENT_MODIFY, nullptr); } void @@ -572,7 +572,7 @@ gnc_price_lookup (const GncGUID *guid, QofBook *book) { QofCollection *col; - if (!guid || !book) return NULL; + if (!guid || !book) return nullptr; col = qof_book_get_collection (book, GNC_ID_PRICE); return (GNCPrice *) qof_collection_lookup_entity (col, guid); } @@ -580,7 +580,7 @@ gnc_price_lookup (const GncGUID *guid, QofBook *book) gnc_commodity * gnc_price_get_commodity(const GNCPrice *p) { - if (!p) return NULL; + if (!p) return nullptr; return p->commodity; } @@ -600,14 +600,14 @@ gnc_price_get_source(const GNCPrice *p) const char* gnc_price_get_source_string(const GNCPrice *p) { - if (!p) return NULL; + if (!p) return nullptr; return source_names[p->source]; } const char * gnc_price_get_typestr(const GNCPrice *p) { - if (!p) return NULL; + if (!p) return nullptr; return p->type; } @@ -616,7 +616,7 @@ gnc_price_get_value(const GNCPrice *p) { if (!p) { - PERR("price NULL.\n"); + PERR("price nullptr.\n"); return gnc_numeric_zero(); } return p->value; @@ -625,7 +625,7 @@ gnc_price_get_value(const GNCPrice *p) gnc_commodity * gnc_price_get_currency(const GNCPrice *p) { - if (!p) return NULL; + if (!p) return nullptr; return p->currency; } @@ -802,7 +802,7 @@ gnc_pricedb_create(QofBook * book) GNCPriceDB * result; QofCollection *col; - g_return_val_if_fail (book, NULL); + g_return_val_if_fail (book, nullptr); /* There can only be one pricedb per book. So if one exits already, * then use that. Warn user, they shouldn't be creating two ... @@ -815,7 +815,7 @@ gnc_pricedb_create(QofBook * book) return result; } - result = static_cast(g_object_new(GNC_TYPE_PRICEDB, NULL)); + result = static_cast(g_object_new(GNC_TYPE_PRICEDB, nullptr)); qof_instance_init_data (&result->inst, GNC_ID_PRICEDB, book); qof_collection_mark_clean(col); @@ -824,8 +824,8 @@ gnc_pricedb_create(QofBook * book) provide one here. */ qof_collection_set_data (col, result); - result->commodity_hash = g_hash_table_new(NULL, NULL); - g_return_val_if_fail (result->commodity_hash, NULL); + result->commodity_hash = g_hash_table_new(nullptr, nullptr); + g_return_val_if_fail (result->commodity_hash, nullptr); return result; } @@ -842,7 +842,7 @@ destroy_pricedb_currency_hash_data(gpointer key, { p = static_cast(node->data); - p->db = NULL; + p->db = nullptr; } gnc_price_list_destroy(price_list); @@ -857,7 +857,7 @@ destroy_pricedb_commodity_hash_data(gpointer key, if (!currency_hash) return; g_hash_table_foreach (currency_hash, destroy_pricedb_currency_hash_data, - NULL); + nullptr); g_hash_table_destroy(currency_hash); } @@ -869,10 +869,10 @@ gnc_pricedb_destroy(GNCPriceDB *db) { g_hash_table_foreach (db->commodity_hash, destroy_pricedb_commodity_hash_data, - NULL); + nullptr); } g_hash_table_destroy (db->commodity_hash); - db->commodity_hash = NULL; + db->commodity_hash = nullptr; /* qof_instance_release (&db->inst); */ g_object_unref(db); } @@ -901,7 +901,7 @@ gnc_pricedb_set_bulk_update(GNCPriceDB *db, gboolean bulk_update) GNCPriceDB * gnc_collection_get_pricedb(QofCollection *col) { - if (!col) return NULL; + if (!col) return nullptr; return static_cast(qof_collection_get_data (col)); } @@ -910,7 +910,7 @@ gnc_pricedb_get_db(QofBook *book) { QofCollection *col; - if (!book) return NULL; + if (!book) return nullptr; col = qof_book_get_collection (book, GNC_ID_PRICEDB); return gnc_collection_get_pricedb (col); } @@ -989,7 +989,7 @@ gnc_pricedb_equal (GNCPriceDB *db1, GNCPriceDB *db2) if (!db1 || !db2) { - PWARN ("one is NULL"); + PWARN ("one is nullptr"); return FALSE; } @@ -1056,7 +1056,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) { GNCPrice *old_price = gnc_pricedb_lookup_day_t64(db, p->commodity, p->currency, p->tmspec); - if (old_price != NULL) + if (old_price != nullptr) { if (p->source > old_price->source) { @@ -1071,7 +1071,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) currency_hash = static_cast(g_hash_table_lookup(db->commodity_hash, commodity)); if (!currency_hash) { - currency_hash = g_hash_table_new(NULL, NULL); + currency_hash = g_hash_table_new(nullptr, nullptr); g_hash_table_insert(db->commodity_hash, commodity, currency_hash); } @@ -1091,7 +1091,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) g_hash_table_insert(currency_hash, currency, price_list); p->db = db; - qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL); + qof_event_gen (&p->inst, QOF_EVENT_ADD, nullptr); LEAVE ("db=%p, pr=%p dirty=%d dextroying=%d commodity=%s/%s currency_hash=%p", db, p, qof_instance_get_dirty_flag(p), @@ -1174,7 +1174,7 @@ remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup) return FALSE; } - qof_event_gen (&p->inst, QOF_EVENT_REMOVE, NULL); + qof_event_gen (&p->inst, QOF_EVENT_REMOVE, nullptr); price_list = static_cast(g_hash_table_lookup(currency_hash, currency)); gnc_price_ref(p); if (!gnc_price_list_remove(&price_list, p)) @@ -1239,7 +1239,7 @@ gnc_pricedb_remove_price(GNCPriceDB *db, GNCPrice *p) gnc_price_begin_edit (p); qof_instance_set_destroying(p, TRUE); gnc_price_commit_edit (p); - p->db = NULL; + p->db = nullptr; gnc_price_unref(p); LEAVE ("db=%p, pr=%p", db, p); return rc; @@ -1395,7 +1395,7 @@ clone_price (GNCPrice **price, GNCPrice *source_price) QofBook *book; if (!source_price) return; - if (price == NULL) return; + if (price == nullptr) return; book = qof_instance_get_book (QOF_INSTANCE(source_price)); @@ -1440,7 +1440,7 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date, GSList *item; gboolean save_first_price = FALSE; gint saved_test_value = 0, next_test_value = 0; - GNCPrice *cloned_price = NULL; + GNCPrice *cloned_price = nullptr; GDateMonth fiscal_month_start; GDate *tmp_date = g_date_new_dmy (g_date_get_day (fiscal_end_date), g_date_get_month (fiscal_end_date), @@ -1556,7 +1556,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, data.db = db; data.cutoff = cutoff; - data.list = NULL; + data.list = nullptr; data.delete_fq = FALSE; data.delete_user = FALSE; data.delete_app = FALSE; @@ -1580,7 +1580,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, g_hash_table_foreach (currencies_hash, pricedb_remove_foreach_pricelist, &data); } - if (data.list == NULL) + if (data.list == nullptr) { LEAVE("Empty price list"); return FALSE; @@ -1590,7 +1590,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, g_slist_length (data.list), datebuff); // Check for a valid fiscal end of year date - if (fiscal_end_date == NULL) + if (fiscal_end_date == nullptr) { GDateYear year_now = g_date_get_year (gnc_g_date_new_today ()); fiscal_end_date = g_date_new (); @@ -1632,14 +1632,14 @@ hash_values_helper(gpointer key, gpointer value, gpointer data) static PriceList * price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency) { - GList *price_list = NULL, *result = NULL ; + GList *price_list = nullptr, *result = nullptr ; if (currency) { price_list = static_cast(g_hash_table_lookup(hash, currency)); if (!price_list) { LEAVE (" no price list"); - return NULL; + return nullptr; } result = g_list_copy (price_list); } @@ -1653,18 +1653,18 @@ price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency) static PriceList * pricedb_price_list_merge (PriceList *a, PriceList *b) { - PriceList *merged_list = NULL; + PriceList *merged_list = nullptr; GList *next_a = a; GList *next_b = b; while (next_a || next_b) { - if (next_a == NULL) + if (next_a == nullptr) { merged_list = g_list_prepend (merged_list, next_b->data); next_b = next_b->next; } - else if (next_b == NULL) + else if (next_b == nullptr) { merged_list = g_list_prepend (merged_list, next_a->data); next_a = next_a->next; @@ -1688,17 +1688,17 @@ static PriceList* pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity, const gnc_commodity *currency, gboolean bidi) { - GHashTable *forward_hash = NULL, *reverse_hash = NULL; - PriceList *forward_list = NULL, *reverse_list = NULL; - g_return_val_if_fail (db != NULL, NULL); - g_return_val_if_fail (commodity != NULL, NULL); + GHashTable *forward_hash = nullptr, *reverse_hash = nullptr; + PriceList *forward_list = nullptr, *reverse_list = nullptr; + g_return_val_if_fail (db != nullptr, nullptr); + g_return_val_if_fail (commodity != nullptr, nullptr); forward_hash = static_cast(g_hash_table_lookup(db->commodity_hash, commodity)); if (currency && bidi) reverse_hash = static_cast(g_hash_table_lookup(db->commodity_hash, currency)); if (!forward_hash && !reverse_hash) { LEAVE (" no currency hash"); - return NULL; + return nullptr; } if (forward_hash) forward_list = price_list_from_hashtable (forward_hash, currency); @@ -1737,11 +1737,11 @@ GNCPrice *gnc_pricedb_lookup_latest(GNCPriceDB *db, GList *price_list; GNCPrice *result; - if (!db || !commodity || !currency) return NULL; + if (!db || !commodity || !currency) return nullptr; ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency); price_list = pricedb_get_prices_internal(db, commodity, currency, TRUE); - if (!price_list) return NULL; + if (!price_list) return nullptr; /* This works magically because prices are inserted in date-sorted * order, and the latest date always comes first. So return the * first in the list. */ @@ -1810,7 +1810,7 @@ price_list_scan_any_currency(GList *price_list, gpointer data) /* No point in looking further, they will all be older */ break; } - else if (node->next == NULL) + else if (node->next == nullptr) { /* The last price is later than given time, add it */ gnc_price_ref(price); @@ -1827,8 +1827,8 @@ price_list_scan_any_currency(GList *price_list, gpointer data) static PriceList* latest_before (PriceList *prices, const gnc_commodity* target, time64 t) { - GList *node, *found_coms = NULL, *retval = NULL; - for (node = prices; node != NULL; node = g_list_next(node)) + GList *node, *found_coms = nullptr, *retval = nullptr; + for (node = prices; node != nullptr; node = g_list_next(node)) { GNCPrice *price = (GNCPrice*)node->data; gnc_commodity *com = gnc_price_get_commodity(price); @@ -1852,7 +1852,7 @@ static GNCPrice** find_comtime(GPtrArray* array, gnc_commodity *com) { unsigned int index = 0; - GNCPrice** retval = NULL; + GNCPrice** retval = nullptr; for (index = 0; index < array->len; ++index) { auto price_p = static_cast(g_ptr_array_index(array, index)); @@ -1873,7 +1873,7 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price, gnc_commodity *other = com == target ? cur : com; GNCPrice **com_price = find_comtime(price_array, other); time64 com_t; - if (com_price == NULL) + if (com_price == nullptr) { com_price = (GNCPrice**)g_slice_new(gpointer); *com_price = price; @@ -1920,7 +1920,7 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price, static PriceList * nearest_to (PriceList *prices, const gnc_commodity* target, time64 t) { - GList *node, *retval = NULL; + GList *node, *retval = nullptr; const guint prealloc_size = 5; /*More than 5 "other" is unlikely as long as * target isn't the book's default * currency. */ @@ -1928,7 +1928,7 @@ nearest_to (PriceList *prices, const gnc_commodity* target, time64 t) GPtrArray *price_array = g_ptr_array_sized_new(prealloc_size); guint index; - for (node = prices; node != NULL; node = g_list_next(node)) + for (node = prices; node != nullptr; node = g_list_next(node)) { GNCPrice *price = (GNCPrice*)node->data; retval = add_nearest_price(retval, price_array, price, target, t); @@ -1958,7 +1958,7 @@ gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db, const gnc_commodity *commodity) { return gnc_pricedb_lookup_nearest_before_any_currency_t64(db, commodity, - gnc_time(NULL)); + gnc_time(nullptr)); } PriceList * @@ -1966,11 +1966,11 @@ gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db, const gnc_commodity *commodity, time64 t) { - GList *prices = NULL, *result; + GList *prices = nullptr, *result; UsesCommodity helper = {&prices, commodity, t}; - result = NULL; + result = nullptr; - if (!db || !commodity) return NULL; + if (!db || !commodity) return nullptr; ENTER ("db=%p commodity=%p", db, commodity); pricedb_pricelist_traversal(db, price_list_scan_any_currency, &helper); @@ -1986,11 +1986,11 @@ gnc_pricedb_lookup_nearest_before_any_currency_t64(GNCPriceDB *db, const gnc_commodity *commodity, time64 t) { - GList *prices = NULL, *result; + GList *prices = nullptr, *result; UsesCommodity helper = {&prices, commodity, t}; - result = NULL; + result = nullptr; - if (!db || !commodity) return NULL; + if (!db || !commodity) return nullptr; ENTER ("db=%p commodity=%p", db, commodity); pricedb_pricelist_traversal(db, price_list_scan_any_currency, @@ -2050,10 +2050,10 @@ gnc_pricedb_get_prices(GNCPriceDB *db, const gnc_commodity *commodity, const gnc_commodity *currency) { - if (!db || !commodity) return NULL; + if (!db || !commodity) return nullptr; ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency); auto result = pricedb_get_prices_internal (db, commodity, currency, FALSE); - if (!result) return NULL; + if (!result) return nullptr; g_list_foreach (result, (GFunc)gnc_price_ref, nullptr); LEAVE (" "); return result; @@ -2096,7 +2096,7 @@ list_combine (gpointer element, gpointer data) { GList *list = *(GList**)data; auto lst = static_cast(element); - if (list == NULL) + if (list == nullptr) *(GList**)data = g_list_copy (lst); else { @@ -2122,14 +2122,14 @@ gnc_pricedb_nth_price (GNCPriceDB *db, const gnc_commodity *c, const int n) { - static const gnc_commodity *last_c = NULL; - static GList *prices = NULL; + static const gnc_commodity *last_c = nullptr; + static GList *prices = nullptr; - GNCPrice *result = NULL; + GNCPrice *result = nullptr; GHashTable *currency_hash; - g_return_val_if_fail (GNC_IS_COMMODITY (c), NULL); + g_return_val_if_fail (GNC_IS_COMMODITY (c), nullptr); - if (!db || !c || n < 0) return NULL; + if (!db || !c || n < 0) return nullptr; ENTER ("db=%p commodity=%s index=%d", db, gnc_commodity_get_mnemonic(c), n); if (last_c && prices && last_c == c && db->reset_nth_price_cache == FALSE) @@ -2144,7 +2144,7 @@ gnc_pricedb_nth_price (GNCPriceDB *db, if (prices) { g_list_free (prices); - prices = NULL; + prices = nullptr; } db->reset_nth_price_cache = FALSE; @@ -2191,7 +2191,7 @@ gnc_pricedb_lookup_at_time64(GNCPriceDB *db, time64 t) { GNCPrice *rv = nullptr; - if (!db || !c || !currency) return NULL; + if (!db || !c || !currency) return nullptr; ENTER ("db=%p commodity=%p currency=%p", db, c, currency); auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE); auto p = g_list_find_custom (price_list, &t, (GCompareFunc) price_same_time); @@ -2213,15 +2213,15 @@ lookup_nearest_in_time(GNCPriceDB *db, gboolean sameday) { GList *price_list; - GNCPrice *current_price = NULL; - GNCPrice *next_price = NULL; - GNCPrice *result = NULL; + GNCPrice *current_price = nullptr; + GNCPrice *next_price = nullptr; + GNCPrice *result = nullptr; - if (!db || !c || !currency) return NULL; - if (t == INT64_MAX) return NULL; + if (!db || !c || !currency) return nullptr; + if (t == INT64_MAX) return nullptr; ENTER ("db=%p commodity=%p currency=%p", db, c, currency); price_list = pricedb_get_prices_internal (db, c, currency, TRUE); - if (!price_list) return NULL; + if (!price_list) return nullptr; /* default answer */ current_price = static_cast(price_list->data); @@ -2254,7 +2254,7 @@ lookup_nearest_in_time(GNCPriceDB *db, price_day = time64CanonicalDayTime(gnc_price_get_time64(current_price)); t_day = time64CanonicalDayTime(t); if (price_day != t_day) - result = NULL; + result = nullptr; } } else @@ -2336,11 +2336,11 @@ gnc_pricedb_lookup_nearest_before_t64 (GNCPriceDB *db, const gnc_commodity *currency, time64 t) { - GNCPrice *current_price = NULL; - if (!db || !c || !currency) return NULL; + GNCPrice *current_price = nullptr; + if (!db || !c || !currency) return nullptr; ENTER ("db=%p commodity=%p currency=%p", db, c, currency); auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE); - if (!price_list) return NULL; + if (!price_list) return nullptr; auto p = g_list_find_custom (price_list, &t, (GCompareFunc)price_time64_less_or_equal); if (p) { @@ -2363,14 +2363,14 @@ static PriceTuple extract_common_prices (PriceList *from_prices, PriceList *to_prices, const gnc_commodity *from, const gnc_commodity *to) { - PriceTuple retval = {NULL, NULL}; - GList *from_node = NULL, *to_node = NULL; - GNCPrice *from_price = NULL, *to_price = NULL; + PriceTuple retval = {nullptr, nullptr}; + GList *from_node = nullptr, *to_node = nullptr; + GNCPrice *from_price = nullptr, *to_price = nullptr; - for (from_node = from_prices; from_node != NULL; + for (from_node = from_prices; from_node != nullptr; from_node = g_list_next(from_node)) { - for (to_node = to_prices; to_node != NULL; + for (to_node = to_prices; to_node != nullptr; to_node = g_list_next(to_node)) { gnc_commodity *to_com, *to_cur; @@ -2386,13 +2386,13 @@ extract_common_prices (PriceList *from_prices, PriceList *to_prices, ((to_cur == from_com || to_cur == from_cur) && (to_cur != from && to_cur != to))) break; - to_price = NULL; - from_price = NULL; + to_price = nullptr; + from_price = nullptr; } - if (to_price != NULL && from_price != NULL) + if (to_price != nullptr && from_price != nullptr) break; } - if (from_price == NULL || to_price == NULL) + if (from_price == nullptr || to_price == nullptr) return retval; gnc_price_ref(from_price); gnc_price_ref(to_price); @@ -2437,7 +2437,7 @@ static gnc_numeric indirect_price_conversion (GNCPriceDB *db, const gnc_commodity *from, const gnc_commodity *to, time64 t, gboolean before_date) { - GList *from_prices = NULL, *to_prices = NULL; + GList *from_prices = nullptr, *to_prices = nullptr; PriceTuple tuple; gnc_numeric zero = gnc_numeric_zero(); if (!from || !to) @@ -2653,7 +2653,7 @@ unstable_price_traversal(GNCPriceDB *db, foreach_data.ok = TRUE; foreach_data.func = f; foreach_data.user_data = user_data; - if (db->commodity_hash == NULL) + if (db->commodity_hash == nullptr) { return FALSE; } @@ -2701,7 +2701,7 @@ pricedb_pricelist_traversal(GNCPriceDB *db, foreach_data.ok = TRUE; foreach_data.func = f; foreach_data.user_data = user_data; - if (db->commodity_hash == NULL) + if (db->commodity_hash == nullptr) { return FALSE; } @@ -2817,7 +2817,7 @@ gnc_pricedb_substitute_commodity(GNCPriceDB *db, gnc_commodity *new_c) { GNCPriceFixupData data; - GList *prices = NULL; + GList *prices = nullptr; if (!db || !old_c || !new_c) return; @@ -2840,7 +2840,7 @@ gnc_price_print(GNCPrice *p, FILE *f, int indent) { gnc_commodity *commodity; gnc_commodity *currency; - gchar *istr = NULL; /* indent string */ + gchar *istr = nullptr; /* indent string */ const char *str; if (!p) return; @@ -2896,12 +2896,12 @@ gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f) { if (!db) { - PERR("NULL PriceDB\n"); + PERR("nullptr PriceDB\n"); return; } if (!f) { - PERR("NULL FILE*\n"); + PERR("nullptr FILE*\n"); return; } @@ -2928,7 +2928,7 @@ pricedb_book_end (QofBook *book) return; col = qof_book_get_collection(book, GNC_ID_PRICEDB); auto db = static_cast(qof_collection_get_data(col)); - qof_collection_set_data(col, NULL); + qof_collection_set_data(col, nullptr); gnc_pricedb_destroy(db); } @@ -3013,7 +3013,7 @@ price_printable(gpointer obj) /* Reference it so the compiler doesn't optimize it out. bit don't actually call it. */ if (obj == buff) - price_list_dump(NULL, ""); + price_list_dump(nullptr, ""); #endif val = gnc_numeric_to_string (pr->value); @@ -3039,7 +3039,7 @@ price_list_dump(GList *price_list, const char *tag) GNCPrice *price; GList *node; printf("Price list %s\n", tag); - for (node = price_list; node != NULL; node = node->next) + for (node = price_list; node != nullptr; node = node->next) { printf("%s\n", price_printable(node->data)); } @@ -3059,13 +3059,13 @@ static QofObject price_object_def = DI(.e_type = ) GNC_ID_PRICE, DI(.type_label = ) "Price", DI(.create = ) price_create, - DI(.book_begin = ) NULL, - DI(.book_end = ) NULL, + DI(.book_begin = ) nullptr, + DI(.book_end = ) nullptr, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, DI(.foreach = ) price_foreach, DI(.printable = ) price_printable, - DI(.version_cmp = ) NULL, + DI(.version_cmp = ) nullptr, }; static QofObject pricedb_object_def = @@ -3073,14 +3073,14 @@ static QofObject pricedb_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_PRICEDB, DI(.type_label = ) "PriceDB", - DI(.create = ) NULL, + DI(.create = ) nullptr, DI(.book_begin = ) pricedb_book_begin, DI(.book_end = ) pricedb_book_end, DI(.is_dirty = ) qof_collection_is_dirty, DI(.mark_clean = ) qof_collection_mark_clean, - DI(.foreach = ) NULL, - DI(.printable = ) NULL, - DI(.version_cmp = ) NULL, + DI(.foreach = ) nullptr, + DI(.printable = ) nullptr, + DI(.version_cmp = ) nullptr, }; gboolean @@ -3094,10 +3094,10 @@ gnc_pricedb_register (void) { PRICE_SOURCE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_source, (QofSetterFunc)gnc_price_set_source }, { PRICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_typestr, (QofSetterFunc)gnc_price_set_typestr }, { PRICE_VALUE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_price_get_value, (QofSetterFunc)gnc_price_set_value }, - { NULL }, + { nullptr }, }; - qof_class_register (GNC_ID_PRICE, NULL, params); + qof_class_register (GNC_ID_PRICE, nullptr, params); if (!qof_object_register (&price_object_def)) return FALSE; diff --git a/libgnucash/engine/guid.cpp b/libgnucash/engine/guid.cpp index 48894640e2..9526a06778 100644 --- a/libgnucash/engine/guid.cpp +++ b/libgnucash/engine/guid.cpp @@ -74,8 +74,8 @@ gnc_value_get_guid (const GValue *value) if (!value) return nullptr; GncGUID *val; - g_return_val_if_fail (value && G_IS_VALUE (value), NULL); - g_return_val_if_fail (GNC_VALUE_HOLDS_GUID (value), NULL); + g_return_val_if_fail (value && G_IS_VALUE (value), nullptr); + g_return_val_if_fail (GNC_VALUE_HOLDS_GUID (value), nullptr); val = (GncGUID*) g_value_get_boxed (value); @@ -172,7 +172,7 @@ guid_to_string (const GncGUID * guid) gchar * guid_to_string_buff (const GncGUID * guid, gchar *str) { - if (!str || !guid) return NULL; + if (!str || !guid) return nullptr; gnc::GUID temp {*guid}; auto val = temp.to_string (); @@ -229,7 +229,7 @@ guid_hash_to_guint (gconstpointer ptr) { if (!ptr) { - PERR ("received NULL guid pointer."); + PERR ("received nullptr guid pointer."); return 0; } GncGUID const & guid = * reinterpret_cast (ptr); diff --git a/libgnucash/engine/qofbook.cpp b/libgnucash/engine/qofbook.cpp index 7575f7a72f..f4f277475c 100644 --- a/libgnucash/engine/qofbook.cpp +++ b/libgnucash/engine/qofbook.cpp @@ -114,7 +114,7 @@ qof_book_init (QofBook *book) qof_instance_init_data (&book->inst, QOF_ID_BOOK, book); book->data_tables = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify)qof_string_cache_remove, NULL); + (GDestroyNotify)qof_string_cache_remove, nullptr); book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal); book->book_open = 'y'; @@ -239,10 +239,10 @@ qof_book_class_init (QofBookClass *klass) PROP_OPT_TRADING_ACCOUNTS, g_param_spec_string("trading-accts", "Use Trading Accounts", - "Scheme true ('t') or NULL. If 't', then the book " + "Scheme true ('t') or nullptr. If 't', then the book " "uses trading accounts for managing multiple-currency " "transactions.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -250,9 +250,9 @@ qof_book_class_init (QofBookClass *klass) PROP_OPT_NUM_FIELD_SOURCE, g_param_spec_string(PARAM_NAME_NUM_FIELD_SOURCE, "Use Split-Action in the Num Field", - "Scheme true ('t') or NULL. If 't', then the book " + "Scheme true ('t') or nullptr. If 't', then the book " "will put the split action value in the Num field.", - NULL, + nullptr, G_PARAM_READWRITE)); g_object_class_install_property @@ -292,10 +292,10 @@ qof_book_new (void) QofBook *book; ENTER (" "); - book = static_cast(g_object_new(QOF_TYPE_BOOK, NULL)); + book = static_cast(g_object_new(QOF_TYPE_BOOK, nullptr)); qof_object_book_begin (book); - qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL); + qof_event_gen (&book->inst, QOF_EVENT_CREATE, nullptr); LEAVE ("book=%p", book); return book; } @@ -336,7 +336,7 @@ qof_book_destroy (QofBook *book) ENTER ("book=%p", book); book->shutting_down = TRUE; - qof_event_force (&book->inst, QOF_EVENT_DESTROY, NULL); + qof_event_force (&book->inst, QOF_EVENT_DESTROY, nullptr); /* Call the list of finalizers, let them do their thing. * Do this before tearing into the rest of the book. @@ -351,9 +351,9 @@ qof_book_destroy (QofBook *book) qof_object_book_end (book); g_hash_table_destroy (book->data_table_finalizers); - book->data_table_finalizers = NULL; + book->data_table_finalizers = nullptr; g_hash_table_destroy (book->data_tables); - book->data_tables = NULL; + book->data_tables = nullptr; /* qof_instance_release (&book->inst); */ @@ -401,7 +401,7 @@ void qof_book_mark_session_dirty (QofBook *book) { /* Set the session dirty upfront, because the callback will check. */ book->session_dirty = TRUE; - book->dirty_time = gnc_time (NULL); + book->dirty_time = gnc_time (nullptr); if (book->dirty_cb) book->dirty_cb(book, TRUE, book->dirty_data); } @@ -413,7 +413,7 @@ qof_book_print_dirty (const QofBook *book) if (qof_book_session_not_saved(book)) PINFO("book is dirty."); qof_book_foreach_collection - (book, (QofCollectionForeachCB)qof_collection_print_dirty, NULL); + (book, (QofCollectionForeachCB)qof_collection_print_dirty, nullptr); } time64 @@ -439,7 +439,7 @@ qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data) QofBackend * qof_book_get_backend (const QofBook *book) { - if (!book) return NULL; + if (!book) return nullptr; return book->backend; } @@ -488,7 +488,7 @@ qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, QofBookFin gpointer qof_book_get_data (const QofBook *book, const char *key) { - if (!book || !key) return NULL; + if (!book || !key) return nullptr; return g_hash_table_lookup (book->data_tables, (gpointer)key); } @@ -496,14 +496,14 @@ qof_book_get_data (const QofBook *book, const char *key) gboolean qof_book_is_readonly(const QofBook *book) { - g_return_val_if_fail( book != NULL, TRUE ); + g_return_val_if_fail( book != nullptr, TRUE ); return book->read_only; } void qof_book_mark_readonly(QofBook *book) { - g_return_if_fail( book != NULL ); + g_return_if_fail( book != nullptr ); book->read_only = TRUE; } @@ -522,7 +522,7 @@ qof_book_get_collection (const QofBook *book, QofIdType entity_type) { QofCollection *col; - if (!book || !entity_type) return NULL; + if (!book || !entity_type) return nullptr; col = static_cast(g_hash_table_lookup (book->hash_of_collections, entity_type)); if (!col) @@ -633,13 +633,13 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name) if (!book) { PWARN ("No book!!!"); - return NULL; + return nullptr; } if (!counter_name || *counter_name == '\0') { PWARN ("Invalid counter name."); - return NULL; + return nullptr; } /* Get the current counter value from the KVP in the book. */ @@ -647,7 +647,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name) /* Check if an error occurred */ if (counter < 0) - return NULL; + return nullptr; /* Increment the counter */ counter++; @@ -658,7 +658,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name) if (!kvp) { PWARN ("Book has no KVP_Frame"); - return NULL; + return nullptr; } /* Save off the new counter */ @@ -673,7 +673,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name) if (!format) { PWARN("Cannot get format for counter"); - return NULL; + return nullptr; } /* Generate a string version of the counter */ @@ -686,21 +686,21 @@ char * qof_book_get_counter_format(const QofBook *book, const char *counter_name) { KvpFrame *kvp; - const char *user_format = NULL; - gchar *norm_format = NULL; + const char *user_format = nullptr; + gchar *norm_format = nullptr; KvpValue *value; - gchar *error = NULL; + gchar *error = nullptr; if (!book) { PWARN ("No book!!!"); - return NULL; + return nullptr; } if (!counter_name || *counter_name == '\0') { PWARN ("Invalid counter name."); - return NULL; + return nullptr; } /* Get the KVP from the current book */ @@ -709,7 +709,7 @@ qof_book_get_counter_format(const QofBook *book, const char *counter_name) if (!kvp) { PWARN ("Book has no KVP_Frame"); - return NULL; + return nullptr; } /* Get the format string */ @@ -722,7 +722,7 @@ qof_book_get_counter_format(const QofBook *book, const char *counter_name) { PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", user_format, counter_name, error); /* Invalid format string */ - user_format = NULL; + user_format = nullptr; g_free(error); } } @@ -746,10 +746,10 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg) "I64i", PRIi64, "li", - NULL, + nullptr, }; int i = 0; - gchar *normalized_spec = NULL; + gchar *normalized_spec = nullptr; while (valid_formats[i]) { @@ -757,7 +757,7 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg) if (err_msg && *err_msg) { g_free (*err_msg); - *err_msg = NULL; + *err_msg = nullptr; } normalized_spec = qof_book_normalize_counter_format_internal(p, valid_formats[i], err_msg); @@ -766,15 +766,15 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg) i++; } - return NULL; + return nullptr; } gchar * qof_book_normalize_counter_format_internal(const gchar *p, const gchar *gint64_format, gchar **err_msg) { - const gchar *conv_start, *base, *tmp = NULL; - gchar *normalized_str = NULL, *aux_str = NULL; + const gchar *conv_start, *base, *tmp = nullptr; + gchar *normalized_str = nullptr, *aux_str = nullptr; /* Validate a counter format. This is a very simple "parser" that * simply checks for a single gint64 conversion specification, @@ -804,7 +804,7 @@ qof_book_normalize_counter_format_internal(const gchar *p, { if (err_msg) *err_msg = g_strdup("Format string ended without any conversion specification"); - return NULL; + return nullptr; } /* Store the start of the conversion for error messages */ @@ -821,7 +821,7 @@ qof_book_normalize_counter_format_internal(const gchar *p, { if (err_msg) *err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format); - return NULL; + return nullptr; } /* Skip any number of flag characters */ @@ -843,23 +843,23 @@ qof_book_normalize_counter_format_internal(const gchar *p, { if (err_msg) *err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start); - return NULL; + return nullptr; } /* See if the format string starts with the correct format * specification. */ tmp = strstr(p, gint64_format); - if (tmp == NULL) + if (tmp == nullptr) { if (err_msg) *err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format); - return NULL; + return nullptr; } else if (tmp != p) { if (err_msg) *err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p); - return NULL; + return nullptr; } /* Copy the string we have so far and add normalized format specifier for long int */ @@ -888,7 +888,7 @@ qof_book_normalize_counter_format_internal(const gchar *p, if (err_msg) *err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p); g_free (normalized_str); - return NULL; + return nullptr; } /* Skip all other characters */ p++; @@ -925,10 +925,10 @@ qof_book_use_split_action_for_num_field (const QofBook *book) { // No cached value? Then do the expensive KVP lookup gboolean result; - char *opt = NULL; + char *opt = nullptr; qof_instance_get (QOF_INSTANCE (book), PARAM_NAME_NUM_FIELD_SOURCE, &opt, - NULL); + nullptr); if (opt && opt[0] == 't' && opt[1] == 0) result = TRUE; @@ -976,7 +976,7 @@ gint qof_book_get_num_days_autoreadonly (const QofBook *book) // No cached value? Then do the expensive KVP lookup qof_instance_get (QOF_INSTANCE (book), PARAM_NAME_NUM_AUTOREAD_ONLY, &tmp, - NULL); + nullptr); const_cast(book)->cached_num_days_autoreadonly = tmp; const_cast(book)->cached_num_days_autoreadonly_isvalid = TRUE; @@ -988,7 +988,7 @@ gint qof_book_get_num_days_autoreadonly (const QofBook *book) GDate* qof_book_get_autoreadonly_gdate (const QofBook *book) { gint num_days; - GDate* result = NULL; + GDate* result = nullptr; g_assert(book); num_days = qof_book_get_num_days_autoreadonly(book); @@ -1237,7 +1237,7 @@ qof_book_get_features (QofBook *book) { KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book)); GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, g_free); + nullptr, g_free); PWARN ("qof_book_get_features is now deprecated."); @@ -1398,12 +1398,12 @@ gboolean qof_book_register (void) { static QofParam params[] = { - { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL }, - { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL }, - { NULL }, + { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, nullptr }, + { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, nullptr }, + { nullptr }, }; - qof_class_register (QOF_ID_BOOK, NULL, params); + qof_class_register (QOF_ID_BOOK, nullptr, params); return TRUE; } diff --git a/libgnucash/engine/qofinstance.cpp b/libgnucash/engine/qofinstance.cpp index 11d77e1656..2ef3bf7882 100644 --- a/libgnucash/engine/qofinstance.cpp +++ b/libgnucash/engine/qofinstance.cpp @@ -133,9 +133,9 @@ static void qof_instance_class_init(QofInstanceClass *klass) object_class->set_property = qof_instance_set_property; object_class->get_property = qof_instance_get_property; - klass->get_display_name = NULL; - klass->refers_to_object = NULL; - klass->get_typed_referring_object_list = NULL; + klass->get_display_name = nullptr; + klass->refers_to_object = nullptr; + klass->get_typed_referring_object_list = nullptr; g_object_class_install_property (object_class, @@ -257,7 +257,7 @@ qof_instance_init (QofInstance *inst) QofInstancePrivate *priv; priv = GET_PRIVATE(inst); - priv->book = NULL; + priv->book = nullptr; inst->kvp_data = new KvpFrame; priv->last_update = 0; priv->editlevel = 0; @@ -279,7 +279,7 @@ qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book) priv->book = book; col = qof_book_get_collection (book, type); - g_return_if_fail(col != NULL); + g_return_if_fail(col != nullptr); /* XXX We passed redundant info to this routine ... but I think that's * OK, it might eliminate programming errors. */ @@ -297,7 +297,7 @@ qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book) { guid_replace(&priv->guid); - if (NULL == qof_collection_lookup_entity (col, &priv->guid)) + if (nullptr == qof_collection_lookup_entity (col, &priv->guid)) break; PWARN("duplicate id created, trying again"); @@ -320,7 +320,7 @@ qof_instance_dispose (GObject *instp) qof_collection_remove_entity(inst); CACHE_REMOVE(inst->e_type); - inst->e_type = NULL; + inst->e_type = nullptr; G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp); } @@ -457,7 +457,7 @@ qof_instance_get_guid (gconstpointer inst) { QofInstancePrivate *priv; - if (!inst) return NULL; + if (!inst) return nullptr; g_return_val_if_fail(QOF_IS_INSTANCE(inst), guid_null()); priv = GET_PRIVATE(inst); return &(priv->guid); @@ -516,7 +516,7 @@ QofCollection * qof_instance_get_collection (gconstpointer ptr) { - g_return_val_if_fail(QOF_IS_INSTANCE(ptr), NULL); + g_return_val_if_fail(QOF_IS_INSTANCE(ptr), nullptr); return GET_PRIVATE(ptr)->collection; } @@ -530,8 +530,8 @@ qof_instance_set_collection (gconstpointer ptr, QofCollection *col) QofBook * qof_instance_get_book (gconstpointer inst) { - if (!inst) return NULL; - g_return_val_if_fail(QOF_IS_INSTANCE(inst), NULL); + if (!inst) return nullptr; + g_return_val_if_fail(QOF_IS_INSTANCE(inst), nullptr); return GET_PRIVATE(inst)->book; } @@ -569,7 +569,7 @@ qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2) KvpFrame* qof_instance_get_slots (const QofInstance *inst) { - if (!inst) return NULL; + if (!inst) return nullptr; return inst->kvp_data; } @@ -785,9 +785,9 @@ void qof_instance_set_idata(gpointer inst, guint32 idata) /* Returns a displayable name to represent this object */ gchar* qof_instance_get_display_name(const QofInstance* inst) { - g_return_val_if_fail( inst != NULL, NULL ); + g_return_val_if_fail( inst != nullptr, nullptr ); - if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != NULL ) + if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != nullptr ) { return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst); } @@ -811,7 +811,7 @@ get_referring_object_instance_helper(QofInstance* inst, gpointer user_data) { QofInstance** pInst = (QofInstance**)user_data; - if (*pInst == NULL) + if (*pInst == nullptr) { *pInst = inst; } @@ -820,12 +820,12 @@ get_referring_object_instance_helper(QofInstance* inst, gpointer user_data) static void get_referring_object_helper(QofCollection* coll, gpointer user_data) { - QofInstance* first_instance = NULL; + QofInstance* first_instance = nullptr; GetReferringObjectHelperData* data = (GetReferringObjectHelperData*)user_data; qof_collection_foreach(coll, get_referring_object_instance_helper, &first_instance); - if (first_instance != NULL) + if (first_instance != nullptr) { GList* new_list = qof_instance_get_typed_referring_object_list(first_instance, data->inst); data->list = g_list_concat(data->list, new_list); @@ -837,11 +837,11 @@ GList* qof_instance_get_referring_object_list(const QofInstance* inst) { GetReferringObjectHelperData data; - g_return_val_if_fail( inst != NULL, NULL ); + g_return_val_if_fail( inst != nullptr, nullptr ); /* scan all collections */ data.inst = inst; - data.list = NULL; + data.list = nullptr; qof_book_foreach_collection(qof_instance_get_book(inst), get_referring_object_helper, @@ -865,11 +865,11 @@ qof_instance_get_referring_object_list_from_collection(const QofCollection* coll { GetReferringObjectHelperData data; - g_return_val_if_fail( coll != NULL, NULL ); - g_return_val_if_fail( ref != NULL, NULL ); + g_return_val_if_fail( coll != nullptr, nullptr ); + g_return_val_if_fail( ref != nullptr, nullptr ); data.inst = ref; - data.list = NULL; + data.list = nullptr; qof_collection_foreach(coll, get_typed_referring_object_instance_helper, &data); return data.list; @@ -878,10 +878,10 @@ qof_instance_get_referring_object_list_from_collection(const QofCollection* coll GList* qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref) { - g_return_val_if_fail( inst != NULL, NULL ); - g_return_val_if_fail( ref != NULL, NULL ); + g_return_val_if_fail( inst != nullptr, nullptr ); + g_return_val_if_fail( ref != nullptr, nullptr ); - if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != NULL ) + if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != nullptr ) { return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref); } @@ -899,10 +899,10 @@ qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofI /* Check if this object refers to a specific object */ gboolean qof_instance_refers_to_object(const QofInstance* inst, const QofInstance* ref) { - g_return_val_if_fail( inst != NULL, FALSE ); - g_return_val_if_fail( ref != NULL, FALSE ); + g_return_val_if_fail( inst != nullptr, FALSE ); + g_return_val_if_fail( ref != nullptr, FALSE ); - if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != NULL ) + if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != nullptr ) { return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref); } @@ -1043,7 +1043,7 @@ qof_commit_edit_part2(QofInstance *inst, gboolean qof_instance_has_kvp (QofInstance *inst) { - return (inst->kvp_data != NULL && !inst->kvp_data->empty()); + return (inst->kvp_data != nullptr && !inst->kvp_data->empty()); } void qof_instance_set_path_kvp (QofInstance * inst, GValue const * value, std::vector const & path) @@ -1111,7 +1111,7 @@ qof_instance_kvp_add_guid (const QofInstance *inst, const char* path, time64 time, const char *key, const GncGUID *guid) { - g_return_if_fail (inst->kvp_data != NULL); + g_return_if_fail (inst->kvp_data != nullptr); auto container = new KvpFrame; Time64 t{time}; @@ -1138,8 +1138,8 @@ gboolean qof_instance_kvp_has_guid (const QofInstance *inst, const char *path, const char* key, const GncGUID *guid) { - g_return_val_if_fail (inst->kvp_data != NULL, FALSE); - g_return_val_if_fail (guid != NULL, FALSE); + g_return_val_if_fail (inst->kvp_data != nullptr, FALSE); + g_return_val_if_fail (guid != nullptr, FALSE); auto v = inst->kvp_data->get_slot({path}); if (v == nullptr) return FALSE; @@ -1152,7 +1152,7 @@ qof_instance_kvp_has_guid (const QofInstance *inst, const char *path, case KvpValue::Type::GLIST: { auto list = v->get(); - for (auto node = list; node != NULL; node = node->next) + for (auto node = list; node != nullptr; node = node->next) { auto val = static_cast(node->data); if (kvp_match_guid (val, {key}, guid)) @@ -1173,11 +1173,11 @@ void qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path, const char *key, const GncGUID *guid) { - g_return_if_fail (inst->kvp_data != NULL); - g_return_if_fail (guid != NULL); + g_return_if_fail (inst->kvp_data != nullptr); + g_return_if_fail (guid != nullptr); auto v = inst->kvp_data->get_slot({path}); - if (v == NULL) return; + if (v == nullptr) return; switch (v->get_type()) { @@ -1215,12 +1215,12 @@ void qof_instance_kvp_merge_guids (const QofInstance *target, const QofInstance *donor, const char *path) { - g_return_if_fail (target != NULL); - g_return_if_fail (donor != NULL); + g_return_if_fail (target != nullptr); + g_return_if_fail (donor != nullptr); if (! qof_instance_has_slot (donor, path)) return; auto v = donor->kvp_data->get_slot({path}); - if (v == NULL) return; + if (v == nullptr) return; auto target_val = target->kvp_data->get_slot({path}); switch (v->get_type()) @@ -1257,7 +1257,7 @@ bool qof_instance_has_path_slot (QofInstance const * inst, std::vectorkvp_data->get_slot({path}) != NULL; + return inst->kvp_data->get_slot({path}) != nullptr; } void qof_instance_slot_path_delete (QofInstance const * inst, std::vector const & path) diff --git a/libgnucash/engine/qoflog.cpp b/libgnucash/engine/qoflog.cpp index 5bd9f8407c..0da26d73fd 100644 --- a/libgnucash/engine/qoflog.cpp +++ b/libgnucash/engine/qoflog.cpp @@ -61,11 +61,11 @@ #define QOF_LOG_INDENT_WIDTH 4 #define NUM_CLOCKS 10 -static FILE *fout = NULL; -static gchar* function_buffer = NULL; +static FILE *fout = nullptr; +static gchar* function_buffer = nullptr; static gint qof_log_num_spaces = 0; -static GLogFunc previous_handler = NULL; -static gchar* qof_logger_format = NULL; +static GLogFunc previous_handler = nullptr; +static gchar* qof_logger_format = nullptr; static QofLogModule log_module = "qof"; using StrVec = std::vector; @@ -90,7 +90,7 @@ struct ModuleEntry MEVec m_children; }; -static ModuleEntryPtr _modules = NULL; +static ModuleEntryPtr _modules = nullptr; static ModuleEntry* get_modules() @@ -155,7 +155,7 @@ qof_log_set_file(FILE *outfile) void qof_log_init(void) { - qof_log_init_filename(NULL); + qof_log_init_filename(nullptr); } static void @@ -180,14 +180,14 @@ log4glib_handler(const gchar *log_domain, #endif ; const char *level_str = qof_log_level_to_string(level); - now = gnc_time (NULL); + now = gnc_time (nullptr); gnc_localtime_r (&now, &now_tm); qof_strftime(timestamp_buf, 9, format_24hour, &now_tm); fprintf(fout, qof_logger_format, timestamp_buf, 5, level_str, - (log_domain == NULL ? "" : log_domain), + (log_domain == nullptr ? "" : log_domain), qof_log_num_spaces, "", message, (g_str_has_suffix(message, "\n") ? "" : "\n")); @@ -198,7 +198,7 @@ log4glib_handler(const gchar *log_domain, else { // chain - previous_handler(log_domain, log_level, message, NULL); + previous_handler(log_domain, log_level, message, nullptr); } */ } @@ -217,7 +217,7 @@ qof_log_init_filename(const gchar* log_filename) int fd; gchar *fname; - if (fout != NULL && fout != stderr && fout != stdout) + if (fout != nullptr && fout != stderr && fout != stdout) fclose(fout); fname = g_strconcat(log_filename, ".XXXXXX.log", nullptr); @@ -251,7 +251,7 @@ qof_log_init_filename(const gchar* log_filename) if (!fout) fout = stderr; - if (previous_handler == NULL) + if (previous_handler == nullptr) previous_handler = g_log_set_default_handler(log4glib_handler, modules); if (warn_about_missing_permission) @@ -266,24 +266,24 @@ qof_log_shutdown (void) if (fout && fout != stderr && fout != stdout) { fclose(fout); - fout = NULL; + fout = nullptr; } if (function_buffer) { g_free(function_buffer); - function_buffer = NULL; + function_buffer = nullptr; } - if (_modules != NULL) + if (_modules != nullptr) { _modules = nullptr; } - if (previous_handler != NULL) + if (previous_handler != nullptr) { - g_log_set_default_handler(previous_handler, NULL); - previous_handler = NULL; + g_log_set_default_handler(previous_handler, nullptr); + previous_handler = nullptr; } } @@ -376,11 +376,11 @@ qof_log_prettify (const char *name) p = g_strstr_len (buffer, length, "("); if (p) *p = '\0'; begin = g_strrstr (buffer, "*"); - if (begin == NULL) + if (begin == nullptr) begin = g_strrstr (buffer, " "); else if (* (begin + 1) == ' ') ++ begin; - if (begin != NULL) + if (begin != nullptr) p = begin + 1; else p = buffer; @@ -415,7 +415,7 @@ void qof_log_parse_log_config(const char *filename) { const gchar *levels_group = "levels", *output_group = "output"; - GError *err = NULL; + GError *err = nullptr; GKeyFile *conf = g_key_file_new(); if (!g_key_file_load_from_file(conf, filename, G_KEY_FILE_NONE, &err)) @@ -432,18 +432,18 @@ qof_log_parse_log_config(const char *filename) unsigned int key_idx; gchar **levels; gint logger_max_name_length = 12; - gchar *str = NULL; + gchar *str = nullptr; - levels = g_key_file_get_keys(conf, levels_group, &num_levels, NULL); + levels = g_key_file_get_keys(conf, levels_group, &num_levels, nullptr); - for (key_idx = 0; key_idx < num_levels && levels[key_idx] != NULL; key_idx++) + for (key_idx = 0; key_idx < num_levels && levels[key_idx] != nullptr; key_idx++) { QofLogLevel level; - gchar *logger_name = NULL, *level_str = NULL; + gchar *logger_name = nullptr, *level_str = nullptr; logger_name = g_strdup(levels[key_idx]); logger_max_name_length = MAX (logger_max_name_length, (gint) strlen (logger_name)); - level_str = g_key_file_get_string(conf, levels_group, logger_name, NULL); + level_str = g_key_file_get_string(conf, levels_group, logger_name, nullptr); level = qof_log_level_from_string(level_str); DEBUG("setting log [%s] to level [%s=%d]", logger_name, level_str, level); @@ -468,8 +468,8 @@ qof_log_parse_log_config(const char *filename) unsigned int output_idx; gchar **outputs; - outputs = g_key_file_get_keys(conf, output_group, &num_outputs, NULL); - for (output_idx = 0; output_idx < num_outputs && outputs[output_idx] != NULL; output_idx++) + outputs = g_key_file_get_keys(conf, output_group, &num_outputs, nullptr); + for (output_idx = 0; output_idx < num_outputs && outputs[output_idx] != nullptr; output_idx++) { gchar *key = outputs[output_idx]; gchar *value; @@ -480,7 +480,7 @@ qof_log_parse_log_config(const char *filename) continue; } - value = g_key_file_get_string(conf, output_group, key, NULL); + value = g_key_file_get_string(conf, output_group, key, nullptr); DEBUG("setting [output].to=[%s]", value); qof_log_init_filename_special(value); g_free(value); diff --git a/libgnucash/engine/qofobject.cpp b/libgnucash/engine/qofobject.cpp index bb74b91554..f6f17e5049 100644 --- a/libgnucash/engine/qofobject.cpp +++ b/libgnucash/engine/qofobject.cpp @@ -32,8 +32,8 @@ static QofLogModule log_module = QOF_MOD_OBJECT; static gboolean object_is_initialized = FALSE; -static GList *object_modules = NULL; -static GList *book_list = NULL; +static GList *object_modules = nullptr; +static GList *book_list = nullptr; /* * These getters are used in tests to reach static vars from outside @@ -66,15 +66,15 @@ qof_object_new_instance (QofIdTypeConst type_name, QofBook *book) { const QofObject *obj; - if (!type_name) return NULL; + if (!type_name) return nullptr; obj = qof_object_lookup (type_name); - if (!obj) return NULL; + if (!obj) return nullptr; if (obj->create) return (obj->create (book)); - return NULL; + return nullptr; } void qof_object_book_begin (QofBook *book) @@ -169,7 +169,7 @@ qof_object_compliance (QofIdTypeConst type_name, gboolean warn) const QofObject *obj; obj = qof_object_lookup(type_name); - if ((obj->create == NULL) || (obj->foreach == NULL)) + if ((obj->create == nullptr) || (obj->foreach == nullptr)) { if (warn) { @@ -222,7 +222,7 @@ do_prepend (QofInstance *qof_p, gpointer list_p) void qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data) { - GList *list = NULL; + GList *list = nullptr; GList *iter; qof_object_foreach(type_name, book, do_prepend, &list); @@ -249,25 +249,25 @@ qof_object_printable (QofIdTypeConst type_name, gpointer obj) { const QofObject *b_obj; - if (!type_name || !obj) return NULL; + if (!type_name || !obj) return nullptr; b_obj = qof_object_lookup (type_name); - if (!b_obj) return NULL; + if (!b_obj) return nullptr; if (b_obj->printable) return (b_obj->printable (obj)); - return NULL; + return nullptr; } const char * qof_object_get_type_label (QofIdTypeConst type_name) { const QofObject *obj; - if (!type_name) return NULL; + if (!type_name) return nullptr; obj = qof_object_lookup (type_name); - if (!obj) return NULL; + if (!obj) return nullptr; return (obj->type_label); } @@ -285,9 +285,9 @@ void qof_object_shutdown (void) g_return_if_fail (object_is_initialized == TRUE); g_list_free (object_modules); - object_modules = NULL; + object_modules = nullptr; g_list_free (book_list); - book_list = NULL; + book_list = nullptr; object_is_initialized = FALSE; } @@ -324,9 +324,9 @@ const QofObject * qof_object_lookup (QofIdTypeConst name) GList *iter; const QofObject *obj; - g_return_val_if_fail (object_is_initialized, NULL); + g_return_val_if_fail (object_is_initialized, nullptr); - if (!name) return NULL; + if (!name) return nullptr; for (iter = object_modules; iter; iter = iter->next) { @@ -334,7 +334,7 @@ const QofObject * qof_object_lookup (QofIdTypeConst name) if (!g_strcmp0 (obj->e_type, name)) return obj; } - return NULL; + return nullptr; } /* ========================= END OF FILE =================== */ diff --git a/libgnucash/engine/qofquery.cpp b/libgnucash/engine/qofquery.cpp index f805fbed55..354724fe7b 100644 --- a/libgnucash/engine/qofquery.cpp +++ b/libgnucash/engine/qofquery.cpp @@ -46,7 +46,7 @@ struct _QofQueryTerm /* These values are filled in during "compilation" of the query * term, based upon the obj_name, param_name, and searched-for - * object type. If conv_fcn is NULL, then we don't know how to + * object type. If conv_fcn is nullptr, then we don't know how to * convert types. */ GSList * param_fcns; @@ -61,7 +61,7 @@ struct _QofQuerySort /* These values are filled in during "compilation" of the query * term, based upon the obj_name, param_name, and searched-for - * object type. If conv_fcn is NULL, then we don't know how to + * object type. If conv_fcn is nullptr, then we don't know how to * convert types. */ gboolean use_default; @@ -113,8 +113,8 @@ typedef struct _QofQueryCB /* initial_term will be owned by the new Query */ static void query_init (QofQuery *q, QofQueryTerm *initial_term) { - GList * _or_ = NULL; - GList *_and_ = NULL; + GList * _or_ = nullptr; + GList *_and_ = nullptr; GHashTable *ht; if (initial_term) @@ -147,7 +147,7 @@ static void query_init (QofQuery *q, QofQueryTerm *initial_term) q->changed = 1; q->max_results = -1; - q->primary_sort.param_list = g_slist_prepend (static_cast(NULL), + q->primary_sort.param_list = g_slist_prepend (static_cast(nullptr), static_cast(const_cast(QUERY_DEFAULT_SORT))); q->primary_sort.increasing = TRUE; q->secondary_sort.increasing = TRUE; @@ -185,7 +185,7 @@ static void free_query_term (QofQueryTerm *qt) static QofQueryTerm * copy_query_term (const QofQueryTerm *qt) { QofQueryTerm *new_qt; - if (!qt) return NULL; + if (!qt) return nullptr; new_qt = g_new0 (QofQueryTerm, 1); *new_qt = *qt; @@ -197,7 +197,7 @@ static QofQueryTerm * copy_query_term (const QofQueryTerm *qt) static GList * copy_and_terms (const GList *and_terms) { - GList *_and_ = NULL; + GList *_and_ = nullptr; const GList *cur_and; for (cur_and = and_terms; cur_and; cur_and = cur_and->next) @@ -211,7 +211,7 @@ static GList * copy_and_terms (const GList *and_terms) static GList * copy_or_terms(const GList * or_terms) { - GList * _or_ = NULL; + GList * _or_ = nullptr; const GList * cur_or; for (cur_or = or_terms; cur_or; cur_or = cur_or->next) @@ -232,17 +232,17 @@ static void copy_sort (QofQuerySort *dst, const QofQuerySort *src) static void free_sort (QofQuerySort *s) { g_slist_free (s->param_list); - s->param_list = NULL; + s->param_list = nullptr; g_slist_free (s->param_fcns); - s->param_fcns = NULL; + s->param_fcns = nullptr; } static void free_members (QofQuery *q) { GList * cur_or; - if (q == NULL) return; + if (q == nullptr) return; for (cur_or = q->terms; cur_or; cur_or = cur_or->next) { @@ -252,11 +252,11 @@ static void free_members (QofQuery *q) cur_and = static_cast(cur_and->next)) { free_query_term(static_cast(cur_and->data)); - cur_and->data = NULL; + cur_and->data = nullptr; } g_list_free(static_cast(cur_or->data)); - cur_or->data = NULL; + cur_or->data = nullptr; } free_sort (&(q->primary_sort)); @@ -264,19 +264,19 @@ static void free_members (QofQuery *q) free_sort (&(q->tertiary_sort)); g_list_free(q->terms); - q->terms = NULL; + q->terms = nullptr; g_list_free(q->books); - q->books = NULL; + q->books = nullptr; g_list_free(q->results); - q->results = NULL; + q->results = nullptr; } static int cmp_func (const QofQuerySort *sort, QofSortFunc default_sort, const gconstpointer a, const gconstpointer b) { - QofParam *param = NULL; + QofParam *param = nullptr; GSList *node; gpointer conva, convb; @@ -377,7 +377,7 @@ check_object (const QofQuery *q, gpointer object) if (qt->param_fcns && qt->pred_fcn) { const GSList *node; - QofParam *param = NULL; + QofParam *param = nullptr; gpointer conv_obj = object; /* iterate through the conversions */ @@ -413,7 +413,7 @@ check_object (const QofQuery *q, gpointer object) * may want to get all objects, but in a particular sorted * order. */ - if (NULL == q->terms) return 1; + if (nullptr == q->terms) return 1; return 0; } @@ -421,19 +421,19 @@ check_object (const QofQuery *q, gpointer object) * compile the list of parameter get-functions. Save the last valid * parameter definition in "final" and return the list of functions. * - * returns NULL if the first parameter is bad (and final is unchanged). + * returns nullptr if the first parameter is bad (and final is unchanged). */ static GSList * compile_params (QofQueryParamList *param_list, QofIdType start_obj, QofParam const **final) { - const QofParam *objDef = NULL; - GSList *fcns = NULL; + const QofParam *objDef = nullptr; + GSList *fcns = nullptr; ENTER ("param_list=%p id=%s", param_list, start_obj); - g_return_val_if_fail (param_list, NULL); - g_return_val_if_fail (start_obj, NULL); - g_return_val_if_fail (final, NULL); + g_return_val_if_fail (param_list, nullptr); + g_return_val_if_fail (start_obj, nullptr); + g_return_val_if_fail (final, nullptr); for (; param_list; param_list = param_list->next) { @@ -460,15 +460,15 @@ compile_params (QofQueryParamList *param_list, QofIdType start_obj, static void compile_sort (QofQuerySort *sort, QofIdType obj) { - const QofParam *resObj = NULL; + const QofParam *resObj = nullptr; ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list); sort->use_default = FALSE; g_slist_free (sort->param_fcns); - sort->param_fcns = NULL; - sort->comp_fcn = NULL; - sort->obj_cmp = NULL; + sort->param_fcns = nullptr; + sort->comp_fcn = nullptr; + sort->obj_cmp = nullptr; /* An empty param_list implies "no sort" */ if (!sort->param_list) @@ -494,7 +494,7 @@ compile_sort (QofQuerySort *sort, QofIdType obj) sort->comp_fcn = qof_query_core_get_compare (resObj->param_type); /* Next, perhaps this is an object compare, not a core type compare? */ - if (sort->comp_fcn == NULL) + if (sort->comp_fcn == nullptr) sort->obj_cmp = qof_class_get_default_sort (resObj->param_type); } else if (!g_strcmp0 (static_cast(sort->param_list->data), @@ -519,10 +519,10 @@ static void compile_terms (QofQuery *q) and_ptr = static_cast(and_ptr->next)) { QofQueryTerm* qt = static_cast(and_ptr->data); - const QofParam* resObj = NULL; + const QofParam* resObj = nullptr; g_slist_free (qt->param_fcns); - qt->param_fcns = NULL; + qt->param_fcns = nullptr; /* Walk the parameter list of obtain the parameter functions */ qt->param_fcns = compile_params (qt->param_list, q->search_for, @@ -535,7 +535,7 @@ static void compile_terms (QofQuery *q) if (qt->param_fcns && resObj) qt->pred_fcn = qof_query_core_get_predicate (resObj->param_type); else - qt->pred_fcn = NULL; + qt->pred_fcn = nullptr; } } @@ -603,7 +603,7 @@ static int param_list_cmp (const QofQueryParamList *l1, const QofQueryParamList static GList * merge_books (GList *l1, GList *l2) { - GList *res = NULL; + GList *res = nullptr; GList *node; res = g_list_copy (l1); @@ -633,7 +633,7 @@ query_free_compiled (gpointer key, gpointer value, gpointer not_used) /* clear out any cached query_compilations */ static void query_clear_compiles (QofQuery *q) { - g_hash_table_foreach_remove (q->be_compiled, query_free_compiled, NULL); + g_hash_table_foreach_remove (q->be_compiled, query_free_compiled, nullptr); } /********************************************************************/ @@ -642,12 +642,12 @@ static void query_clear_compiles (QofQuery *q) QofQueryParamList * qof_query_build_param_list (char const *param, ...) { - QofQueryParamList *param_list = NULL; + QofQueryParamList *param_list = nullptr; char const *this_param; va_list ap; if (!param) - return NULL; + return nullptr; va_start (ap, param); @@ -673,7 +673,7 @@ void qof_query_add_term (QofQuery *q, QofQueryParamList *param_list, qs = qof_query_create (); query_init (qs, qt); - if (q->terms != NULL) + if (q->terms != nullptr) qr = qof_query_merge (q, qs, op); else qr = qof_query_merge (q, qs, QOF_QUERY_OR); @@ -725,13 +725,13 @@ static GList * qof_query_run_internal (QofQuery *q, void(*run_cb)(QofQueryCB*, gpointer), gpointer cb_arg) { - GList *matching_objects = NULL; + GList *matching_objects = nullptr; int object_count = 0; - if (!q) return NULL; - g_return_val_if_fail (q->search_for, NULL); - g_return_val_if_fail (q->books, NULL); - g_return_val_if_fail (run_cb, NULL); + if (!q) return nullptr; + g_return_val_if_fail (q->search_for, nullptr); + g_return_val_if_fail (q->books, nullptr); + g_return_val_if_fail (run_cb, nullptr); ENTER (" q=%p", q); /* XXX: Prioritize the query terms? */ @@ -786,11 +786,11 @@ static GList * qof_query_run_internal (QofQuery *q, /* mptr is set to the first node of what will be the new list */ mptr = g_list_nth(matching_objects, object_count - q->max_results); - /* mptr should not be NULL, but let's be safe */ - if (mptr != NULL) + /* mptr should not be nullptr, but let's be safe */ + if (mptr != nullptr) { - if (mptr->prev != NULL) mptr->prev->next = NULL; - mptr->prev = NULL; + if (mptr->prev != nullptr) mptr->prev->next = nullptr; + mptr->prev = nullptr; } g_list_free(matching_objects); matching_objects = mptr; @@ -799,7 +799,7 @@ static GList * qof_query_run_internal (QofQuery *q, { /* q->max_results == 0 */ g_list_free(matching_objects); - matching_objects = NULL; + matching_objects = nullptr; } } @@ -846,7 +846,7 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg) GList * qof_query_run (QofQuery *q) { /* Just a wrapper */ - return qof_query_run_internal(q, qof_query_run_cb, NULL); + return qof_query_run_internal(q, qof_query_run_cb, nullptr); } static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg) @@ -860,14 +860,14 @@ static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg) GList * qof_query_run_subquery (QofQuery *subq, const QofQuery* primaryq) { - if (!subq) return NULL; - if (!primaryq) return NULL; + if (!subq) return nullptr; + if (!primaryq) return nullptr; /* Make sure we're searching for the same thing */ - g_return_val_if_fail (subq->search_for, NULL); - g_return_val_if_fail (primaryq->search_for, NULL); + g_return_val_if_fail (subq->search_for, nullptr); + g_return_val_if_fail (primaryq->search_for, nullptr); g_return_val_if_fail(!g_strcmp0(subq->search_for, primaryq->search_for), - NULL); + nullptr); /* Perform the subquery */ return qof_query_run_internal(subq, qof_query_run_subq_cb, @@ -878,7 +878,7 @@ GList * qof_query_last_run (QofQuery *query) { if (!query) - return NULL; + return nullptr; return query->results; } @@ -890,9 +890,9 @@ void qof_query_clear (QofQuery *query) qof_query_destroy (q2); g_list_free (query->books); - query->books = NULL; + query->books = nullptr; g_list_free (query->results); - query->results = NULL; + query->results = nullptr; query->changed = 1; } @@ -900,7 +900,7 @@ QofQuery * qof_query_create (void) { QofQuery *qp = g_new0 (QofQuery, 1); qp->be_compiled = g_hash_table_new (g_direct_hash, g_direct_equal); - query_init (qp, NULL); + query_init (qp, nullptr); return qp; } @@ -920,7 +920,7 @@ QofQuery * qof_query_create_for (QofIdTypeConst obj_type) { QofQuery *q; if (!obj_type) - return NULL; + return nullptr; q = qof_query_create (); qof_query_search_for (q, obj_type); return q; @@ -968,7 +968,7 @@ GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param) { GList *_or_; GList *_and_; - GSList *results = NULL; + GSList *results = nullptr; if (!q || !term_param) return FALSE; @@ -1001,7 +1001,7 @@ QofQuery * qof_query_copy (QofQuery *q) QofQuery *copy; GHashTable *ht; - if (!q) return NULL; + if (!q) return nullptr; copy = qof_query_create (); ht = copy->be_compiled; free_members (copy); @@ -1039,7 +1039,7 @@ QofQuery * qof_query_invert (QofQuery *q) int num_or_terms; if (!q) - return NULL; + return nullptr; num_or_terms = g_list_length(q->terms); @@ -1060,12 +1060,12 @@ QofQuery * qof_query_invert (QofQuery *q) retval->changed = 1; aterms = static_cast(g_list_nth_data(q->terms, 0)); - new_oterm = NULL; + new_oterm = nullptr; for (cur = aterms; cur; cur = cur->next) { qt = copy_query_term(static_cast(cur->data)); qt->invert = !(qt->invert); - new_oterm = g_list_append(NULL, qt); + new_oterm = g_list_append(nullptr, qt); retval->terms = g_list_prepend(retval->terms, new_oterm); } retval->terms = g_list_reverse(retval->terms); @@ -1079,7 +1079,7 @@ QofQuery * qof_query_invert (QofQuery *q) right->terms = copy_or_terms(g_list_nth(q->terms, 1)); left = qof_query_create(); - left->terms = g_list_append(NULL, + left->terms = g_list_append(nullptr, copy_and_terms(static_cast(g_list_nth_data(q->terms, 0)))); iright = qof_query_invert(right); @@ -1110,7 +1110,7 @@ QofQuery * qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) { - QofQuery * retval = NULL; + QofQuery * retval = nullptr; QofQuery * i1, * i2; QofQuery * t1, * t2; GList * i, * j; @@ -1121,7 +1121,7 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) if (q1->search_for && q2->search_for) g_return_val_if_fail (g_strcmp0 (q1->search_for, q2->search_for) == 0, - NULL); + nullptr); search_for = (q1->search_for ? q1->search_for : q2->search_for); @@ -1135,7 +1135,7 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) * so that the first term added to an empty query doesn't screw up. */ if ((QOF_QUERY_AND == op) && - (q1->terms == NULL || q2->terms == NULL)) + (q1->terms == nullptr || q2->terms == nullptr)) { op = QOF_QUERY_OR; } @@ -1291,7 +1291,7 @@ void qof_query_add_guid_list_match (QofQuery *q, QofQueryParamList *param_list, void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list, const GncGUID *guid, QofQueryOp op) { - GList *g = NULL; + GList *g = nullptr; if (!q || !param_list) return; @@ -1306,7 +1306,7 @@ void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list, void qof_query_set_book (QofQuery *q, QofBook *book) { - QofQueryParamList *slist = NULL; + QofQueryParamList *slist = nullptr; if (!q || !book) return; /* Make sure this book is only in the list once */ @@ -1321,7 +1321,7 @@ void qof_query_set_book (QofQuery *q, QofBook *book) GList * qof_query_get_books (QofQuery *q) { - if (!q) return NULL; + if (!q) return nullptr; return q->books; } @@ -1360,27 +1360,27 @@ int qof_query_get_max_results (const QofQuery *q) QofIdType qof_query_get_search_for (const QofQuery *q) { - if (!q) return NULL; + if (!q) return nullptr; return q->search_for; } GList * qof_query_get_terms (const QofQuery *q) { - if (!q) return NULL; + if (!q) return nullptr; return q->terms; } QofQueryParamList * qof_query_term_get_param_path (const QofQueryTerm *qt) { if (!qt) - return NULL; + return nullptr; return qt->param_list; } QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *qt) { if (!qt) - return NULL; + return nullptr; return qt->pdata; } @@ -1407,7 +1407,7 @@ void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary, QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *qs) { if (!qs) - return NULL; + return nullptr; return qs->param_list; } @@ -1533,8 +1533,8 @@ qof_query_print (QofQuery * query) return; } - output = NULL; - str = NULL; + output = nullptr; + str = nullptr; maxResults = qof_query_get_max_results (query); output = qof_query_printSearchFor (query, output); @@ -1566,7 +1566,7 @@ qof_query_printOutput (GList * output) DEBUG (" %s", line->str); g_string_free (line, TRUE); - line = NULL; + line = nullptr; } } @@ -1582,7 +1582,7 @@ qof_query_printSearchFor (QofQuery * query, GList * output) searchFor = qof_query_get_search_for (query); gs = g_string_new ("Query Object Type: "); - g_string_append (gs, (NULL == searchFor) ? "(null)" : searchFor); + g_string_append (gs, (nullptr == searchFor) ? "(null)" : searchFor); output = g_list_append (output, gs); return output; @@ -1628,7 +1628,7 @@ qof_query_printTerms (QofQuery * query, GList * output) static GList * qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output) { - QofQueryParamList *gsl, *n = NULL; + QofQueryParamList *gsl, *n = nullptr; gint curSort; GString *gs = g_string_new ("Sort Parameters: "); @@ -1699,7 +1699,7 @@ qof_query_printAndTerms (GList * terms, GList * output) static GString * qof_query_printParamPath (QofQueryParamList * parmList) { - QofQueryParamList *list = NULL; + QofQueryParamList *list = nullptr; GString *gs = g_string_new ("Param List: "); g_string_append (gs, " "); for (list = parmList; list; list = list->next) diff --git a/libgnucash/engine/qofquerycore.cpp b/libgnucash/engine/qofquerycore.cpp index 51c5301135..4b4aeec279 100644 --- a/libgnucash/engine/qofquerycore.cpp +++ b/libgnucash/engine/qofquerycore.cpp @@ -90,31 +90,31 @@ static const char * query_choice_type = QOF_TYPE_CHOICE; /* Tables for predicate storage and lookup */ static gboolean initialized = FALSE; -static GHashTable *predTable = NULL; -static GHashTable *cmpTable = NULL; -static GHashTable *copyTable = NULL; -static GHashTable *freeTable = NULL; -static GHashTable *toStringTable = NULL; -static GHashTable *predEqualTable = NULL; +static GHashTable *predTable = nullptr; +static GHashTable *cmpTable = nullptr; +static GHashTable *copyTable = nullptr; +static GHashTable *freeTable = nullptr; +static GHashTable *toStringTable = nullptr; +static GHashTable *predEqualTable = nullptr; #define COMPARE_ERROR -3 #define PREDICATE_ERROR -2 #define VERIFY_PDATA(str) { \ - g_return_if_fail (pd != NULL); \ + g_return_if_fail (pd != nullptr); \ g_return_if_fail (pd->type_name == str || \ !g_strcmp0 (str, pd->type_name)); \ } #define VERIFY_PDATA_R(str) { \ - g_return_val_if_fail (pd != NULL, NULL); \ + g_return_val_if_fail (pd != nullptr, nullptr); \ g_return_val_if_fail (pd->type_name == str || \ !g_strcmp0 (str, pd->type_name), \ - NULL); \ + nullptr); \ } #define VERIFY_PREDICATE(str) { \ - g_return_val_if_fail (getter != NULL, PREDICATE_ERROR); \ - g_return_val_if_fail (getter->param_getfcn != NULL, PREDICATE_ERROR); \ - g_return_val_if_fail (pd != NULL, PREDICATE_ERROR); \ + g_return_val_if_fail (getter != nullptr, PREDICATE_ERROR); \ + g_return_val_if_fail (getter->param_getfcn != nullptr, PREDICATE_ERROR); \ + g_return_val_if_fail (pd != nullptr, PREDICATE_ERROR); \ g_return_val_if_fail (pd->type_name == str || \ !g_strcmp0 (str, pd->type_name), \ PREDICATE_ERROR); \ @@ -220,7 +220,7 @@ qof_string_number_compare_func (gpointer a, gpointer b, gint options, s1 = ((query_string_getter)getter->param_getfcn) (a, getter); s2 = ((query_string_getter)getter->param_getfcn) (b, getter); - // Deal with NULL strings + // Deal with nullptr strings if (s1 == s2) return 0; if (!s1 && s2) return -1; if (s1 && !s2) return 1; @@ -282,10 +282,10 @@ qof_query_string_predicate (QofQueryCompare how, { query_string_t pdata; - g_return_val_if_fail (str, NULL); -// g_return_val_if_fail (*str != '\0', NULL); + g_return_val_if_fail (str, nullptr); +// g_return_val_if_fail (*str != '\0', nullptr); g_return_val_if_fail (how == QOF_COMPARE_CONTAINS || how == QOF_COMPARE_NCONTAINS || - how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, NULL); + how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, nullptr); pdata = g_new0 (query_string_def, 1); pdata->pd.type_name = query_string_type; @@ -305,7 +305,7 @@ qof_query_string_predicate (QofQueryCompare how, { g_free(pdata->matchstring); g_free(pdata); - return NULL; + return nullptr; } pdata->is_regex = TRUE; } @@ -320,7 +320,7 @@ string_to_string (gpointer object, QofParam *getter) res = ((query_string_getter)getter->param_getfcn)(object, getter); if (res) return g_strdup (res); - return NULL; + return nullptr; } /* QOF_TYPE_DATE =================================================== */ @@ -452,7 +452,7 @@ date_to_string (gpointer object, QofParam *getter) if (tt != INT64_MAX) return qof_print_date (tt); - return NULL; + return nullptr; } /* QOF_TYPE_NUMERIC ================================================= */ @@ -595,7 +595,7 @@ guid_match_predicate (gpointer object, QofParam *getter, { query_guid_t pdata = (query_guid_t)pd; GList *node, *o_list; - const GncGUID *guid = NULL; + const GncGUID *guid = nullptr; VERIFY_PREDICATE (query_guid_type); @@ -620,15 +620,15 @@ guid_match_predicate (gpointer object, QofParam *getter, } /* - * If o_list is NULL, we've walked the whole list without finding + * If o_list is nullptr, we've walked the whole list without finding * a match. Therefore break out now, the match has failed. */ - if (o_list == NULL) + if (o_list == nullptr) break; } /* - * The match is complete. If node == NULL then we've successfully + * The match is complete. If node == nullptr then we've successfully * found a match for all the guids in the predicate. Return * appropriately below. */ @@ -657,14 +657,14 @@ guid_match_predicate (gpointer object, QofParam *getter, } /* Check to see if we found a match. If so, break now */ - if (node2 != NULL) + if (node2 != nullptr) break; } g_list_free(o_list); /* yea, node may point to an invalid location, but that's ok. - * we're not _USING_ the value, just checking that it's non-NULL + * we're not _USING_ the value, just checking that it's non-nullptr */ break; @@ -687,14 +687,14 @@ guid_match_predicate (gpointer object, QofParam *getter, { case QOF_GUID_MATCH_ANY: case QOF_GUID_MATCH_LIST_ANY: - return (node != NULL); + return (node != nullptr); break; case QOF_GUID_MATCH_NONE: case QOF_GUID_MATCH_ALL: - return (node == NULL); + return (node == nullptr); break; case QOF_GUID_MATCH_NULL: - return ((guid == NULL) || guid_equal(guid, guid_null())); + return ((guid == nullptr) || guid_equal(guid, guid_null())); break; default: PWARN ("bad match type"); @@ -751,7 +751,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guid_list) /* An empty list of guids is only valid when testing for a null GUID value */ if (!guid_list) - g_return_val_if_fail (options == QOF_GUID_MATCH_NULL, NULL); + g_return_val_if_fail (options == QOF_GUID_MATCH_NULL, nullptr); pdata = g_new0 (query_guid_def, 1); pdata->pd.how = QOF_COMPARE_EQUAL; @@ -1111,7 +1111,7 @@ QofQueryPredData * qof_query_boolean_predicate (QofQueryCompare how, gboolean val) { query_boolean_t pdata; - g_return_val_if_fail (how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, NULL); + g_return_val_if_fail (how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, nullptr); pdata = g_new0 (query_boolean_def, 1); pdata->pd.type_name = query_boolean_type; @@ -1196,7 +1196,7 @@ QofQueryPredData * qof_query_char_predicate (QofCharMatch options, const char *chars) { query_char_t pdata; - g_return_val_if_fail (chars, NULL); + g_return_val_if_fail (chars, nullptr); pdata = g_new0 (query_char_def, 1); pdata->pd.type_name = query_char_type; pdata->pd.how = QOF_COMPARE_EQUAL; @@ -1225,7 +1225,7 @@ collect_match_predicate (gpointer object, QofParam *getter, pdata = (query_coll_t)pd; VERIFY_PREDICATE (query_collect_type); - guid = NULL; + guid = nullptr; switch (pdata->options) { case QOF_GUID_MATCH_ALL : @@ -1242,7 +1242,7 @@ collect_match_predicate (gpointer object, QofParam *getter, break; } } - if (o_list == NULL) + if (o_list == nullptr) { break; } @@ -1262,7 +1262,7 @@ collect_match_predicate (gpointer object, QofParam *getter, break; } } - if (node2 != NULL) + if (node2 != nullptr) { break; } @@ -1286,18 +1286,18 @@ collect_match_predicate (gpointer object, QofParam *getter, case QOF_GUID_MATCH_ANY : case QOF_GUID_MATCH_LIST_ANY : { - return (node != NULL); + return (node != nullptr); break; } case QOF_GUID_MATCH_NONE : case QOF_GUID_MATCH_ALL : { - return (node == NULL); + return (node == nullptr); break; } case QOF_GUID_MATCH_NULL : { - return ((guid == NULL) || guid_equal(guid, guid_null())); + return ((guid == nullptr) || guid_equal(guid, guid_null())); break; } default : @@ -1328,7 +1328,7 @@ collect_free_pdata (QofQueryPredData *pd) query_coll_t pdata; GList *node; - node = NULL; + node = nullptr; pdata = (query_coll_t) pd; VERIFY_PDATA (query_collect_type); for (node = pdata->guids; node; node = node->next) @@ -1380,14 +1380,14 @@ qof_query_collect_predicate (QofGuidMatch options, QofCollection *coll) { query_coll_t pdata; - g_return_val_if_fail (coll, NULL); + g_return_val_if_fail (coll, nullptr); pdata = g_new0 (query_coll_def, 1); pdata->pd.type_name = query_collect_type; pdata->options = options; qof_collection_foreach(coll, query_collect_cb, pdata); - if (NULL == pdata->guids) + if (nullptr == pdata->guids) { - return NULL; + return nullptr; } return ((QofQueryPredData*)pdata); } @@ -1400,7 +1400,7 @@ choice_match_predicate (gpointer object, QofParam *getter, { query_choice_t pdata = (query_choice_t)pd; GList *node, *o_list; - const GncGUID *guid = NULL; + const GncGUID *guid = nullptr; VERIFY_PREDICATE (query_choice_type); @@ -1425,15 +1425,15 @@ choice_match_predicate (gpointer object, QofParam *getter, } /* - * If o_list is NULL, we've walked the whole list without finding + * If o_list is nullptr, we've walked the whole list without finding * a match. Therefore break out now, the match has failed. */ - if (o_list == NULL) + if (o_list == nullptr) break; } /* - * The match is complete. If node == NULL then we've successfully + * The match is complete. If node == nullptr then we've successfully * found a match for all the guids in the predicate. Return * appropriately below. */ @@ -1455,7 +1455,7 @@ choice_match_predicate (gpointer object, QofParam *getter, break; } - if (node2 != NULL) + if (node2 != nullptr) break; } @@ -1481,14 +1481,14 @@ choice_match_predicate (gpointer object, QofParam *getter, { case QOF_GUID_MATCH_ANY: case QOF_GUID_MATCH_LIST_ANY: - return (node != NULL); + return (node != nullptr); break; case QOF_GUID_MATCH_NONE: case QOF_GUID_MATCH_ALL: - return (node == NULL); + return (node == nullptr); break; case QOF_GUID_MATCH_NULL: - return ((guid == NULL) || guid_equal(guid, guid_null())); + return ((guid == nullptr) || guid_equal(guid, guid_null())); break; default: PWARN ("bad match type"); @@ -1543,7 +1543,7 @@ qof_query_choice_predicate (QofGuidMatch options, GList *guid_list) query_choice_t pdata; GList *node; - if (NULL == guid_list) return NULL; + if (nullptr == guid_list) return nullptr; pdata = g_new0 (query_choice_def, 1); pdata->pd.how = QOF_COMPARE_EQUAL; @@ -1645,8 +1645,8 @@ static void init_tables (void) numeric_predicate_equal }, { - QOF_TYPE_GUID, guid_match_predicate, NULL, - guid_copy_predicate, guid_free_pdata, NULL, + QOF_TYPE_GUID, guid_match_predicate, nullptr, + guid_copy_predicate, guid_free_pdata, nullptr, guid_predicate_equal }, { @@ -1676,12 +1676,12 @@ static void init_tables (void) }, { QOF_TYPE_COLLECT, collect_match_predicate, collect_compare_func, - collect_copy_predicate, collect_free_pdata, NULL, + collect_copy_predicate, collect_free_pdata, nullptr, collect_predicate_equal }, { - QOF_TYPE_CHOICE, choice_match_predicate, NULL, - choice_copy_predicate, choice_free_pdata, NULL, choice_predicate_equal + QOF_TYPE_CHOICE, choice_match_predicate, nullptr, + choice_copy_predicate, choice_free_pdata, nullptr, choice_predicate_equal }, }; @@ -1702,7 +1702,7 @@ static QueryPredicateCopyFunc qof_query_copy_predicate (QofType type) { QueryPredicateCopyFunc rc; - g_return_val_if_fail (type, NULL); + g_return_val_if_fail (type, nullptr); rc = reinterpret_cast(g_hash_table_lookup (copyTable, type)); return rc; } @@ -1710,7 +1710,7 @@ qof_query_copy_predicate (QofType type) static QueryPredDataFree qof_query_predicate_free (QofType type) { - g_return_val_if_fail (type, NULL); + g_return_val_if_fail (type, nullptr); return reinterpret_cast(g_hash_table_lookup (freeTable, type)); } @@ -1750,14 +1750,14 @@ void qof_query_core_shutdown (void) QofQueryPredicateFunc qof_query_core_get_predicate (QofType type) { - g_return_val_if_fail (type, NULL); + g_return_val_if_fail (type, nullptr); return reinterpret_cast(g_hash_table_lookup (predTable, type)); } QofCompareFunc qof_query_core_get_compare (QofType type) { - g_return_val_if_fail (type, NULL); + g_return_val_if_fail (type, nullptr); return reinterpret_cast(g_hash_table_lookup (cmpTable, type)); } @@ -1778,8 +1778,8 @@ qof_query_core_predicate_copy (const QofQueryPredData *pdata) { QueryPredicateCopyFunc copy; - g_return_val_if_fail (pdata, NULL); - g_return_val_if_fail (pdata->type_name, NULL); + g_return_val_if_fail (pdata, nullptr); + g_return_val_if_fail (pdata->type_name, nullptr); copy = qof_query_copy_predicate (pdata->type_name); return (copy (pdata)); @@ -1791,12 +1791,12 @@ qof_query_core_to_string (QofType type, gpointer object, { QueryToString toString; - g_return_val_if_fail (type, NULL); - g_return_val_if_fail (object, NULL); - g_return_val_if_fail (getter, NULL); + g_return_val_if_fail (type, nullptr); + g_return_val_if_fail (object, nullptr); + g_return_val_if_fail (getter, nullptr); toString = reinterpret_cast(g_hash_table_lookup (toStringTable, type)); - g_return_val_if_fail (toString, NULL); + g_return_val_if_fail (toString, nullptr); return toString (object, getter); } diff --git a/libgnucash/engine/test/utest-Account.cpp b/libgnucash/engine/test/utest-Account.cpp index 8a29680510..54cfdfb78d 100644 --- a/libgnucash/engine/test/utest-Account.cpp +++ b/libgnucash/engine/test/utest-Account.cpp @@ -471,7 +471,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"; - auto msg = ": assertion 'separator != NULL' failed"; + auto msg = ": assertion 'separator != nullptr' failed"; auto check = test_error_struct_new(log_domain, log_level, msg); GList *results, *res_iter; auto sep = ":"; diff --git a/libgnucash/engine/test/utest-Split.cpp b/libgnucash/engine/test/utest-Split.cpp index d0293184fe..9293d79ee1 100644 --- a/libgnucash/engine/test/utest-Split.cpp +++ b/libgnucash/engine/test/utest-Split.cpp @@ -414,7 +414,7 @@ test_xaccSplitEqual (Fixture *fixture, gconstpointer pData) { Split *split1 = xaccSplitCloneNoKvp (fixture->split); Split *split2 = xaccDupeSplit (fixture->split); - gchar *msg01 = "[xaccSplitEqual] one is NULL"; + gchar *msg01 = "[xaccSplitEqual] one is nullptr"; gchar *msg02 = "[xaccSplitEqual] GUIDs differ"; gchar *msg03; gchar *msg04 = "[xaccSplitEqual] actions differ: foo vs bar"; @@ -423,7 +423,7 @@ test_xaccSplitEqual (Fixture *fixture, gconstpointer pData) G_GNUC_UNUSED gchar *msg07 = "[xaccSplitEqual] reconciled date differs"; G_GNUC_UNUSED gchar *msg08 = "[xaccSplitEqual] amounts differ: foo vs bar"; gchar *msg10 = "[xaccSplitEqual] transactions differ"; - gchar *msg11 = "[xaccTransEqual] one is NULL"; + gchar *msg11 = "[xaccTransEqual] one is nullptr"; gchar *msg12 = "[xaccSplitEqualCheckBal] balances differ: 321/1000 vs 0/1"; gchar *msg13 = "[xaccSplitEqualCheckBal] cleared balances differ: 321/1000 vs 0/1"; gchar *msg14 = "[xaccSplitEqualCheckBal] reconciled balances differ: 321/1000 vs 0/1"; diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp index ff3ebc344c..704af204c9 100644 --- a/libgnucash/engine/test/utest-Transaction.cpp +++ b/libgnucash/engine/test/utest-Transaction.cpp @@ -753,7 +753,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData) Transaction *txn1 = xaccTransClone (txn0); const GncGUID *guid_f_txn = qof_instance_get_guid (txn0); gchar entered[DATE_BUF_SIZE], posted[DATE_BUF_SIZE]; - auto msg1 = "[xaccTransEqual] one is NULL"; + auto msg1 = "[xaccTransEqual] one is nullptr"; gchar *msg2 = NULL; auto cleanup_fmt = "[trans_cleanup_commit] get rid of rollback trans=%p"; gchar split_guid0[GUID_ENCODING_LENGTH + 1];