23 #include "swig-runtime.h" 26 #include "gnc-guile-utils.h" 27 #include "guile-mappings.h" 39 gchar *gnc_scm_to_utf8_string(SCM scm_string)
41 if (scm_is_string (scm_string))
42 return scm_to_utf8_stringn(scm_string, NULL);
45 g_error (
"bad value\n");
63 gchar *gnc_scm_to_locale_string(SCM scm_string)
65 if (scm_is_string (scm_string))
66 return scm_to_locale_string(scm_string);
69 g_error (
"bad value\n");
84 gnc_scm_symbol_to_locale_string(SCM symbol_value)
87 if (scm_is_symbol(symbol_value))
89 SCM string_value = scm_symbol_to_string (symbol_value);
90 if (scm_is_string (string_value))
91 return scm_to_utf8_string (string_value);
95 g_error (
"bad value\n");
110 gnc_scm_call_1_to_string(SCM func, SCM arg)
114 if (scm_is_procedure(func))
116 value = scm_call_1(func, arg);
118 if (scm_is_string(value))
120 return gnc_scm_to_utf8_string(value);
124 g_error (
"bad value\n");
129 g_error (
"not a procedure\n");
147 gnc_scm_call_1_symbol_to_string(SCM func, SCM arg)
151 if (scm_is_procedure(func))
153 symbol_value = scm_call_1(func, arg);
154 return gnc_scm_symbol_to_locale_string (symbol_value);
158 g_error (
"not a procedure\n");
175 gnc_scm_call_1_to_procedure(SCM func, SCM arg)
179 if (scm_is_procedure(func))
181 value = scm_call_1(func, arg);
183 if (scm_is_procedure(value))
187 g_error (
"bad value\n");
192 g_error (
"not a procedure\n");
195 return SCM_UNDEFINED;
209 gnc_scm_call_1_to_list(SCM func, SCM arg)
213 if (scm_is_procedure(func))
215 value = scm_call_1(func, arg);
217 if (scm_is_list(value))
221 g_error (
"bad value\n");
226 g_error (
"not a procedure\n");
229 return SCM_UNDEFINED;
243 gnc_scm_call_1_to_vector(SCM func, SCM arg)
247 if (scm_is_procedure(func))
249 value = scm_call_1(func, arg);
251 if (scm_is_vector(value))
255 g_error (
"bad value\n");
260 g_error (
"not a procedure\n");
263 return SCM_UNDEFINED;
270 gchar *gnc_scm_strip_comments (SCM scm_text)
272 gchar *raw_text, *text, **splits;
275 raw_text = gnc_scm_to_utf8_string (scm_text);
276 splits = g_strsplit(raw_text,
"\n", -1);
277 for (i = j = 0; splits[i]; i++)
279 if ((splits[i][0] ==
';') || (splits[i][0] ==
'\0'))
284 splits[j++] = splits [i];
288 text = g_strjoinv(
" ", splits);