Fix crash while reading Scintilla styles.

Append "_export" to the exported file name when the exported file has the same extension as the source file.	 


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2162 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-01-11 15:02:42 +00:00
parent fd4f40e48d
commit a248c03f18
2 changed files with 20 additions and 5 deletions

View File

@ -5,6 +5,10 @@
Fix crash while reading Scintilla styles. Fix crash while reading Scintilla styles.
Add GTK's progress dialog when printing large documents which also Add GTK's progress dialog when printing large documents which also
provides the ability to cancel a print operation. provides the ability to cancel a print operation.
* plugins/export.c:
Fix crash while reading Scintilla styles.
Append "_export" to the exported file name when the exported file has
the same extension as the source file.
2008-01-10 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-01-10 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -25,6 +25,7 @@
/* Export plugin. */ /* Export plugin. */
#include <ctype.h> #include <ctype.h>
#include <math.h>
#include "geany.h" #include "geany.h"
#include "support.h" #include "support.h"
@ -210,9 +211,17 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
{ {
gchar *base_name = g_path_get_basename(doc_list[idx].file_name); gchar *base_name = g_path_get_basename(doc_list[idx].file_name);
gchar *short_name = utils->remove_ext_from_filename(base_name); gchar *short_name = utils->remove_ext_from_filename(base_name);
gchar *file_name = g_strconcat(short_name, extension, NULL); gchar *file_name;
gchar *locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name); gchar *locale_filename;
gchar *locale_dirname = g_path_get_dirname(locale_filename); gchar *locale_dirname;
gchar *suffix = "";
if (g_str_has_suffix(doc_list[idx].file_name, extension))
suffix = "_export";
file_name = g_strconcat(short_name, suffix, extension, NULL);
locale_filename = utils->get_locale_from_utf8(doc_list[idx].file_name);
locale_dirname = g_path_get_dirname(locale_filename);
// set the current name to base_name.html which probably doesn't exist yet so // set the current name to base_name.html which probably doesn't exist yet so
// gtk_file_chooser_set_filename() can't be used and we need // gtk_file_chooser_set_filename() can't be used and we need
// gtk_file_chooser_set_current_folder() additionally // gtk_file_chooser_set_current_folder() additionally
@ -346,9 +355,10 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
GString *body; GString *body;
GString *cmds; GString *cmds;
GString *latex; GString *latex;
gint style_max = pow(2, scintilla->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
// first read all styles from Scintilla // first read all styles from Scintilla
for (i = 0; i <= STYLE_MAX; i++) for (i = 0; i < style_max; i++)
{ {
styles[i][FORE] = scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0); styles[i][FORE] = scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0); styles[i][BACK] = scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0);
@ -552,9 +562,10 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
GString *body; GString *body;
GString *css; GString *css;
GString *html; GString *html;
gint style_max = pow(2, scintilla->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
// first read all styles from Scintilla // first read all styles from Scintilla
for (i = 0; i <= STYLE_MAX; i++) for (i = 0; i < style_max; i++)
{ {
styles[i][FORE] = ROTATE_RGB(scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0)); styles[i][FORE] = ROTATE_RGB(scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0)); styles[i][BACK] = ROTATE_RGB(scintilla->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0));