Fix tip of the day dialog on Windows.

On Windows, entries in tip_of_the_day.list are separated by five
newlines.  This led to empty strings in the dialog that got translated
to the head part of xy.po.  Fix this by replacing all substrings of its
contents of more than two newlines by \n\n and also removing leading and
trailing \n\n.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15682 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-03-07 00:27:50 +00:00
parent 19bb7be296
commit 43f3d912bc

View File

@ -144,7 +144,7 @@ gnc_totd_dialog_startup_toggled (GtkToggleButton *button,
static gboolean static gboolean
gnc_totd_initialize (void) gnc_totd_initialize (void)
{ {
gchar *filename, *contents, *new; gchar *filename, *contents, *new, *found;
gsize length; gsize length;
GError *error; GError *error;
@ -161,6 +161,24 @@ gnc_totd_initialize (void)
return FALSE; return FALSE;
} }
/* Replace maximal substrings of more than two newlines by \n\n,
* remove leading and trailing \n\n */
while ((found = strstr(contents, "\n\n\n")) != NULL) {
*found++ = '\0';
while (*found == '\n') found++;
if (*contents && *found) {
/* put \n\n between the two nonempty parts */
new = g_strdup_printf("%s\n\n%s", contents, found);
g_free(contents);
contents = new;
} else if (*found) {
/* remove leading newlines */
new = g_strdup(found);
g_free(contents);
contents = new;
}
}
/* Split into multiple strings */ /* Split into multiple strings */
tip_list = g_strsplit(contents, "\n\n", 0); tip_list = g_strsplit(contents, "\n\n", 0);