SF.net SVN: geany: [709] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Aug 13 08:36:59 UTC 2006


Revision: 709
Author:   eht16
Date:     2006-08-13 01:36:52 -0700 (Sun, 13 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=709&view=rev

Log Message:
-----------
Use wrappers for converting between utf8 and locale encoding.
Fixed small memory leak.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-12 21:38:36 UTC (rev 708)
+++ trunk/ChangeLog	2006-08-13 08:36:52 UTC (rev 709)
@@ -1,3 +1,10 @@
+2006-08-13  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/document.c:
+   Use wrappers for converting between utf8 and locale encoding.
+   Fixed small memory leak.
+
+
 2006-08-12  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/document.c:

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-08-12 21:38:36 UTC (rev 708)
+++ trunk/src/document.c	2006-08-13 08:36:52 UTC (rev 709)
@@ -429,7 +429,7 @@
 	if (reload)
 	{
 		utf8_filename = g_strdup(doc_list[idx].file_name);
-		locale_filename = g_locale_from_utf8(utf8_filename, -1, NULL, NULL, NULL);
+		locale_filename = utils_get_locale_from_utf8(utf8_filename);
 	}
 	else
 	{
@@ -442,15 +442,7 @@
 
 		// try to get the UTF-8 equivalent for the filename, fallback to filename if error
 		locale_filename = g_strdup(filename);
-		utf8_filename = g_locale_to_utf8(locale_filename, -1, NULL, NULL, &err);
-		if (utf8_filename == NULL)
-		{
-			if (err != NULL) msgwin_status_add("%s (%s)", _("Invalid filename"), err->message);
-			else msgwin_status_add(_("Invalid filename"));
-			utf8_filename = g_strdup(locale_filename);
-			g_error_free(err);
-			err = NULL;	// set to NULL for further usage
-		}
+		utf8_filename = utils_get_utf8_from_locale(locale_filename);
 
 		// if file is already open, switch to it and go
 		idx = document_find_by_filename(utf8_filename, FALSE);
@@ -751,8 +743,9 @@
 	{
 		len = strlen(data);
 	}
-	locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
+	locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
 	fp = fopen(locale_filename, "wb"); // this should fix the windows \n problem
+	g_free(locale_filename);
 	if (fp == NULL)
 	{
 		msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
@@ -1047,7 +1040,7 @@
 
 	if (doc_list[idx].tm_file == NULL)
 	{
-		gchar *locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
+		gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
 		doc_list[idx].tm_file = tm_source_file_new(locale_filename, FALSE,
 												   doc_list[idx].file_type->name);
 		g_free(locale_filename);


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