mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Correct memory leaks found with Valgrind.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20631 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -464,14 +464,6 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
|
||||
gboolean tax_related = FALSE;
|
||||
const char *code;
|
||||
const gchar *tax_type;
|
||||
GNCAccountType atype;
|
||||
SCM category;
|
||||
SCM code_scm;
|
||||
SCM tax_entity_type;
|
||||
const gchar *form, *desc, *copy_txt;
|
||||
gint64 copy_number;
|
||||
SCM scm;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
@@ -498,8 +490,13 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
}
|
||||
else /* with tax code */
|
||||
{
|
||||
const gchar *num_code = NULL;
|
||||
const gchar *tax_type;
|
||||
GNCAccountType atype;
|
||||
SCM tax_entity_type;
|
||||
SCM category;
|
||||
gchar *num_code = NULL;
|
||||
const gchar *prefix = "N";
|
||||
gchar *return_string = NULL;
|
||||
|
||||
tax_type = gnc_get_current_book_tax_type ();
|
||||
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
|
||||
@@ -562,89 +559,129 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
(atype == ACCT_TYPE_PAYABLE)) ?
|
||||
"txf-liab-eq-categories" : ""))));
|
||||
|
||||
num_code = g_strdup (code);
|
||||
if (g_str_has_prefix (num_code, prefix))
|
||||
num_code++; /* to lose the leading N */
|
||||
if (g_str_has_prefix (code, prefix))
|
||||
{
|
||||
const gchar *num_code_tmp;
|
||||
num_code_tmp = g_strdup (code);
|
||||
num_code_tmp++; /* to lose the leading N */
|
||||
num_code = g_strdup (num_code_tmp);
|
||||
num_code_tmp--;
|
||||
g_free ((gpointer *) num_code_tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_code = g_strdup (code);
|
||||
}
|
||||
|
||||
if (category == SCM_UNDEFINED)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("Tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
return_string = g_strdup_printf
|
||||
(_("Tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
}
|
||||
|
||||
code_scm = scm_str2symbol (code);
|
||||
scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
|
||||
if (!scm_is_string (scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("Invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
|
||||
form = scm_to_locale_string (scm);
|
||||
if (!form)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No form: code %s, tax type %s"), num_code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no form: code %s, tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
|
||||
scm = scm_call_3 (get_desc, category, code_scm, tax_entity_type);
|
||||
if (!scm_is_string (scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
|
||||
desc = scm_to_locale_string (scm);
|
||||
if (!desc)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
|
||||
copy_number = xaccAccountGetTaxUSCopyNumber (account);
|
||||
copy_txt = (copy_number == 1) ? "" : g_strdup_printf ("(%d)",
|
||||
(gint) copy_number);
|
||||
|
||||
if (tax_related)
|
||||
{
|
||||
if (safe_strcmp (form, "") == 0)
|
||||
return g_strdup_printf ("%s", desc);
|
||||
else
|
||||
return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
}
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
||||
form, copy_txt, desc, num_code, tax_type);
|
||||
{
|
||||
SCM code_scm;
|
||||
SCM form_scm;
|
||||
code_scm = scm_str2symbol (code);
|
||||
form_scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
|
||||
if (!scm_is_string (form_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("Invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *form = NULL;
|
||||
scm_dynwind_begin (0);
|
||||
form = scm_to_locale_string (form_scm);
|
||||
if (!form)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No form: code %s, tax type %s"), num_code,
|
||||
tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no form: code %s, tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM desc_scm;
|
||||
desc_scm = scm_call_3 (get_desc, category, code_scm,
|
||||
tax_entity_type);
|
||||
if (!scm_is_string (desc_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *desc = NULL;
|
||||
desc = scm_to_locale_string (desc_scm);
|
||||
if (!desc)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint64 copy_number;
|
||||
gchar *copy_txt = NULL;
|
||||
copy_number = xaccAccountGetTaxUSCopyNumber (account);
|
||||
copy_txt = (copy_number == 1) ?
|
||||
g_strdup ("") :
|
||||
g_strdup_printf ("(%d)",
|
||||
(gint) copy_number);
|
||||
if (tax_related)
|
||||
{
|
||||
if (safe_strcmp (form, "") == 0)
|
||||
return_string = g_strdup_printf ("%s", desc);
|
||||
else
|
||||
return_string = g_strdup_printf ("%s%s: %s",
|
||||
form, copy_txt, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
||||
form, copy_txt, desc, num_code, tax_type);
|
||||
}
|
||||
g_free (copy_txt);
|
||||
}
|
||||
scm_dynwind_free (desc);
|
||||
}
|
||||
}
|
||||
scm_dynwind_free (form);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
}
|
||||
g_free (num_code);
|
||||
return return_string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,12 +715,12 @@ gnc_ui_account_get_tax_info_sub_acct_string (const Account *account)
|
||||
* account generally corresponds to a specific line number
|
||||
* on a paper form and each form has a unique
|
||||
* identification (e.g., Form 1040, Schedule A). */
|
||||
return (sub_acct_tax_number == 0) ? g_strdup ("") :
|
||||
return (sub_acct_tax_number == 0) ? NULL :
|
||||
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
|
||||
sub_acct_tax_number);
|
||||
}
|
||||
else
|
||||
return g_strdup ("");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
||||
Reference in New Issue
Block a user