SF.net SVN: geany: [2121] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Dec 21 16:34:08 UTC 2007
Revision: 2121
http://geany.svn.sourceforge.net/geany/?rev=2121&view=rev
Author: ntrel
Date: 2007-12-21 08:34:07 -0800 (Fri, 21 Dec 2007)
Log Message:
-----------
Make utils_get_utf8_from_locale(), utils_get_locale_from_utf8()
NULL-safe.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-12-21 13:09:09 UTC (rev 2120)
+++ trunk/ChangeLog 2007-12-21 16:34:07 UTC (rev 2121)
@@ -6,6 +6,9 @@
the GtkEntry, use a callback for input text, and have a 'persistent'
option to hide the dialog instead of deleting it, using a combo box
for input text history.
+ * src/utils.c:
+ Make utils_get_utf8_from_locale(), utils_get_locale_from_utf8()
+ NULL-safe.
2007-12-19 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-12-21 13:09:09 UTC (rev 2120)
+++ trunk/src/utils.c 2007-12-21 16:34:07 UTC (rev 2121)
@@ -1384,6 +1384,7 @@
}
+/* Null-safe with fallback encoding conversion. */
gchar *utils_get_locale_from_utf8(const gchar *utf8_text)
{
#ifdef G_OS_WIN32
@@ -1391,13 +1392,19 @@
// which would result in wrongly converted strings
return g_strdup(utf8_text);
#else
- gchar *locale_text = g_locale_from_utf8(utf8_text, -1, NULL, NULL, NULL);
- if (locale_text == NULL) locale_text = g_strdup(utf8_text);
+ gchar *locale_text;
+
+ if (! utf8_text)
+ return NULL;
+ locale_text = g_locale_from_utf8(utf8_text, -1, NULL, NULL, NULL);
+ if (locale_text == NULL)
+ locale_text = g_strdup(utf8_text);
return locale_text;
#endif
}
+/* Null-safe with fallback encoding conversion. */
gchar *utils_get_utf8_from_locale(const gchar *locale_text)
{
#ifdef G_OS_WIN32
@@ -1405,8 +1412,13 @@
// which would result in wrongly converted strings
return g_strdup(locale_text);
#else
- gchar *utf8_text = g_locale_to_utf8(locale_text, -1, NULL, NULL, NULL);
- if (utf8_text == NULL) utf8_text = g_strdup(locale_text);
+ gchar *utf8_text;
+
+ if (! locale_text)
+ return NULL;
+ utf8_text = g_locale_to_utf8(locale_text, -1, NULL, NULL, NULL);
+ if (utf8_text == NULL)
+ utf8_text = g_strdup(locale_text);
return utf8_text;
#endif
}
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