Do not discard last empty lines

master
Yevgen Muntyan 2007-11-26 02:45:08 -06:00
parent 1d477b367c
commit 103b32915d
3 changed files with 10 additions and 22 deletions

View File

@ -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;

View File

@ -6,6 +6,9 @@ from moo.utils import _
class PyCmd(moo.edit.Command):
def __init__(self, code, options):
moo.edit.Command.__init__(self)
if code and code[-1] != '\n' and code[-1] != '\r':
self.code = code + '\n'
else:
self.code = code
self.set_options(options)

View File

@ -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, NULL);
return (char**) g_ptr_array_free (array, FALSE);
}