[gnome-builder] snippets: be more careful with empty strings



commit 66d483278971ba121b34912e83f5447444fb3f28
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 13 18:28:56 2016 -0700

    snippets: be more careful with empty strings

 libide/snippets/ide-source-snippet-context.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/libide/snippets/ide-source-snippet-context.c b/libide/snippets/ide-source-snippet-context.c
index f86222c..a81c1ca 100644
--- a/libide/snippets/ide-source-snippet-context.c
+++ b/libide/snippets/ide-source-snippet-context.c
@@ -146,6 +146,9 @@ filter_capitalize (const gchar *input)
   gunichar c;
   GString *str;
 
+  if (!*input)
+    return g_strdup ("");
+
   c = g_utf8_get_char (input);
 
   if (g_unichar_isupper (c))
@@ -154,7 +157,8 @@ filter_capitalize (const gchar *input)
   str = g_string_new (NULL);
   input = g_utf8_next_char (input);
   g_string_append_unichar (str, g_unichar_toupper (c));
-  g_string_append (str, input);
+  if (*input)
+    g_string_append (str, input);
 
   return g_string_free (str, FALSE);
 }
@@ -473,7 +477,7 @@ scan_forward (const gchar  *input,
 
 gchar *
 ide_source_snippet_context_expand (IdeSourceSnippetContext *context,
-                                  const gchar            *input)
+                                   const gchar             *input)
 {
   const gchar *expand;
   gunichar c;


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