Skip to content

Commit

Permalink
[gnc-pricedb.h] remove unused gnc_pricedb_substitute_commodity
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Aug 31, 2024
1 parent 1718fa0 commit dc84e4d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 68 deletions.
3 changes: 0 additions & 3 deletions libgnucash/engine/gnc-pricedb-p.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ typedef struct gnc_price_lookup_helper_s
} GNCPriceLookupHelper;

#define gnc_price_set_guid(P,G) qof_instance_set_guid(QOF_INSTANCE(P),(G))
void gnc_pricedb_substitute_commodity(GNCPriceDB *db,
gnc_commodity *old_c,
gnc_commodity *new_c);

/** register the pricedb object with the gncObject system */
gboolean gnc_pricedb_register (void);
Expand Down
60 changes: 0 additions & 60 deletions libgnucash/engine/gnc-pricedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2744,66 +2744,6 @@ gnc_pricedb_foreach_price(GNCPriceDB *db,
return unstable_price_traversal(db, f, user_data);
}

/* ==================================================================== */
/* commodity substitution */

typedef struct
{
gnc_commodity *old_c;
gnc_commodity *new_c;
} GNCPriceFixupData;

static gboolean
add_price_to_list (GNCPrice *p, gpointer data)
{
auto list = static_cast<GList**>(data);

*list = g_list_prepend (*list, p);

return TRUE;
}

static void
gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data)
{
auto p = static_cast<GNCPrice*>(data);
auto fixup_data = static_cast<GNCPriceFixupData*>(user_data);
gnc_commodity *price_c;

if (!p) return;

price_c = gnc_price_get_commodity(p);
if (gnc_commodity_equiv(price_c, fixup_data->old_c))
{
gnc_price_set_commodity (p, fixup_data->new_c);
}
price_c = gnc_price_get_currency(p);
if (gnc_commodity_equiv(price_c, fixup_data->old_c))
{
gnc_price_set_currency (p, fixup_data->new_c);
}
}

void
gnc_pricedb_substitute_commodity(GNCPriceDB *db,
gnc_commodity *old_c,
gnc_commodity *new_c)
{
GNCPriceFixupData data;
GList *prices = nullptr;

if (!db || !old_c || !new_c) return;

data.old_c = old_c;
data.new_c = new_c;

gnc_pricedb_foreach_price (db, add_price_to_list, &prices, FALSE);

g_list_foreach (prices, gnc_price_fixup_legacy_commods, &data);

g_list_free (prices);
}

/***************************************************************************/

/* Semi-lame debugging code */
Expand Down
5 changes: 0 additions & 5 deletions libgnucash/engine/test/utest-gnc-pricedb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,11 +1587,6 @@ gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data)// Local: 0:1:0
test_gnc_price_fixup_legacy_commods (Fixture *fixture, gconstpointer pData)
{
}*/
// Not Used
/* gnc_pricedb_substitute_commodity
void
gnc_pricedb_substitute_commodity(GNCPriceDB *db,// Local: 0:0:0
*/
/* gnc_price_print
void
gnc_price_print(GNCPrice *p, FILE *f, int indent)// Local: 1:0:0
Expand Down

0 comments on commit dc84e4d

Please sign in to comment.