[gedit] modelines: check the hash is created



commit bec87a37b6fd770b6e49d02d171318e90fafc2b6
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Mar 9 15:33:19 2012 +0100

    modelines: check the hash is created

 plugins/modelines/modeline-parser.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/plugins/modelines/modeline-parser.c b/plugins/modelines/modeline-parser.c
index aea7e1e..b65c3b0 100644
--- a/plugins/modelines/modeline-parser.c
+++ b/plugins/modelines/modeline-parser.c
@@ -155,7 +155,7 @@ load_language_mappings (void)
 				     fname);
 
 		vim_languages = load_language_mappings_group (mappings, "vim");
-		emacs_languages	= load_language_mappings_group (mappings, "emacs");
+		emacs_languages = load_language_mappings_group (mappings, "emacs");
 		kate_languages = load_language_mappings_group (mappings, "kate");
 	}
 	else
@@ -175,22 +175,23 @@ static gchar *
 get_language_id (const gchar *language_name, GHashTable *mapping)
 {
 	gchar *name;
-	gchar *language_id;
+	gchar *language_id = NULL;
 
 	name = g_ascii_strdown (language_name, -1);
 
-	language_id = g_hash_table_lookup (mapping, name);
-
-	if (language_id != NULL)
-	{
-		g_free (name);
-		return g_strdup (language_id);
-	}
-	else
+	if (mapping != NULL)
 	{
-		/* by default assume that the gtksourcevuew id is the same */
-		return name;
+		language_id = g_hash_table_lookup (mapping, name);
+
+		if (language_id != NULL)
+		{
+			g_free (name);
+			return g_strdup (language_id);
+		}
 	}
+
+	/* by default assume that the gtksourcevuew id is the same */
+	return name;
 }
 
 static gchar *



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