From 43f3d912bc900c460294b41848d03e069743483c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Wed, 7 Mar 2007 00:27:50 +0000 Subject: [PATCH] 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 --- src/gnome-utils/dialog-totd.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gnome-utils/dialog-totd.c b/src/gnome-utils/dialog-totd.c index cbb48e4ce4..6803ce7d79 100644 --- a/src/gnome-utils/dialog-totd.c +++ b/src/gnome-utils/dialog-totd.c @@ -144,7 +144,7 @@ gnc_totd_dialog_startup_toggled (GtkToggleButton *button, static gboolean gnc_totd_initialize (void) { - gchar *filename, *contents, *new; + gchar *filename, *contents, *new, *found; gsize length; GError *error; @@ -161,6 +161,24 @@ gnc_totd_initialize (void) 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 */ tip_list = g_strsplit(contents, "\n\n", 0);