From 093781c01889dddf0afa8eacd7aab8efe12a18ce Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 17 Mar 2024 16:36:41 +0800 Subject: [PATCH] [policy.cpp] convert to cpp --- libgnucash/engine/CMakeLists.txt | 2 +- libgnucash/engine/{policy.c => policy.cpp} | 16 ++++++++-------- po/POTFILES.in | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) rename libgnucash/engine/{policy.c => policy.cpp} (95%) diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt index f07e022e64..a6b6df1744 100644 --- a/libgnucash/engine/CMakeLists.txt +++ b/libgnucash/engine/CMakeLists.txt @@ -177,7 +177,7 @@ set (engine_SOURCES gnc-uri-utils.c engine-helpers.c guid.cpp - policy.c + policy.cpp gncAddress.c gncBillTerm.c gncBusiness.c diff --git a/libgnucash/engine/policy.c b/libgnucash/engine/policy.cpp similarity index 95% rename from libgnucash/engine/policy.c rename to libgnucash/engine/policy.cpp index 3e4b05614b..e8039749b1 100644 --- a/libgnucash/engine/policy.c +++ b/libgnucash/engine/policy.cpp @@ -76,18 +76,18 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse) time64 open_time; Account* lot_account; - if (!pcy || !lot || !gnc_lot_get_split_list(lot)) return NULL; + if (!pcy || !lot || !gnc_lot_get_split_list(lot)) return nullptr; lot_account = gnc_lot_get_account(lot); - if (!lot_account) return NULL; + if (!lot_account) return nullptr; /* Recomputing the balance re-evaluates the lot closure */ baln = gnc_lot_get_balance (lot); - if (gnc_lot_is_closed(lot)) return NULL; + if (gnc_lot_is_closed(lot)) return nullptr; want_positive = gnc_numeric_negative_p (baln); /* All splits in lot must share a common transaction currency. */ - split = gnc_lot_get_split_list(lot)->data; + split = GNC_SPLIT(gnc_lot_get_split_list(lot)->data); common_currency = split->parent->common_currency; /* Don't add a split to the lot unless it will be the new last @@ -111,7 +111,7 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse) gboolean is_match; gboolean is_positive; time64 this_time; - split = node->data; + split = GNC_SPLIT(node->data); if (split->lot) goto donext; /* Skip it if it's too early */ @@ -145,7 +145,7 @@ donext: node = node->next; } } - return NULL; + return nullptr; } /* ============================================================== */ @@ -153,7 +153,7 @@ donext: static GNCLot * FIFOPolicyGetLot (GNCPolicy *pcy, Split *split) { - if (!split) return NULL; + if (!split) return nullptr; return xaccAccountFindEarliestOpenLot (split->acc, split->amount, split->parent->common_currency); } @@ -189,7 +189,7 @@ FIFOPolicyIsOpeningSplit (GNCPolicy *pcy, GNCLot *lot, Split *split) GNCPolicy * xaccGetFIFOPolicy (void) { - static GNCPolicy *pcy = NULL; + static GNCPolicy *pcy = nullptr; if (!pcy) { diff --git a/po/POTFILES.in b/po/POTFILES.in index bc28fad43c..29754f9aab 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -666,7 +666,7 @@ libgnucash/engine/gncVendor.c libgnucash/engine/guid.cpp libgnucash/engine/kvp-frame.cpp libgnucash/engine/kvp-value.cpp -libgnucash/engine/policy.c +libgnucash/engine/policy.cpp libgnucash/engine/qof-backend.cpp libgnucash/engine/qofbook.cpp libgnucash/engine/qofbookslots.h