[gnc-ab-utils] concise string accumulator

This commit is contained in:
Christopher Lam 2022-09-03 13:58:42 +08:00
parent ecd2cdf425
commit 68aced362c

View File

@ -510,50 +510,16 @@ ab_ultimate_creditor_debtor_to_gnc (const AB_TRANSACTION *ab_trans,
gchar *
gnc_ab_description_to_gnc (const AB_TRANSACTION *ab_trans, gboolean is_ofx)
{
/* Description */
gchar *description = gnc_ab_get_purpose (ab_trans, is_ofx);
gchar *other_name = gnc_ab_get_remote_name (ab_trans);
gchar *ultimate = ab_ultimate_creditor_debtor_to_gnc (ab_trans, is_ofx);
gchar *retval = NULL;
GList *acc = NULL;
gchar *retval;
if (ultimate)
retval = ultimate;
if (description)
{
if (retval)
{
char *tmp = g_strdup_printf ("%s; %s", retval, description);
g_free (retval);
g_free (description);
retval = tmp;
}
else
{
retval = description;
}
}
acc = g_list_prepend (acc, gnc_ab_get_remote_name (ab_trans));
acc = g_list_prepend (acc, gnc_ab_get_purpose (ab_trans, is_ofx));
acc = g_list_prepend (acc, ab_ultimate_creditor_debtor_to_gnc (ab_trans, is_ofx));
retval = gnc_g_list_stringjoin (acc, "; ");
if (other_name)
{
if (retval)
{
char *tmp = g_strdup_printf ("%s; %s", retval, other_name);
g_free (retval);
g_free (other_name);
retval = tmp;
}
else
{
retval = other_name;
}
}
if (!retval)
{
retval = g_strdup (_("Unspecified"));
}
return retval;
g_list_free_full (acc, g_free);
return retval ? retval : g_strdup (_("Unspecified"));
}
gchar *