SF.net SVN: geany:[3254] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Nov 19 17:32:24 UTC 2008


Revision: 3254
          http://geany.svn.sourceforge.net/geany/?rev=3254&view=rev
Author:   eht16
Date:     2008-11-19 17:32:24 +0000 (Wed, 19 Nov 2008)

Log Message:
-----------
Fix wrong encoding handling when the chosen encoding was UTF-8 and properly skip any conversions in this case.

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-11-19 17:31:54 UTC (rev 3253)
+++ trunk/ChangeLog	2008-11-19 17:32:24 UTC (rev 3254)
@@ -3,6 +3,8 @@
  * src/search.c:
    Rework search_close_pid() and let it handle the case when the grep
    command was killed externally.
+   Fix wrong encoding handling when the chosen encoding was UTF-8 and
+   properly skip any conversions in this case.
 
 
 2008-11-18  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2008-11-19 17:31:54 UTC (rev 3253)
+++ trunk/src/search.c	2008-11-19 17:32:24 UTC (rev 3254)
@@ -1374,15 +1374,24 @@
 			utf8_msg = NULL;
 
 			g_strstrip(msg);
-			if (! g_utf8_validate(msg, -1, NULL))
+			/* enc is NULL when encoding is set to UTF-8, so we can skip any conversion */
+			if (enc != NULL)
 			{
-				utf8_msg = g_convert(msg, -1, "UTF-8", enc, NULL, NULL, NULL);
+				if (! g_utf8_validate(msg, -1, NULL))
+				{
+					utf8_msg = g_convert(msg, -1, "UTF-8", enc, NULL, NULL, NULL);
+				}
+				if (utf8_msg == NULL)
+					utf8_msg = msg;
 			}
-			if (utf8_msg == NULL)
-				utf8_msg = g_strdup(msg);
+			else
+				utf8_msg = msg;
+
 			msgwin_msg_add(COLOR_BLACK, -1, NULL, utf8_msg);
+
+			if (utf8_msg != msg)
+				g_free(utf8_msg);
 			g_free(msg);
-			g_free(utf8_msg);
 		}
 	}
 	if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
@@ -1404,15 +1413,24 @@
 			utf8_msg = NULL;
 
 			g_strstrip(msg);
-			if (! g_utf8_validate(msg, -1, NULL))
+			/* enc is NULL when encoding is set to UTF-8, so we can skip any conversion */
+			if (enc != NULL)
 			{
-				utf8_msg = g_convert(msg, -1, "UTF-8", enc, NULL, NULL, NULL);
+				if (! g_utf8_validate(msg, -1, NULL))
+				{
+					utf8_msg = g_convert(msg, -1, "UTF-8", enc, NULL, NULL, NULL);
+				}
+				if (utf8_msg == NULL)
+					utf8_msg = msg;
 			}
-			if (utf8_msg == NULL)
-				utf8_msg = g_strdup(msg);
+			else
+				utf8_msg = msg;
+
 			g_warning("Find in Files: %s", utf8_msg);
+
+			if (utf8_msg != msg)
+				g_free(utf8_msg);
 			g_free(msg);
-			g_free(utf8_msg);
 		}
 	}
 	if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))


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