Follow-up to r19999: Refactor guile version-safe scm_to_locale_string into gnc function.

(Yay, I made r20000 :-)

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20000 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2010-12-30 11:41:33 +00:00
parent 6af446e0d7
commit 6cbd67d180
2 changed files with 22 additions and 51 deletions
+17 -51
View File
@@ -163,17 +163,7 @@ gnc_guile_call1_to_string(SCM func, SCM arg)
if (scm_is_string(value))
{
char* x;
gchar* s;
x = scm_to_locale_string(value);
/* scm_to_locale_string() returns a malloc'ed string in
guile-1.8 (but not in guile-1.6). Copy to a
g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
return gnc_scm_to_locale_string(value);
}
else
{
@@ -662,8 +652,6 @@ char *
gnc_split_scm_get_memo(SCM split_scm)
{
SCM result;
char* x;
gchar* s;
initialize_scm_functions();
@@ -674,14 +662,7 @@ gnc_split_scm_get_memo(SCM split_scm)
if (!scm_is_string(result))
return NULL;
x = scm_to_locale_string(result);
/* scm_to_locale_string() returns a malloc'ed string in
guile-1.8 (but not in guile-1.6).
Copy to a g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
return gnc_scm_to_locale_string(result);
}
@@ -696,8 +677,6 @@ char *
gnc_split_scm_get_action(SCM split_scm)
{
SCM result;
char* x;
gchar* s;
initialize_scm_functions();
@@ -708,14 +687,7 @@ gnc_split_scm_get_action(SCM split_scm)
if (!scm_is_string(result))
return NULL;
x = scm_to_locale_string(result);
/* scm_to_locale_string() returns a malloc'ed string in
guile-1.8 (but not in guile-1.6).
Copy to a g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
return gnc_scm_to_locale_string(result);
}
@@ -1130,8 +1102,6 @@ gnc_get_debit_string(GNCAccountType account_type)
const gchar *string;
SCM result;
SCM arg;
char* x;
gchar* s;
initialize_scm_functions();
@@ -1147,14 +1117,7 @@ gnc_get_debit_string(GNCAccountType account_type)
if (!scm_is_string(result))
return NULL;
x = scm_to_locale_string(result);
/* scm_to_locale_string() returns a malloc'ed string in
guile-1.8 (but not in guile-1.6).
Copy to a g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
return gnc_scm_to_locale_string(result);
}
@@ -1171,8 +1134,6 @@ gnc_get_credit_string(GNCAccountType account_type)
const gchar *string;
SCM result;
SCM arg;
char* x;
gchar* s;
initialize_scm_functions();
@@ -1188,14 +1149,7 @@ gnc_get_credit_string(GNCAccountType account_type)
if (!scm_is_string(result))
return NULL;
x = scm_to_locale_string(result);
/* scm_to_locale_string() returns a malloc'ed string in
guile-1.8 (but not in guile-1.6).
Copy to a g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
return gnc_scm_to_locale_string(result);
}
@@ -1364,3 +1318,15 @@ gnc_parse_time_to_timet(const gchar *s, const gchar *format)
return mktime(&tm);
}
gchar *gnc_scm_to_locale_string(SCM scm_string)
{
gchar* s;
char* x = scm_to_locale_string(scm_string);
/* scm_to_locale_string() returns a malloc'ed string in guile-1.8
(but not in guile-1.6). Copy to a g_malloc'ed one. */
s = g_strdup(x);
gnc_free_scm_locale_string(x);
return s;
}
+5
View File
@@ -41,6 +41,11 @@ SCM gnc_guile_call1_to_list(SCM func, SCM arg);
SCM gnc_guile_list_ref(SCM list, int index);
SCM gnc_guile_call1_to_vector(SCM func, SCM arg);
/** Wrapper around scm_to_locale_string() that returns a newly
* allocated string (even for guile-1.6 version). The caller must
* g_free() the returned string later. */
gchar * gnc_scm_to_locale_string(SCM scm_string);
/* Don't use this to get hold of symbols that are considered private
* to a given module unless the C code you're writing is considered
* part of that module. */