[Scrub2.cpp] convert to cpp

This commit is contained in:
Christopher Lam 2024-03-17 23:15:15 +08:00
parent ddfa664601
commit 6b5a4d7c11
4 changed files with 19 additions and 11 deletions

View File

@ -143,7 +143,7 @@ set (engine_SOURCES
SX-book.c
SX-ttinfo.c
Scrub.cpp
Scrub2.c
Scrub2.cpp
Scrub3.c
ScrubBusiness.c
ScrubBudget.c

View File

@ -68,7 +68,7 @@ restart_loop:
splits = xaccAccountGetSplitList(acc);
for (node = splits; node; node = node->next)
{
Split * split = node->data;
Split * split = GNC_SPLIT(node->data);
/* If already in lot, then no-op */
if (split->lot) continue;
@ -163,7 +163,7 @@ xaccLotFill (GNCLot *lot)
void
xaccLotScrubDoubleBalance (GNCLot *lot)
{
gnc_commodity *currency = NULL;
gnc_commodity *currency = nullptr;
SplitList *snode;
GList *node;
gnc_numeric zero = gnc_numeric_zero();
@ -175,8 +175,8 @@ xaccLotScrubDoubleBalance (GNCLot *lot)
for (snode = gnc_lot_get_split_list(lot); snode; snode = snode->next)
{
Split *s = snode->data;
xaccSplitComputeCapGains (s, NULL);
Split *s = GNC_SPLIT(snode->data);
xaccSplitComputeCapGains (s, nullptr);
}
/* We double-check only closed lots */
@ -188,11 +188,11 @@ xaccLotScrubDoubleBalance (GNCLot *lot)
for (snode = gnc_lot_get_split_list(lot); snode; snode = snode->next)
{
Split *s = snode->data;
Split *s = GNC_SPLIT(snode->data);
Transaction *trans = s->parent;
/* Check to make sure all splits in the lot have a common currency */
if (NULL == currency)
if (nullptr == currency)
{
currency = trans->common_currency;
}
@ -227,7 +227,7 @@ xaccLotScrubDoubleBalance (GNCLot *lot)
gnc_num_dbg_to_string (value));
for (node = gnc_lot_get_split_list(lot); node; node = node->next)
{
Split *s = node->data;
Split *s = GNC_SPLIT(node->data);
PERR ("s=%p amt=%s val=%s", s,
gnc_num_dbg_to_string(s->amount),
gnc_num_dbg_to_string(s->value));
@ -340,7 +340,7 @@ xaccScrubMergeSubSplits (Split *split, gboolean strict)
restart:
for (node = txn->splits; node; node = node->next)
{
Split *s = node->data;
Split *s = GNC_SPLIT(node->data);
if (xaccSplitGetLot (s) != lot) continue;
if (s == split) continue;
if (qof_instance_get_destroying(s)) continue;
@ -391,7 +391,7 @@ xaccScrubMergeLotSubSplits (GNCLot *lot, gboolean strict)
restart:
for (node = gnc_lot_get_split_list(lot); node; node = node->next)
{
Split *s = node->data;
Split *s = GNC_SPLIT(node->data);
if (!xaccScrubMergeSubSplits(s, strict)) continue;
rc = TRUE;

View File

@ -34,6 +34,10 @@
#include "gnc-engine.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @name Lot Management Routines
* Provides the low-level API for checking and repairing ('scrubbing
* clean') the usage of Lots and lot balances in stock and commodity
@ -110,6 +114,10 @@ gboolean xaccScrubMergeSubSplits (Split *split, gboolean strict);
*/
gboolean xaccScrubMergeLotSubSplits (GNCLot *lot, gboolean strict);
#ifdef __cplusplus
}
#endif
#endif /* XACC_SCRUB2_H */
/** @} */
/** @} */

View File

@ -686,7 +686,7 @@ libgnucash/engine/qof-win32.cpp
libgnucash/engine/Query.c
libgnucash/engine/Recurrence.cpp
libgnucash/engine/SchedXaction.c
libgnucash/engine/Scrub2.c
libgnucash/engine/Scrub2.cpp
libgnucash/engine/Scrub3.c
libgnucash/engine/ScrubBudget.c
libgnucash/engine/ScrubBusiness.c