r15682 - gnucash/trunk/src/gnome-utils - Fix tip of the day dialog on Windows.
Andreas Köhler
andi5 at cvs.gnucash.org
Tue Mar 6 19:27:52 EST 2007
Author: andi5
Date: 2007-03-06 19:27:50 -0500 (Tue, 06 Mar 2007)
New Revision: 15682
Trac: http://svn.gnucash.org/trac/changeset/15682
Modified:
gnucash/trunk/src/gnome-utils/dialog-totd.c
Log:
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.
Modified: gnucash/trunk/src/gnome-utils/dialog-totd.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-totd.c 2007-03-06 19:57:51 UTC (rev 15681)
+++ gnucash/trunk/src/gnome-utils/dialog-totd.c 2007-03-07 00:27:50 UTC (rev 15682)
@@ -144,7 +144,7 @@
static gboolean
gnc_totd_initialize (void)
{
- gchar *filename, *contents, *new;
+ gchar *filename, *contents, *new, *found;
gsize length;
GError *error;
@@ -161,6 +161,24 @@
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);
More information about the gnucash-changes
mailing list