Moved string splitting to gm-string

This commit is contained in:
Jesse van den Kieboom 2005-12-23 16:09:16 +00:00
parent eed9b8ad0e
commit 44d940db8b
1 changed files with 1 additions and 30 deletions

View File

@ -123,38 +123,9 @@ gm_editor_lines_free(GmEditor *editor) {
editor->priv->lines = NULL;
}
void
gm_editor_add_line(GmEditor *editor, gchar *line, GList **lastptr) {
if (!editor->priv->lines) {
editor->priv->lines = g_list_append(NULL, line);
*lastptr = editor->priv->lines;
} else {
g_list_append(*lastptr, line);
*lastptr = (*lastptr)->next;
}
}
void
gm_editor_set_lines_from_string(GmEditor *editor, gchar const *text) {
gchar *fptr, *line;
GList *lastptr;
gm_editor_lines_free(editor);
while ((fptr = g_utf8_strchr(text, -1, '\n'))) {
line = g_strndup(text, fptr - text);
gm_string_remove_char(line, '\r');
gm_editor_add_line(editor, line, &lastptr);
text = g_utf8_next_char(fptr);
}
if (*text != '\0') {
line = g_strdup(text);
gm_string_remove_char(line, '\r');
gm_editor_add_line(editor, line, &lastptr);
}
editor->priv->lines = gm_string_split(text);
}
void