Commit 2a052b4a authored by Christian Persch's avatar Christian Persch

Make gucharmap_unicode_get_version_string return NULL for unassigned characters,

and fix the one-off indexing for assigned characters.

svn path=/trunk/; revision=1711
parent 4b8abe77
......@@ -454,7 +454,7 @@ set_details (GucharmapCharmap *charmap,
/* Unicode version */
version = gucharmap_get_unicode_version (uc);
if (version)
if (version != GUCHARMAP_UNICODE_VERSION_UNASSIGNED)
insert_vanilla_detail (charmap, buffer, &iter,
_("In Unicode since:"),
gucharmap_unicode_version_to_string (version));
......
......@@ -192,7 +192,7 @@ gucharmap_get_unicode_version (gunichar uc)
gint max = G_N_ELEMENTS (unicode_versions) - 1;
if (uc < unicode_versions[0].start || uc > unicode_versions[max].end)
return GUCHARMAP_UNICODE_VERSION_UNASSIGNED;;
return GUCHARMAP_UNICODE_VERSION_UNASSIGNED;
while (max >= min)
{
......@@ -215,7 +215,10 @@ gucharmap_unicode_version_to_string (GucharmapUnicodeVersion version)
g_return_val_if_fail (version >= GUCHARMAP_UNICODE_VERSION_UNASSIGNED &&
version <= GUCHARMAP_UNICODE_VERSION_LATEST, NULL);
return unicode_version_strings + unicode_version_string_offsets[version];
if (G_UNLIKELY (version == GUCHARMAP_UNICODE_VERSION_UNASSIGNED))
return NULL;
return unicode_version_strings + unicode_version_string_offsets[version - 1];
}
#if ENABLE_UNIHAN
......
......@@ -38,7 +38,8 @@ typedef enum {
GUCHARMAP_UNICODE_VERSION_4_0,
GUCHARMAP_UNICODE_VERSION_4_1,
GUCHARMAP_UNICODE_VERSION_5_0,
GUCHARMAP_UNICODE_VERSION_LATEST = GUCHARMAP_UNICODE_VERSION_5_0 /* private, will move forward with each revision */
GUCHARMAP_UNICODE_VERSION_5_1,
GUCHARMAP_UNICODE_VERSION_LATEST = GUCHARMAP_UNICODE_VERSION_5_1 /* private, will move forward with each revision */
} GucharmapUnicodeVersion;
/* return values are read-only */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment