[gtksourceview/wip/fix-warnings] completion-words: fix warnings



commit ef5aebfe2e30a6664460a41356ca9d12c8fd66f9
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Aug 9 16:31:54 2015 +0200

    completion-words: fix warnings

 .../words/gtksourcecompletionwordslibrary.c        |   11 ++++++++---
 .../words/gtksourcecompletionwordsutils.c          |    9 ++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
index 51187bb..8d80a28 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
@@ -120,12 +120,17 @@ iter_match_prefix (GSequenceIter *iter,
                    gint           len)
 {
        GtkSourceCompletionWordsProposal *item;
+       const gchar *proposal_word;
 
        item = gtk_source_completion_words_library_get_proposal (iter);
+       proposal_word = gtk_source_completion_words_proposal_get_word (item);
 
-       return strncmp (gtk_source_completion_words_proposal_get_word (item),
-                       word,
-                       len != -1 ? len : strlen (word)) == 0;
+       if (len == -1)
+       {
+               len = strlen (word);
+       }
+
+       return strncmp (proposal_word, word, len) == 0;
 }
 
 GtkSourceCompletionWordsProposal *
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
index 4108b1f..1f638d9 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
@@ -109,10 +109,13 @@ _gtk_source_completion_words_utils_scan_words (gchar *text,
 
        while (find_next_word (text, &start_idx, &end_idx))
        {
-               gint word_size = end_idx - start_idx;
-               gunichar ch = g_utf8_get_char (text + start_idx);
+               guint word_size;
+               gunichar ch;
+
+               g_assert (end_idx >= start_idx);
 
-               g_assert (word_size >= 0);
+               word_size = end_idx - start_idx;
+               ch = g_utf8_get_char (text + start_idx);
 
                if (word_size >= minimum_word_size &&
                    valid_start_char (ch))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]