Complete reversion of e81bcf6 in gnc-pricedb.c.

This commit is contained in:
John Ralls 2019-01-23 17:50:22 -08:00
parent 9069bace15
commit 3a48672763

View File

@ -2196,7 +2196,7 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
merged currency list. */
GList **price_array = (GList **)g_new(gpointer, num_currencies);
GList **next_list;
int i, j, k;
int i, j;
GHashTableIter iter;
gpointer key, value;
@ -2208,16 +2208,14 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
price_array[i] = value;
}
/* Iterate up to n times (there are i prices, so going past i will run off the end of the array) to get the nth price, each time finding the currency
with the latest price */
for (k = 0; k <= n && k < i; ++k)
for (i = 0; i <= n; ++i)
{
next_list = NULL;
for (j = 0; j < i; ++j)
for (j = 0; j < num_currencies; ++j)
{
/* Save this entry if it's the first one or later than
the saved one. */
if (price_array[k] != NULL &&
if (price_array[j] != NULL &&
(next_list == NULL || *next_list == NULL ||
compare_prices_by_date((*next_list)->data, (price_array[j])->data) > 0))
{