diff --git a/moo/mooedit/mookeyfile.c b/moo/mooedit/mookeyfile.c index fb7c2a17..1fcfff7a 100644 --- a/moo/mooedit/mookeyfile.c +++ b/moo/mooedit/mookeyfile.c @@ -128,18 +128,7 @@ static gboolean line_is_empty_or_comment (const char *line, gsize line_len) { - gsize i; - - for (i = 0; i < line_len; ++i) - { - if (line[i] == '#') - return TRUE; - - if (!CHAR_IS_SPACE (line[i])) - return FALSE; - } - - return TRUE; + return line_len == 0 || line[0] == '#'; } static guint @@ -169,6 +158,8 @@ line_is_blank (const char *line, { guint i; + *indent = line_len; + for (i = 0; i < line_len; ++i) { if (!CHAR_IS_SPACE (line[i])) @@ -282,12 +273,7 @@ parse_content (Parser *parser, line = parser->ptr; get_line (line, parser->len, &line_len, &next_line); - if (line_is_blank (line, line_len, &indent_here)) - { - g_string_append (content, "\n"); - parser_next_line (parser, next_line); - continue; - } + line_is_blank (line, line_len, &indent_here); if (!indent_here) break; diff --git a/moo/moopython/plugins/pycmd.py b/moo/moopython/plugins/pycmd.py index 1bf7d8f9..3107e13d 100644 --- a/moo/moopython/plugins/pycmd.py +++ b/moo/moopython/plugins/pycmd.py @@ -6,7 +6,10 @@ from moo.utils import _ class PyCmd(moo.edit.Command): def __init__(self, code, options): moo.edit.Command.__init__(self) - self.code = code + if code and code[-1] != '\n' and code[-1] != '\r': + self.code = code + '\n' + else: + self.code = code self.set_options(options) def __set_variable(self, name, value, dic): diff --git a/moo/mooutils/mooutils-misc.c b/moo/mooutils/mooutils-misc.c index 5d63b8de..af5d9a98 100644 --- a/moo/mooutils/mooutils-misc.c +++ b/moo/mooutils/mooutils-misc.c @@ -1816,10 +1816,9 @@ _moo_splitlines (const char *string) } } - if (p > line) - g_ptr_array_add (array, g_strndup (line, p - line)); - + g_ptr_array_add (array, g_strndup (line, p - line)); g_ptr_array_add (array, NULL); + return (char**) g_ptr_array_free (array, FALSE); }