Fix off-by-one bug which hidden the last empty line of a document.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5581 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2011-03-06 17:37:58 +00:00
parent 3ebfcceafe
commit 7e29511228
2 changed files with 13 additions and 8 deletions

View File

@ -20,6 +20,7 @@
Add option to insert line numbers (closes #3197150).
Cleanup.
Use the full filename and add the extension of the export format.
Fix off-by-one bug which hidden the last empty line of a document.
2011-03-05 Colomban Wendling <colomban(at)geany(dot)org>

View File

@ -392,7 +392,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
/* read the document and write the LaTeX code */
body = g_string_new("");
doc_len = sci_get_length(sci);
for (i = 0; i < doc_len; i++)
for (i = 0; i <= doc_len; i++)
{
style = sci_get_style_at(sci, i);
c = sci_get_char_at(sci, i);
@ -421,9 +421,11 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
g_string_append(body, "}\n");
block_open = FALSE;
}
g_string_append_printf(body, "\\style%s{", get_tex_style(style));
block_open = TRUE;
if (i < doc_len)
{
g_string_append_printf(body, "\\style%s{", get_tex_style(style));
block_open = TRUE;
}
}
/* escape the current character if necessary else just add it */
switch (c)
@ -632,7 +634,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
/* read the document and write the HTML body */
body = g_string_new("");
doc_len = sci_get_length(sci);
for (i = 0; i < doc_len; i++)
for (i = 0; i <= doc_len; i++)
{
style = sci_get_style_at(sci, i);
c = sci_get_char_at(sci, i);
@ -661,9 +663,11 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
{
g_string_append(body, "</span>");
}
g_string_append_printf(body, "<span class=\"style_%d\">", style);
span_open = TRUE;
if (i < doc_len)
{
g_string_append_printf(body, "<span class=\"style_%d\">", style);
span_open = TRUE;
}
}
/* escape the current character if necessary else just add it */
switch (c)