gucharmap r1667 - trunk/gucharmap
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gucharmap r1667 - trunk/gucharmap
- Date: Fri, 21 Mar 2008 10:53:12 +0000 (GMT)
Author: chpe
Date: Fri Mar 21 10:53:12 2008
New Revision: 1667
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1667&view=rev
Log:
Fix last-char setting value to correctly read back U+10FFFF.
Modified:
trunk/gucharmap/gucharmap-settings.c
Modified: trunk/gucharmap/gucharmap-settings.c
==============================================================================
--- trunk/gucharmap/gucharmap-settings.c (original)
+++ trunk/gucharmap/gucharmap-settings.c Fri Mar 21 10:53:12 2008
@@ -19,7 +19,9 @@
#include <config.h>
+#include <errno.h>
#include <string.h>
+
#include <glib.h>
#include <glib/gi18n-lib.h>
@@ -172,25 +174,28 @@
gucharmap_settings_get_last_char (void)
{
/* See bug 469053 */
- gchar *str;
- gunichar c;
+ gchar *str, *endptr;
+ guint64 value;
if (!gucharmap_settings_initialized ()) {
return gucharmap_settings_get_locale_character ();
}
str = gconf_client_get_string (client, GCONF_PREFIX"/last_char", NULL);
- if (!str) {
+ if (!str || !g_str_has_prefix (str, "U+")) {
+ g_free (str);
return gucharmap_settings_get_locale_character ();
}
- /* FIXME: use g_ascii_strtoull */
- sscanf (str, "U+%X", &c);
- g_free(str);
- if (c > 0 && c < UNICHAR_MAX)
- return c;
+ endptr = NULL;
+ errno = 0;
+ value = g_ascii_strtoull (str + 2 /* skip the "U+" */, &endptr, 16);
+ if (errno || endptr == str || value > UNICHAR_MAX) {
+ g_free (str);
+ return gucharmap_settings_get_locale_character ();
+ }
- return gucharmap_settings_get_locale_character ();
+ return (gunichar) value;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]