mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
Move gnc_guile_strip_comments to core-utils and normalize its name to
gnc_scm_strip_comments Also make it a true convenience functions by doing the conversion from an scm string to a c string internally. This saves the caller a manual conversion step. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22687 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
feb2eac9e4
commit
365237aec4
@ -949,32 +949,6 @@ gnc_get_credit_string(GNCAccountType account_type)
|
||||
}
|
||||
|
||||
|
||||
/* Clean up a scheme options string for use in a key/value file.
|
||||
* This function removes all full line comments, removes all blank
|
||||
* lines, and removes all leading/trailing white space. */
|
||||
gchar *gnc_guile_strip_comments (const gchar *raw_text)
|
||||
{
|
||||
gchar *text, **splits;
|
||||
gint i, j;
|
||||
|
||||
splits = g_strsplit(raw_text, "\n", -1);
|
||||
for (i = j = 0; splits[i]; i++)
|
||||
{
|
||||
if ((splits[i][0] == ';') || (splits[i][0] == '\0'))
|
||||
{
|
||||
g_free(splits[i]);
|
||||
continue;
|
||||
}
|
||||
splits[j++] = g_strstrip(splits[i]);
|
||||
}
|
||||
splits[j] = NULL;
|
||||
|
||||
text = g_strjoinv(" ", splits);
|
||||
g_strfreev(splits);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
on_child_exit (GPid pid, gint status, gpointer data)
|
||||
{
|
||||
|
@ -83,15 +83,6 @@ int gnc_trans_scm_get_num_splits(SCM trans_scm);
|
||||
char * gnc_get_debit_string(GNCAccountType account_type);
|
||||
char * gnc_get_credit_string(GNCAccountType account_type);
|
||||
|
||||
/** Clean up a scheme options string for use in a key/value file.
|
||||
* This function removes all full line comments, removes all blank
|
||||
* lines, and removes all leading/trailing white space.
|
||||
*
|
||||
* @note: This function does not correctly handle comments that occur
|
||||
* at the end of a line. Fortunately there aren't any such
|
||||
* comments. */
|
||||
gchar *gnc_guile_strip_comments (const gchar *text);
|
||||
|
||||
/** An opaque process structure returned by gnc_spawn_process_async. */
|
||||
typedef struct _Process Process;
|
||||
|
||||
|
@ -255,3 +255,31 @@ gnc_scm_call_1_to_vector(SCM func, SCM arg)
|
||||
|
||||
return SCM_UNDEFINED;
|
||||
}
|
||||
|
||||
|
||||
/* Clean up a scheme options string for use in a key/value file.
|
||||
* This function removes all full line comments, removes all blank
|
||||
* lines, and removes all leading/trailing white space. */
|
||||
gchar *gnc_scm_strip_comments (SCM scm_text)
|
||||
{
|
||||
gchar *raw_text, *text, **splits;
|
||||
gint i, j;
|
||||
|
||||
raw_text = gnc_scm_to_locale_string (scm_text);
|
||||
splits = g_strsplit(raw_text, "\n", -1);
|
||||
for (i = j = 0; splits[i]; i++)
|
||||
{
|
||||
if ((splits[i][0] == ';') || (splits[i][0] == '\0'))
|
||||
{
|
||||
g_free(splits[i]);
|
||||
continue;
|
||||
}
|
||||
splits[j++] = g_strstrip(splits[i]);
|
||||
}
|
||||
splits[j] = NULL;
|
||||
|
||||
text = g_strjoinv(" ", splits);
|
||||
g_free (raw_text);
|
||||
g_strfreev(splits);
|
||||
return text;
|
||||
}
|
||||
|
@ -55,4 +55,13 @@ SCM gnc_scm_call_1_to_vector(SCM func, SCM arg);
|
||||
#define gnc_guile_call1_to_list gnc_scm_call_1_to_list
|
||||
#define gnc_guile_call1_to_vector gnc_scm_call_1_to_vector
|
||||
|
||||
/** Clean up a scheme options string for use in a key/value file.
|
||||
* This function removes all full line comments, removes all blank
|
||||
* lines, and removes all leading/trailing white space.
|
||||
*
|
||||
* @note: This function does not correctly handle comments that occur
|
||||
* at the end of a line. Fortunately there aren't any such
|
||||
* comments. */
|
||||
gchar *gnc_scm_strip_comments (SCM scm_text);
|
||||
|
||||
#endif
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-window.h"
|
||||
#include "guile-util.h"
|
||||
#include "option-util.h"
|
||||
#include "window-report.h"
|
||||
#include "swig-runtime.h"
|
||||
@ -732,7 +731,6 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
SCM get_embedded_list, embedded, item, tmp_report;
|
||||
gint count, id;
|
||||
gchar *text, *key_name;
|
||||
char * str;
|
||||
|
||||
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REPORT(plugin_page));
|
||||
g_return_if_fail (key_file != NULL);
|
||||
@ -771,11 +769,9 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
}
|
||||
|
||||
key_name = g_strdup_printf(SCHEME_OPTIONS_N, id);
|
||||
str = gnc_scm_to_locale_string (scm_text);
|
||||
text = gnc_guile_strip_comments(str);
|
||||
text = gnc_scm_strip_comments(scm_text);
|
||||
g_key_file_set_string(key_file, group_name, key_name, text);
|
||||
g_free(text);
|
||||
g_free (str);
|
||||
g_free(key_name);
|
||||
}
|
||||
|
||||
@ -786,11 +782,9 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
|
||||
return;
|
||||
}
|
||||
|
||||
str = gnc_scm_to_locale_string (scm_text);
|
||||
text = gnc_guile_strip_comments(str);
|
||||
text = gnc_scm_strip_comments(scm_text);
|
||||
g_key_file_set_string(key_file, group_name, SCHEME_OPTIONS, text);
|
||||
g_free(text);
|
||||
g_free (str);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user