SF.net SVN: geany: [554] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Fri Jul 14 10:48:16 UTC 2006


Revision: 554
Author:   eht16
Date:     2006-07-14 03:48:02 -0700 (Fri, 14 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=554&view=rev

Log Message:
-----------
Fixed wrong charset detection on UTF-8 (and maybe other) systems.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/encodings.c
    trunk/src/encodings.h
    trunk/src/utils.c
    trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-14 10:15:12 UTC (rev 553)
+++ trunk/ChangeLog	2006-07-14 10:48:02 UTC (rev 554)
@@ -2,6 +2,10 @@
 
  * src/filetypes.c, src/highlighting.c, tagmanager/tm_tag.c,
    tagmanager/tm_workspace.c: Fixed autocompletion for filetype C++.
+ * src/utils.c: Removed unneeded functions:
+   utils_glist_strings_free() and utils_glist_from_string().
+ * src/encodings.c: Fixed wrong charset detection on UTF-8
+                    (and maybe other) systems.
 
 
 2006-07-13  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/encodings.c
===================================================================
--- trunk/src/encodings.c	2006-07-14 10:15:12 UTC (rev 553)
+++ trunk/src/encodings.c	2006-07-14 10:48:02 UTC (rev 554)
@@ -192,33 +192,17 @@
 
 
 /* Encodings */
-GList *encodings_get_encodings(GList *encoding_strings)
+GList *encodings_get_encodings(void)
 {
 	GList *res = NULL;
+	gint i;
 
-	if (encoding_strings != NULL)
+	for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
 	{
-		GList *tmp;
-		const GeanyEncoding *enc;
-
-		tmp = encoding_strings;
-
-		while (tmp)
-		{
-		      const char *charset = tmp->data;
-
-		      if (strcmp(charset, "current") == 0)
-			      g_get_charset(&charset);
-
-		      g_return_val_if_fail(charset != NULL, NULL);
-		      enc = encodings_get_from_charset(charset);
-
-		      if (enc != NULL)
-				res = g_list_append(res, (gpointer)enc);
-
-		      tmp = g_list_next(tmp);
-		}
+		if (&encodings[i] != NULL)
+			res = g_list_append(res, (gpointer)&encodings[i]);
 	}
+
 	return res;
 }
 

Modified: trunk/src/encodings.h
===================================================================
--- trunk/src/encodings.h	2006-07-14 10:15:12 UTC (rev 553)
+++ trunk/src/encodings.h	2006-07-14 10:48:02 UTC (rev 554)
@@ -35,9 +35,9 @@
 
 typedef struct
 {
-  gint   idx;
-  gchar *charset;
-  gchar *name;
+	gint   idx;
+	gchar *charset;
+	gchar *name;
 } GeanyEncoding;
 
 
@@ -48,7 +48,7 @@
 gchar* encodings_to_string(const GeanyEncoding* enc);
 const gchar* encodings_get_charset(const GeanyEncoding* enc);
 
-GList* encodings_get_encodings(GList *encoding_strings);
+GList* encodings_get_encodings(void);
 
 void encodings_init(void);
 

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-07-14 10:15:12 UTC (rev 553)
+++ trunk/src/utils.c	2006-07-14 10:48:02 UTC (rev 554)
@@ -863,11 +863,8 @@
 	GList *encodings = NULL;
 	GList *start;
 	gchar *locale_charset = NULL;
-	GList *encoding_strings;
 
-	encoding_strings = utils_glist_from_string("UTF-8");
-	encodings = encodings_get_encodings(encoding_strings);
-	utils_glist_strings_free(encoding_strings);
+	encodings = encodings_get_encodings();
 
 	if (g_get_charset((const gchar**)&locale_charset) == FALSE)
 	{
@@ -1593,68 +1590,7 @@
 	g_free(replacement);
 }
 
-/* GList of strings operations */
-GList *utils_glist_from_string(const gchar *string)
-{
-	gchar *str, *temp, buff[256];
-	GList *list;
-	gchar *word_start, *word_end;
-	gboolean the_end;
 
-	list = NULL;
-	the_end = FALSE;
-	temp = g_strdup(string);
-	str = temp;
-	if (!str)
-		return NULL;
-
-	while (1)
-	{
-		gint i;
-		gchar *ptr;
-
-		/* Remove leading spaces */
-		while (isspace (*str) && *str != '\0')
-			str++;
-		if (*str == '\0')
-			break;
-
-		/* Find start and end of word */
-		word_start = str;
-		while (!isspace (*str) && *str != '\0')
-			str++;
-		word_end = str;
-
-		/* Copy the word into the buffer */
-		for (ptr = word_start, i = 0; ptr < word_end; ptr++, i++)
-			buff[i] = *ptr;
-		buff[i] = '\0';
-		if (strlen (buff))
-			list = g_list_append(list, g_strdup (buff));
-		if (*str == '\0')
-			break;
-	}
-	if (temp)
-		g_free(temp);
-	return list;
-}
-
-
-/* Free the strings and GList */
-void utils_glist_strings_free(GList *list)
-{
-	GList *node;
-	node = list;
-	while (node)
-	{
-		if (node->data)
-			g_free(node->data);
-		node = g_list_next(node);
-	}
-	g_list_free(list);
-}
-
-
 gchar *utils_get_hostname(void)
 {
 #ifndef HAVE_GETHOSTNAME

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2006-07-14 10:15:12 UTC (rev 553)
+++ trunk/src/utils.h	2006-07-14 10:48:02 UTC (rev 554)
@@ -155,10 +155,6 @@
 
 void utils_replace_tabs(gint idx);
 
-GList *utils_glist_from_string(const gchar *string);
-
-void utils_glist_strings_free(GList * list);
-
 gchar *utils_get_hostname(void);
 
 gint utils_make_settings_dir(const gchar *dir);


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