SF.net SVN: geany:[4445] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Nov 24 16:22:14 UTC 2009


Revision: 4445
          http://geany.svn.sourceforge.net/geany/?rev=4445&view=rev
Author:   ntrel
Date:     2009-11-24 16:22:14 +0000 (Tue, 24 Nov 2009)

Log Message:
-----------
Fix setting filetype properties when both the system and the user file
have properties set.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/highlighting.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-11-24 15:47:44 UTC (rev 4444)
+++ trunk/ChangeLog	2009-11-24 16:22:14 UTC (rev 4445)
@@ -3,6 +3,9 @@
  * src/highlighting.c:
    Make stylesets take a ft_id argument so they can be reused fully with
    custom filetypes, so custom styles and keywords can be set.
+ * src/highlighting.c:
+   Fix setting filetype properties when both the system and the user file
+   have properties set.
 
 
 2009-11-23  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2009-11-24 15:47:44 UTC (rev 4444)
+++ trunk/src/highlighting.c	2009-11-24 16:22:14 UTC (rev 4445)
@@ -3114,17 +3114,36 @@
 }
 
 
+#define foreach_strv(strptr, strv) \
+	for (strptr = strv; *strptr; strptr++)
+
 static void read_properties(GeanyFiletype *ft, GKeyFile *config, GKeyFile *configh)
 {
 	gchar group[] = "lexer_properties";
 	gchar **keys = g_key_file_get_keys(config, group, NULL, NULL);
+	gchar **keysh = g_key_file_get_keys(configh, group, NULL, NULL);
 
+	/* move/merge keysh into keys */
 	if (!keys)
-		keys = g_key_file_get_keys(configh, group, NULL, NULL);
+		keys = keysh;
+	else if (keysh)
+	{
+		gchar **strv = g_new0(gchar*, g_strv_length(keys) + g_strv_length(keysh) + 1);
+		gchar **read, **write = strv;
 
+		/* may have same key in each, but home will override so it's OK */
+		foreach_strv(read, keys)
+			*write++ = *read;
+		foreach_strv(read, keysh)
+			*write++ = *read;
+		g_free(keys);
+		g_free(keysh);
+		keys = strv;
+	}
+
 	if (keys)
 	{
-		gchar **values = g_new0(gchar*, g_strv_length(keys));
+		gchar **values = g_new0(gchar*, g_strv_length(keys) + 1);
 
 		style_sets[ft->id].property_keys = keys;
 		style_sets[ft->id].property_values = values;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list