mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
19bb7be296
commit
43f3d912bc
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user