SF.net SVN: geany: [1525] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri May 11 13:01:51 UTC 2007


Revision: 1525
          http://svn.sourceforge.net/geany/?rev=1525&view=rev
Author:   ntrel
Date:     2007-05-11 06:01:50 -0700 (Fri, 11 May 2007)

Log Message:
-----------
Prevent double loading of common styles when filetype none is used
before other filetypes.
Replace init_styles() with direct initialization of style_sets.

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-11 12:41:01 UTC (rev 1524)
+++ trunk/ChangeLog	2007-05-11 13:01:50 UTC (rev 1525)
@@ -10,6 +10,10 @@
    Rename 'confdialog' to 'prefs'.
    Move compile time options section into an appendix (most users
    shouldn't change these options).
+ * src/highlighting.c:
+   Prevent double loading of common styles when filetype none is used
+   before other filetypes.
+   Replace init_styles() with direct initialization of style_sets.
 
 
 2007-05-10  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2007-05-11 12:41:01 UTC (rev 1524)
+++ trunk/src/highlighting.c	2007-05-11 13:01:50 UTC (rev 1525)
@@ -48,14 +48,13 @@
 
 typedef struct
 {
-	Style	 *styling;	// array of styles, NULL if not used
+	Style	 *styling;		// array of styles, NULL if not used or uninitialised
 	gchar	**keywords;
-	gchar	 *wordchars;
+	gchar	 *wordchars;	// NULL used for style sets with no styles
 } StyleSet;
 
-// After styleset_common_init, each style_sets[...].* is set to NULL in styleset_init_styles.
 // each filetype has a styleset except GEANY_FILETYPE_ALL
-static StyleSet style_sets[GEANY_MAX_FILE_TYPES - 1];
+static StyleSet style_sets[GEANY_MAX_FILE_TYPES - 1] = {{NULL, NULL, NULL}};
 
 
 enum	// Geany common styling
@@ -323,20 +322,6 @@
 }
 
 
-// called from styleset_common
-static void init_styles()
-{
-	gint i;
-
-	for (i = 0; i < GEANY_MAX_FILE_TYPES - 1; i++)
-	{
-		style_sets[i].styling = NULL;	// styling == NULL used to check init was run for most style sets
-		style_sets[i].keywords = NULL;
-		style_sets[i].wordchars = NULL;	// wordchars == NULL used for style sets with no styles
-	}
-}
-
-
 void styleset_free_styles()
 {
 	gint i;
@@ -370,6 +355,7 @@
 }
 
 
+/* This should only be called from styleset_common(). */
 static void styleset_common_init(void)
 {
 	GKeyFile *config = g_key_file_new();
@@ -430,9 +416,6 @@
 	if (! common_style_set_valid)
 	{
 		styleset_common_init();
-		// As styleset_common is called first for all file types before they are used,
-		// we can init their pointers to NULL here.
-		init_styles();
 		common_style_set_valid = TRUE;
 	}
 
@@ -1999,13 +1982,10 @@
 
 	SSM(sci, SCI_SETLEXER, SCLEX_NULL, 0);
 
-	if (style_sets[GEANY_FILETYPES_ALL].styling == NULL)
-		styleset_common_init();
+	styleset_common(sci, 5, ft_id);
 
 	set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_ALL, GCS_DEFAULT);
 
-	styleset_common(sci, 5, ft_id);
-
 	SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) common_style_set.wordchars);
 }
 


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