[geany/geany-plugins] 28060b: automark: Replace deprecated sci_get_text_range() (#436)

Jiří Techet git-noreply at xxxxx
Sat Dec 10 14:25:43 UTC 2016


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Frank Lanitz <frank at frank.uvena.de>
Date:        Sat, 10 Dec 2016 14:25:43 UTC
Commit:      28060b7fa90141cc7b2a2761af60a535e29b3d09
             https://github.com/geany/geany-plugins/commit/28060b7fa90141cc7b2a2761af60a535e29b3d09

Log Message:
-----------
automark: Replace deprecated sci_get_text_range() (#436)


Modified Paths:
--------------
    automark/src/automark.c

Modified: automark/src/automark.c
22 lines changed, 10 insertions(+), 12 deletions(-)
===================================================================
@@ -80,21 +80,16 @@ search_mark_in_range(
 }
 
 /* based on editor_find_current_word_sciwc from editor.c */
-static void
-get_current_word(ScintillaObject *sci, gchar *word, gsize wordlen)
+static gchar *
+get_current_word(ScintillaObject *sci)
 {
 	gint pos = sci_get_current_position(sci);
 	gint start = SSM(sci, SCI_WORDSTARTPOSITION, pos, TRUE);
 	gint end = SSM(sci, SCI_WORDENDPOSITION, pos, TRUE);
 	
-	if (start == end)
-		*word = 0;
-	else
-	{
-		if ((guint)(end - start) >= wordlen)
-			end = start + (wordlen - 1);
-		sci_get_text_range(sci, start, end, word);
-	}
+	if ((guint)(end - start) >= GEANY_MAX_WORD_LENGTH)
+		end = start + (GEANY_MAX_WORD_LENGTH - 1);
+	return sci_get_contents_range(sci, start, end);
 }
 
 static gboolean
@@ -104,7 +99,7 @@ automark(gpointer user_data)
 	GeanyEditor        *editor = doc->editor;
 	static GeanyEditor *editor_cache = NULL;
 	ScintillaObject    *sci = editor->sci;
-	gchar               text[GEANY_MAX_WORD_LENGTH];
+	gchar              *text;
 	static gchar        text_cache[GEANY_MAX_WORD_LENGTH] = {0};
 	gint                match_flag = SCFIND_MATCHCASE | SCFIND_WHOLEWORD;
 	struct              Sci_TextToFind ttf;
@@ -119,11 +114,12 @@ automark(gpointer user_data)
 	if (sci_has_selection(sci))
 		return FALSE;
 
-	get_current_word(editor->sci, text, sizeof(text));
+	text = get_current_word(editor->sci);
 
 	if (!*text)
 	{
 		editor_indicator_clear(editor, AUTOMARK_INDICATOR);
+		g_free(text);
 		return FALSE;
 	}
 
@@ -147,6 +143,8 @@ automark(gpointer user_data)
 
 	search_mark_in_range(editor, match_flag, &ttf);
 
+	g_free(text);
+
 	return FALSE;
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list