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) {
}
}
+ /* 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) {
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;