[glabels] Don't add newline when last line is an empty merge field.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Don't add newline when last line is an empty merge field.
- Date: Tue, 10 Jul 2012 16:45:11 +0000 (UTC)
commit 642a686f03e5be944a153f995c49e44516717a99
Author: Samuel Sieb <samuel-gnome sieb net>
Date: Tue Jul 10 12:39:14 2012 -0400
Don't add newline when last line is an empty merge field.
Fixes bug #679600. Fixes problem by only prepending newlines to lines as they
are added, except on the first line.
src/text-node.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/src/text-node.c b/src/text-node.c
index f9dec9c..2b5cad0 100644
--- a/src/text-node.c
+++ b/src/text-node.c
@@ -220,6 +220,7 @@ gl_text_node_lines_expand (GList *lines,
GList *p_line, *p_node;
glTextNode *text_node;
gchar *text, *old_text, *expanded_node;
+ gboolean first_line = TRUE;
text = g_strdup (""); /* prime pointer for concatenation */
for (p_line = lines; p_line != NULL; p_line = p_line->next) {
@@ -234,6 +235,15 @@ gl_text_node_lines_expand (GList *lines,
}
}
+ /* prepend newline if it's not the first line */
+ if (!first_line) {
+ old_text = text;
+ text = g_strconcat (text, "\n", NULL);
+ g_free (old_text);
+ } else {
+ first_line = FALSE;
+ }
+
/* expand each node */
for (p_node = (GList *) p_line->data; p_node != NULL;
p_node = p_node->next) {
@@ -244,13 +254,6 @@ gl_text_node_lines_expand (GList *lines,
g_free (old_text);
g_free (expanded_node);
}
-
- /* append newline to each line, except last. */
- if ( p_line->next != NULL ) {
- old_text = text;
- text = g_strconcat (text, "\n", NULL);
- g_free (old_text);
- }
}
return text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]