From f701893ef7cdcd130bd83b14c4e647d631b6f966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 25 Sep 2008 18:29:11 +0000 Subject: [PATCH] When using editor_get_eol_char_* functions with an invalid editor object, return the appropriate value according to the eol character preference (just in case). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2999 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 4 ++++ src/editor.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b3a1acd..254803e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,10 @@ src/tools.c: Unify the API in editor.c, all public functions now take a GeanyEditor* object. + * src/editor.c: + When using editor_get_eol_char_* functions with an invalid editor + object, return the appropriate value according to the eol character + preference (just in case). 2008-09-25 Nick Treleaven diff --git a/src/editor.c b/src/editor.c index a15a9054..54602b15 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3445,10 +3445,12 @@ void editor_insert_color(GeanyEditor *editor, const gchar *colour) const gchar *editor_get_eol_char_name(GeanyEditor *editor) { - if (editor == NULL) - return ""; + gint mode = file_prefs.default_eol_character; - switch (sci_get_eol_mode(editor->sci)) + if (editor != NULL) + mode = sci_get_eol_mode(editor->sci); + + switch (mode) { case SC_EOL_CRLF: return _("Win (CRLF)"); break; case SC_EOL_CR: return _("Mac (CR)"); break; @@ -3460,10 +3462,12 @@ const gchar *editor_get_eol_char_name(GeanyEditor *editor) /* returns the end-of-line character(s) length of the specified editor */ gint editor_get_eol_char_len(GeanyEditor *editor) { - if (editor == NULL) - return 0; + gint mode = file_prefs.default_eol_character; - switch (sci_get_eol_mode(editor->sci)) + if (editor != NULL) + mode = sci_get_eol_mode(editor->sci); + + switch (mode) { case SC_EOL_CRLF: return 2; break; default: return 1; break; @@ -3474,10 +3478,12 @@ gint editor_get_eol_char_len(GeanyEditor *editor) /* returns the end-of-line character(s) of the specified editor */ const gchar *editor_get_eol_char(GeanyEditor *editor) { - if (editor == NULL) - return ""; + gint mode = file_prefs.default_eol_character; - switch (sci_get_eol_mode(editor->sci)) + if (editor != NULL) + mode = sci_get_eol_mode(editor->sci); + + switch (mode) { case SC_EOL_CRLF: return "\r\n"; break; case SC_EOL_CR: return "\r"; break;