mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 10:20:18 -06:00
Readd gnc_scm_to_locale_string function and use it where appropriate
This function is a wrapper around scm_to_locale_string which returns a gchar * to be freed with g_free. The return value of the original function has to be freed with free. This is confusing since most of the gnucash code relies on g_malloc/g_free. While at it, clean up a lot of memory handling issues around (gnc_)scm_to_locale_string git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22684 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bc42791f92
commit
06eb020f7f
@ -11,6 +11,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gfec.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "platform.h"
|
||||
#if COMPILER(MSVC)
|
||||
# define strdup _strdup
|
||||
@ -36,15 +37,7 @@ gfec_catcher(void *data, SCM tag, SCM throw_args)
|
||||
{
|
||||
result = scm_call_2(func, tag, throw_args);
|
||||
if (scm_is_string(result))
|
||||
{
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (result);
|
||||
msg = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
msg = gnc_scm_to_locale_string (result);
|
||||
}
|
||||
|
||||
if (msg == NULL)
|
||||
|
@ -444,7 +444,7 @@ gnc_split_scm_set_value(SCM split_scm, gnc_numeric value)
|
||||
* return the newly allocated memo of a scheme split, or NULL. *
|
||||
* *
|
||||
* Args: split_scm - the scheme split *
|
||||
* Returns: newly allocated memo string *
|
||||
* Returns: newly allocated memo string, must be freed with g_free *
|
||||
\********************************************************************/
|
||||
char *
|
||||
gnc_split_scm_get_memo(SCM split_scm)
|
||||
@ -460,17 +460,17 @@ gnc_split_scm_get_memo(SCM split_scm)
|
||||
if (!scm_is_string(result))
|
||||
return NULL;
|
||||
|
||||
return scm_to_locale_string(result);
|
||||
return gnc_scm_to_locale_string(result);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_split_scm_get_action *
|
||||
* return the newly allocated action of a scheme split, or NULL. *
|
||||
* *
|
||||
* Args: split_scm - the scheme split *
|
||||
* Returns: newly allocated action string *
|
||||
\********************************************************************/
|
||||
/**********************************************************************\
|
||||
* gnc_split_scm_get_action *
|
||||
* return the newly allocated action of a scheme split, or NULL. *
|
||||
* *
|
||||
* Args: split_scm - the scheme split *
|
||||
* Returns: newly allocated action string, must be freed with g_free *
|
||||
\**********************************************************************/
|
||||
char *
|
||||
gnc_split_scm_get_action(SCM split_scm)
|
||||
{
|
||||
@ -485,7 +485,7 @@ gnc_split_scm_get_action(SCM split_scm)
|
||||
if (!scm_is_string(result))
|
||||
return NULL;
|
||||
|
||||
return scm_to_locale_string(result);
|
||||
return gnc_scm_to_locale_string(result);
|
||||
}
|
||||
|
||||
|
||||
@ -918,13 +918,13 @@ gnc_get_debit_string(GNCAccountType account_type)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_credit_string *
|
||||
* return a credit string for a given account type *
|
||||
* *
|
||||
* Args: account_type - type of account to get credit string for *
|
||||
* Return: g_malloc'd credit string or NULL *
|
||||
\********************************************************************/
|
||||
/************************************************************************\
|
||||
* gnc_get_credit_string *
|
||||
* return a credit string for a given account type *
|
||||
* *
|
||||
* Args: account_type - type of account to get credit string for *
|
||||
* Return: g_malloc'd credit string or NULL, must be freed with g_free *
|
||||
\************************************************************************/
|
||||
char *
|
||||
gnc_get_credit_string(GNCAccountType account_type)
|
||||
{
|
||||
@ -945,7 +945,7 @@ gnc_get_credit_string(GNCAccountType account_type)
|
||||
if (!scm_is_string(result))
|
||||
return NULL;
|
||||
|
||||
return scm_to_locale_string(result);
|
||||
return gnc_scm_to_locale_string(result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "option-util.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "glib-helpers.h"
|
||||
#include "guile-util.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "qof.h"
|
||||
#include "guile-mappings.h"
|
||||
|
||||
@ -900,8 +900,6 @@ char *
|
||||
gnc_option_permissible_value_name(GNCOption *option, int index)
|
||||
{
|
||||
SCM name;
|
||||
char * str;
|
||||
char * string;
|
||||
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
@ -915,13 +913,7 @@ gnc_option_permissible_value_name(GNCOption *option, int index)
|
||||
if (!scm_is_string(name))
|
||||
return NULL;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (name);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
return string;
|
||||
return gnc_scm_to_locale_string (name);
|
||||
}
|
||||
|
||||
|
||||
@ -939,8 +931,6 @@ char *
|
||||
gnc_option_permissible_value_description(GNCOption *option, int index)
|
||||
{
|
||||
SCM help;
|
||||
char * str;
|
||||
char * string;
|
||||
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
@ -954,13 +944,7 @@ gnc_option_permissible_value_description(GNCOption *option, int index)
|
||||
if (!scm_is_string(help))
|
||||
return NULL;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (help);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
return string;
|
||||
return gnc_scm_to_locale_string (help);
|
||||
}
|
||||
|
||||
|
||||
@ -1708,11 +1692,7 @@ gnc_commit_option(GNCOption *option)
|
||||
return;
|
||||
}
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (oops);
|
||||
message = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
message = gnc_scm_to_locale_string (oops);
|
||||
name = gnc_option_name(option);
|
||||
section = gnc_option_section(option);
|
||||
|
||||
@ -1903,8 +1883,6 @@ gnc_option_db_get_default_section(GNCOptionDB *odb)
|
||||
{
|
||||
SCM getter;
|
||||
SCM value;
|
||||
char * str;
|
||||
char * string;
|
||||
|
||||
if (odb == NULL)
|
||||
return NULL;
|
||||
@ -1917,12 +1895,7 @@ gnc_option_db_get_default_section(GNCOptionDB *odb)
|
||||
if (!scm_is_string(value))
|
||||
return NULL;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
return string;
|
||||
return gnc_scm_to_locale_string (value);
|
||||
}
|
||||
|
||||
|
||||
@ -2028,16 +2001,7 @@ gnc_option_db_lookup_string_option(GNCOptionDB *odb,
|
||||
{
|
||||
value = scm_call_0(getter);
|
||||
if (scm_is_string(value))
|
||||
{
|
||||
char * str;
|
||||
char * string;
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
return string;
|
||||
}
|
||||
return gnc_scm_to_locale_string (value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2772,14 +2736,7 @@ gboolean gnc_dateformat_option_value_parse(SCM value, QofDateFormat *format,
|
||||
break;
|
||||
|
||||
if (custom)
|
||||
{
|
||||
char * tmp_str;
|
||||
char * string;
|
||||
tmp_str = scm_to_locale_string (val);
|
||||
string = g_strdup (tmp_str);
|
||||
free (tmp_str);
|
||||
*custom = string;
|
||||
}
|
||||
*custom = gnc_scm_to_locale_string (val);
|
||||
|
||||
return FALSE;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "engine-helpers.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "test-engine-stuff.h"
|
||||
#include "test-stuff.h"
|
||||
#include "Query.h"
|
||||
@ -20,7 +21,6 @@ test_query (Query *q, SCM val2str)
|
||||
SCM res_q;
|
||||
SCM args = SCM_EOL;
|
||||
Query *q2;
|
||||
char * str;
|
||||
gchar *str2 = NULL;
|
||||
|
||||
scm_q = gnc_query2scm (q);
|
||||
@ -30,11 +30,7 @@ test_query (Query *q, SCM val2str)
|
||||
args = scm_cons (scm_from_locale_string ("'"), scm_cons (str_q, SCM_EOL));
|
||||
str_q = scm_string_append (args);
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (str_q);
|
||||
if (str) str2 = g_strdup(str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
str2 = gnc_scm_to_locale_string (str_q);
|
||||
if (str2)
|
||||
{
|
||||
res_q = scm_c_eval_string (str2);
|
||||
@ -53,14 +49,14 @@ test_query (Query *q, SCM val2str)
|
||||
scm_q = gnc_query2scm (q2);
|
||||
scm_display (scm_q, SCM_UNDEFINED);
|
||||
scm_newline (SCM_UNDEFINED);
|
||||
if (str2) g_free(str2);
|
||||
g_free(str2);
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
success ("queries match");
|
||||
}
|
||||
if (str2) g_free(str2);
|
||||
g_free(str2);
|
||||
if (q2) qof_query_destroy (q2);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,35 @@ static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_guile_symbol_to_locale_string *
|
||||
* gnc_scm_to_locale_string *
|
||||
* returns the string representation of the scm string in *
|
||||
* a newly allocated gchar * or NULL if it can't be retrieved. *
|
||||
* *
|
||||
* Args: symbol_value - the scm symbol *
|
||||
* Returns: newly allocated gchar * or NULL, should be freed with *
|
||||
* g_free by the caller *
|
||||
\********************************************************************/
|
||||
gchar *gnc_scm_to_locale_string(SCM scm_string)
|
||||
{
|
||||
if (scm_is_string (scm_string))
|
||||
{
|
||||
gchar* s;
|
||||
char * str;
|
||||
|
||||
str = scm_to_locale_string(scm_string);
|
||||
s = g_strdup(str);
|
||||
free (str);
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Unable to extract string from the symbol...*/
|
||||
PERR("bad value\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_scm_symbol_to_locale_string *
|
||||
* returns the string representation of the scm symbol in *
|
||||
* a newly allocated gchar * or NULL if it can't be retrieved. *
|
||||
* *
|
||||
|
@ -28,7 +28,15 @@
|
||||
#include <libguile.h>
|
||||
|
||||
/** Helper function to get the string representation of
|
||||
* a guile symbol. */
|
||||
* a guile string.
|
||||
*
|
||||
* Returns a newly allocated string that must be freed with g_free*/
|
||||
gchar * gnc_scm_to_locale_string(SCM scm_string);
|
||||
|
||||
/** Helper function to get the string representation of
|
||||
* a guile symbol.
|
||||
*
|
||||
* Returns a newly allocated string that must be freed with g_free*/
|
||||
gchar * gnc_scm_symbol_to_locale_string(SCM scm_string);
|
||||
|
||||
/* Helpful functions for calling functions that return
|
||||
|
@ -326,11 +326,9 @@ gnc_scm2guid(SCM guid_scm)
|
||||
{
|
||||
return *guid_null();
|
||||
}
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (guid_scm);
|
||||
str = gnc_scm_to_locale_string (guid_scm);
|
||||
string_to_guid(str, &guid);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
return guid;
|
||||
}
|
||||
|
||||
@ -348,11 +346,9 @@ gnc_guid_p(SCM guid_scm)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (guid_scm);
|
||||
str = gnc_scm_to_locale_string (guid_scm);
|
||||
return_int = string_to_guid(str, &guid);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
return return_int;
|
||||
}
|
||||
|
||||
@ -702,14 +698,8 @@ gnc_query_scm2path (SCM path_scm)
|
||||
if (!scm_is_string (key_scm))
|
||||
break;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(key_scm);
|
||||
key = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
key = gnc_scm_to_locale_string(key_scm);
|
||||
path = g_slist_prepend (path, key);
|
||||
|
||||
path_scm = SCM_CDR (path_scm);
|
||||
}
|
||||
|
||||
@ -877,11 +867,9 @@ gnc_scm2KvpValue (SCM value_scm)
|
||||
case KVP_TYPE_STRING:
|
||||
{
|
||||
gchar * str;
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (val_scm);
|
||||
str = gnc_scm_to_locale_string (val_scm);
|
||||
value = kvp_value_new_string (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1175,13 +1163,11 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
||||
qt_scm = SCM_CDR (qt_scm);
|
||||
if (!scm_is_string (scm)) break;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
matchstring = scm_to_locale_string (scm);
|
||||
matchstring = gnc_scm_to_locale_string (scm);
|
||||
|
||||
pd = qof_query_string_predicate (compare_how, matchstring,
|
||||
options, is_regex);
|
||||
scm_dynwind_free (matchstring);
|
||||
scm_dynwind_end ();
|
||||
g_free (matchstring);
|
||||
}
|
||||
else if (!g_strcmp0 (type, QOF_TYPE_DATE))
|
||||
{
|
||||
@ -1299,12 +1285,10 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
||||
qt_scm = SCM_CDR (qt_scm);
|
||||
if (!scm_is_string (scm))
|
||||
break;
|
||||
scm_dynwind_begin (0);
|
||||
char_list = scm_to_locale_string (scm);
|
||||
char_list = gnc_scm_to_locale_string (scm);
|
||||
|
||||
pd = qof_query_char_predicate (options, char_list);
|
||||
scm_dynwind_free (char_list);
|
||||
scm_dynwind_end ();
|
||||
g_free (char_list);
|
||||
}
|
||||
else if (!g_strcmp0 (type, QOF_TYPE_KVP))
|
||||
{
|
||||
@ -1572,8 +1556,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||
|
||||
scm = SCM_CAR (query_term_scm);
|
||||
query_term_scm = SCM_CDR (query_term_scm);
|
||||
scm_dynwind_begin (0);
|
||||
matchstring = scm_to_locale_string (scm);
|
||||
matchstring = gnc_scm_to_locale_string (scm);
|
||||
|
||||
if (!g_strcmp0 (pr_type, "pr-action"))
|
||||
{
|
||||
@ -1607,8 +1590,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||
{
|
||||
PINFO ("Unknown string predicate: %s", pr_type);
|
||||
}
|
||||
scm_dynwind_free (matchstring);
|
||||
scm_dynwind_end ();
|
||||
g_free (matchstring);
|
||||
|
||||
}
|
||||
else if (!g_strcmp0 (pd_type, "pd-cleared"))
|
||||
@ -1648,7 +1630,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||
{
|
||||
GncGUID guid;
|
||||
QofIdType id_type;
|
||||
gchar *str;
|
||||
|
||||
/* guid */
|
||||
if (scm_is_null (query_term_scm))
|
||||
@ -1661,11 +1642,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||
/* id type */
|
||||
scm = SCM_CAR (query_term_scm);
|
||||
query_term_scm = SCM_CDR (query_term_scm);
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm);
|
||||
id_type = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
id_type = (QofIdType) gnc_scm_to_locale_string (scm);
|
||||
|
||||
xaccQueryAddGUIDMatch (q, &guid, id_type, QOF_QUERY_OR);
|
||||
g_free ((void *) id_type);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <glib.h>
|
||||
#include <libguile.h>
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "swig-runtime.h"
|
||||
#include "glib-helpers.h"
|
||||
|
||||
@ -128,14 +129,12 @@ gnc_scm_to_glist_string(SCM list)
|
||||
{
|
||||
if (scm_is_string(SCM_CAR(list)))
|
||||
{
|
||||
char * str;
|
||||
gchar * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (SCM_CAR(list));
|
||||
str = gnc_scm_to_locale_string (SCM_CAR(list));
|
||||
if (str)
|
||||
glist = g_list_prepend (glist, g_strdup (str));
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
}
|
||||
list = SCM_CDR (list);
|
||||
}
|
||||
@ -152,14 +151,12 @@ gnc_scm_to_gslist_string(SCM list)
|
||||
{
|
||||
if (scm_is_string(SCM_CAR(list)))
|
||||
{
|
||||
char * str;
|
||||
gchar * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (SCM_CAR(list));
|
||||
str = gnc_scm_to_locale_string (SCM_CAR(list));
|
||||
if (str)
|
||||
gslist = g_slist_prepend (gslist, g_strdup (str));
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
}
|
||||
list = SCM_CDR (list);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "kvp-scm.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "swig-runtime.h"
|
||||
|
||||
/* NOTE: There are some problems with this approach. Currently,
|
||||
@ -48,11 +49,9 @@ gnc_scm_to_kvp_value_ptr(SCM val)
|
||||
{
|
||||
gchar *newstr;
|
||||
KvpValue *ret;
|
||||
scm_dynwind_begin (0);
|
||||
newstr = scm_to_locale_string (val);
|
||||
newstr = gnc_scm_to_locale_string (val);
|
||||
ret = kvp_value_new_string(newstr);
|
||||
scm_dynwind_free (newstr);
|
||||
scm_dynwind_end ();
|
||||
g_free (newstr);
|
||||
return ret;
|
||||
}
|
||||
else if (SWIG_IsPointerOfType(val, SWIG_TypeQuery("_p_KvpFrame")))
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "guile-util.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "option-util.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-date-format.h"
|
||||
@ -2171,14 +2172,8 @@ gnc_option_set_ui_value_string (GNCOption *option, gboolean use_default,
|
||||
if (scm_is_string(value))
|
||||
{
|
||||
const gchar *string;
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
string = gnc_scm_to_locale_string (value);
|
||||
gtk_entry_set_text(GTK_ENTRY(widget), string);
|
||||
g_free ((gpointer *) string);
|
||||
return FALSE;
|
||||
@ -2201,14 +2196,8 @@ gnc_option_set_ui_value_text (GNCOption *option, gboolean use_default,
|
||||
if (scm_is_string(value))
|
||||
{
|
||||
const gchar *string;
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
string = gnc_scm_to_locale_string (value);
|
||||
gtk_text_buffer_set_text (buffer, string, scm_c_string_length(value));
|
||||
g_free ((gpointer *) string);
|
||||
return FALSE;
|
||||
@ -2481,14 +2470,8 @@ gnc_option_set_ui_value_font (GNCOption *option, gboolean use_default,
|
||||
if (scm_is_string(value))
|
||||
{
|
||||
const gchar *string;
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
string = gnc_scm_to_locale_string (value);
|
||||
if ((string != NULL) && (*string != '\0'))
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
|
||||
@ -2509,14 +2492,8 @@ gnc_option_set_ui_value_pixmap (GNCOption *option, gboolean use_default,
|
||||
if (scm_is_string(value))
|
||||
{
|
||||
const gchar *string;
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (value);
|
||||
string = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
string = gnc_scm_to_locale_string (value);
|
||||
if (string && *string)
|
||||
{
|
||||
gchar *test;
|
||||
|
@ -171,22 +171,15 @@ gnc_extension_path (SCM extension, char **fullpath)
|
||||
|
||||
if (scm_is_string(item))
|
||||
{
|
||||
char* s;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
s = scm_to_locale_string(item);
|
||||
gchar* s;
|
||||
s = gnc_scm_to_locale_string(item);
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
|
||||
strings[i] = g_strdup(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
strings[i] = g_strdup(gettext(s));
|
||||
}
|
||||
scm_dynwind_free (s);
|
||||
scm_dynwind_end ();
|
||||
|
||||
g_free (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <libguile.h>
|
||||
#include "guile-mappings.h"
|
||||
#include "guile-util.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "gnc-ui-util.h"
|
||||
@ -337,37 +338,19 @@ load_txf_info (gint acct_category, TaxInfoDialog *ti_dialog)
|
||||
|
||||
scm = scm_call_3 (getters.form, category, code_scm, tax_entity_type);
|
||||
if (scm_is_string(scm))
|
||||
{
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm);
|
||||
txf_info->form = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
txf_info->form = gnc_scm_to_locale_string(scm);
|
||||
else
|
||||
txf_info->form = g_strdup ("");
|
||||
|
||||
scm = scm_call_3 (getters.description, category, code_scm, tax_entity_type);
|
||||
if (scm_is_string(scm))
|
||||
{
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm);
|
||||
txf_info->description = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
txf_info->description = gnc_scm_to_locale_string(scm);
|
||||
else
|
||||
txf_info->description = g_strdup ("");
|
||||
|
||||
scm = scm_call_2 (getters.help, category, code_scm);
|
||||
if (scm_is_string(scm))
|
||||
{
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm);
|
||||
help_text = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
help_text = gnc_scm_to_locale_string(scm);
|
||||
else
|
||||
help_text = g_strdup ("");
|
||||
|
||||
@ -395,15 +378,8 @@ load_txf_info (gint acct_category, TaxInfoDialog *ti_dialog)
|
||||
line_year = scm_is_bool (SCM_CAR (year_scm)) ? 0 :
|
||||
scm_to_int (SCM_CAR (year_scm));
|
||||
if (scm_is_string((SCM_CAR (SCM_CDR (year_scm)))))
|
||||
{
|
||||
gchar *temp_line;
|
||||
scm_dynwind_begin (0);
|
||||
temp_line = scm_to_locale_string((SCM_CAR (SCM_CDR
|
||||
(year_scm))));
|
||||
line = g_strdup (temp_line);
|
||||
scm_dynwind_free (temp_line);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
line = gnc_scm_to_locale_string((SCM_CAR (SCM_CDR
|
||||
(year_scm))));
|
||||
else
|
||||
line = g_strdup ("");
|
||||
temp2 = g_strdup_printf ("%d", line_year);
|
||||
@ -505,33 +481,19 @@ load_tax_entity_type_list (TaxInfoDialog *ti_dialog)
|
||||
tax_type_info = g_new0 (TaxTypeInfo, 1);
|
||||
|
||||
if (scm_is_symbol(type_scm))
|
||||
str = gnc_scm_symbol_to_locale_string (type_scm);
|
||||
tax_type_info->type_code = gnc_scm_symbol_to_locale_string (type_scm);
|
||||
else
|
||||
str = g_strdup ("");
|
||||
tax_type_info->type_code = g_strdup (str);
|
||||
g_free (str);
|
||||
tax_type_info->type_code = g_strdup ("");
|
||||
|
||||
scm = scm_call_1 (getters.tax_entity_type, type_scm);
|
||||
if (scm_is_string(scm))
|
||||
{
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm);
|
||||
tax_type_info->type = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
tax_type_info->type = gnc_scm_to_locale_string(scm);
|
||||
else
|
||||
tax_type_info->type = g_strdup ("");
|
||||
|
||||
scm = scm_call_1 (getters.tax_entity_desc, type_scm);
|
||||
if (scm_is_string(scm))
|
||||
{
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm);
|
||||
tax_type_info->description = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
tax_type_info->description = gnc_scm_to_locale_string(scm);
|
||||
else
|
||||
tax_type_info->description = g_strdup ("");
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-ui.h" /* for GNC_RESPONSE_NEW */
|
||||
|
||||
enum account_cols
|
||||
@ -92,15 +93,7 @@ acct_tree_add_accts(SCM accts,
|
||||
}
|
||||
|
||||
if (scm_is_string(SCM_CAR(current)))
|
||||
{
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (SCM_CAR(current));
|
||||
compname = g_strdup(str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
compname = gnc_scm_to_locale_string (SCM_CAR(current));
|
||||
else
|
||||
compname = g_strdup("");
|
||||
|
||||
@ -349,15 +342,7 @@ qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
|
||||
/* Set the initial account to be selected. */
|
||||
if (scm_is_string(orig_acct))
|
||||
{
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (orig_acct);
|
||||
wind->selected_name = g_strdup(str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
wind->selected_name = gnc_scm_to_locale_string (orig_acct);
|
||||
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker");
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "option-util.h"
|
||||
#include "window-report.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-report.h"
|
||||
@ -99,7 +100,6 @@ update_report_list(GtkListStore *store, CustomReportDialog *crd)
|
||||
SCM get_names = scm_c_eval_string("gnc:custom-report-template-names");
|
||||
SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid");
|
||||
SCM names;
|
||||
const gchar *name;
|
||||
int i;
|
||||
GtkTreeIter iter;
|
||||
|
||||
@ -116,19 +116,17 @@ update_report_list(GtkListStore *store, CustomReportDialog *crd)
|
||||
in the gtkliststore */
|
||||
for (i = 0; !scm_is_null(names); i++)
|
||||
{
|
||||
char * str;
|
||||
gchar *name;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names), SCM_BOOL_F));
|
||||
name = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
name = gnc_scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names), SCM_BOOL_F));
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter,
|
||||
COL_NAME, name,
|
||||
COL_NUM, i,
|
||||
-1);
|
||||
g_free (name);
|
||||
|
||||
names = SCM_CDR(names);
|
||||
}
|
||||
}
|
||||
@ -277,18 +275,13 @@ delete_custom_report_clicked_cb(GtkWidget *button, gpointer data)
|
||||
|
||||
SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid");
|
||||
SCM guid;
|
||||
gchar* report_name;
|
||||
|
||||
guid = get_custom_report_selection(crd, _("You must select a report to delete."));
|
||||
if (!scm_is_null(guid))
|
||||
{
|
||||
char * str;
|
||||
gchar *report_name;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(scm_call_2(template_menu_name, guid, SCM_BOOL_F));
|
||||
report_name = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
report_name = gnc_scm_to_locale_string(scm_call_2(template_menu_name, guid, SCM_BOOL_F));
|
||||
|
||||
/* we must confirm the user wants to delete their precious custom report! */
|
||||
if (gnc_verify_dialog(crd->dialog, FALSE, "Are you sure you want to delete %s?", report_name))
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "option-util.h"
|
||||
#include "window-report.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-report.h"
|
||||
|
||||
enum available_cols
|
||||
@ -113,7 +114,7 @@ update_display_lists(gnc_column_view_edit * view)
|
||||
SCM_BOOL_F);
|
||||
SCM this_report;
|
||||
SCM selection;
|
||||
const gchar *name;
|
||||
gchar *name;
|
||||
int row, i, id;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
@ -145,21 +146,17 @@ update_display_lists(gnc_column_view_edit * view)
|
||||
{
|
||||
for (i = 0; !scm_is_null(names); names = SCM_CDR(names), i++)
|
||||
{
|
||||
char * str;
|
||||
|
||||
if (scm_is_equal (SCM_CAR(names), selection))
|
||||
row = i;
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names),
|
||||
name = gnc_scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names),
|
||||
SCM_BOOL_F));
|
||||
name = _(g_strdup (str));
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter,
|
||||
AVAILABLE_COL_NAME, name,
|
||||
AVAILABLE_COL_NAME, _(name),
|
||||
AVAILABLE_COL_ROW, i,
|
||||
-1);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -193,27 +190,22 @@ update_display_lists(gnc_column_view_edit * view)
|
||||
{
|
||||
for (i = 0; !scm_is_null(contents); contents = SCM_CDR(contents), i++)
|
||||
{
|
||||
char * str;
|
||||
|
||||
if (scm_is_equal (SCM_CAR(contents), selection))
|
||||
row = i;
|
||||
|
||||
id = scm_to_int(SCM_CAAR(contents));
|
||||
this_report = gnc_report_find(id);
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm_call_1(report_menu_name, this_report));
|
||||
name = _(g_strdup (str));
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
name = gnc_scm_to_locale_string (scm_call_1(report_menu_name, this_report));
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set
|
||||
(store, &iter,
|
||||
CONTENTS_COL_NAME, name,
|
||||
CONTENTS_COL_NAME, _(name),
|
||||
CONTENTS_COL_ROW, i,
|
||||
CONTENTS_COL_REPORT_COLS, scm_to_int(SCM_CADR(SCM_CAR(contents))),
|
||||
CONTENTS_COL_REPORT_ROWS, scm_to_int(SCM_CADDR(SCM_CAR(contents))),
|
||||
-1);
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-gconf-utils.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-html-history.h"
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-html-factory.h"
|
||||
@ -770,13 +771,11 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
}
|
||||
|
||||
key_name = g_strdup_printf(SCHEME_OPTIONS_N, id);
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm_text);
|
||||
str = gnc_scm_to_locale_string (scm_text);
|
||||
text = gnc_guile_strip_comments(str);
|
||||
g_key_file_set_string(key_file, group_name, key_name, text);
|
||||
g_free(text);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
g_free(key_name);
|
||||
}
|
||||
|
||||
@ -787,13 +786,11 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
return;
|
||||
}
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (scm_text);
|
||||
str = gnc_scm_to_locale_string (scm_text);
|
||||
text = gnc_guile_strip_comments(str);
|
||||
g_key_file_set_string(key_file, group_name, SCHEME_OPTIONS, text);
|
||||
g_free(text);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
g_free (str);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
@ -1371,11 +1368,8 @@ gnc_get_export_type_choice (SCM export_types)
|
||||
break;
|
||||
}
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
name = scm_to_locale_string (scm);
|
||||
choices = g_list_prepend (choices, g_strdup (name));
|
||||
scm_dynwind_free (name);
|
||||
scm_dynwind_end ();
|
||||
name = gnc_scm_to_locale_string (scm);
|
||||
choices = g_list_prepend (choices, name);
|
||||
}
|
||||
|
||||
if (!bad)
|
||||
@ -1423,14 +1417,7 @@ gnc_get_export_filename (SCM choice)
|
||||
if (choice == SCM_BOOL_T)
|
||||
type = g_strdup (html_type);
|
||||
else
|
||||
{
|
||||
char * str;
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string(SCM_CAR (choice));
|
||||
type = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
type = gnc_scm_to_locale_string(SCM_CAR (choice));
|
||||
|
||||
/* %s is the type of what is about to be saved, e.g. "HTML". */
|
||||
title = g_strdup_printf (_("Save %s To File"), type);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "dialog-options.h"
|
||||
#include "file-utils.h"
|
||||
#include "gnc-gkeyfile-utils.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-report.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "option-util.h"
|
||||
@ -158,15 +159,7 @@ gnc_report_window_default_params_editor(SCM options, SCM report)
|
||||
{
|
||||
ptr = scm_call_1(get_template_name, ptr);
|
||||
if (scm_is_string(ptr))
|
||||
{
|
||||
char * str;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
str = scm_to_locale_string (ptr);
|
||||
title = g_strdup (str);
|
||||
scm_dynwind_free (str);
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
title = gnc_scm_to_locale_string (ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ gncinclude_HEADERS = \
|
||||
libgncmod_report_system_la_LDFLAGS = -avoid-version
|
||||
|
||||
libgncmod_report_system_la_LIBADD = \
|
||||
${top_builddir}/src/core-utils/libgnc-core-utils.la \
|
||||
${top_builddir}/src/gnc-module/libgnc-module.la \
|
||||
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
|
||||
${GUILE_LIBS} \
|
||||
@ -28,6 +29,7 @@ endif
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/src \
|
||||
-I${top_srcdir}/src/core-utils \
|
||||
-I${top_srcdir}/src/gnc-module \
|
||||
-I${top_srcdir}/src/app-utils \
|
||||
${GLIB_CFLAGS} \
|
||||
|
@ -157,11 +157,7 @@ gnc_run_report (gint report_id, char ** data)
|
||||
if (scm_text == SCM_UNDEFINED || !scm_is_string (scm_text))
|
||||
return FALSE;
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
free_data = scm_to_locale_string (scm_text);
|
||||
*data = g_strdup (free_data);
|
||||
scm_dynwind_free (free_data);
|
||||
scm_dynwind_end ();
|
||||
*data = gnc_scm_to_locale_string (scm_text);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user