summaryrefslogtreecommitdiffstats
path: root/info.c
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-03-07 21:16:31 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-07 12:01:47 -0800
commit4401132836fdb8798c4dbe07b5c7ae1e0112f248 (patch)
tree8739129e7ced876a95a013a05a0c64eaaee14ffe /info.c
parent9f6b8ca89a0d8828f2b60b01326f3bd9f021112c (diff)
downloadsubsurface-4401132836fdb8798c4dbe07b5c7ae1e0112f248.tar.gz
Fix potentially broken white space truncation on certain Windows versions
Testing the Planner in Subsurface on a Windows XP SP3 installation, shows corrupted UTF-8 strings in the case of Cyrillic locales, but possibly others as well. Instead limited to the Planner, this affects the entire application. After some examination it appears that <ctype>'s isspace() in MSVC on the tested version of Windows is broken for some UTF-8 characters, after enabling the user locale using: setlocale(LC_ALL, ""); For example, characters such as the Cyrillic capital "BE" are defined as: 0xD091, where isspace() for the first byte returns 0x08, which is the bytemask for C1_SPACE and the character is treated as space. After a byte is treated as space, it is usually discarded from a UTF-8 character/string, where if only one byte left, corrupting the entire string. In Subsurface, usages of string trimming are present in multiple locations, so to make this work try to use GLib's g_ascii_isspace(), which is a locale agnostic version of isspace(). Affected versions of Windows could be everything up to XP SP3, but not apparently Vista. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'info.c')
-rw-r--r--info.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/info.c b/info.c
index 0517eaccb..4a4b41c7d 100644
--- a/info.c
+++ b/info.c
@@ -48,7 +48,7 @@ static int text_changed(const char *old, const char *new)
static const char *skip_space(const char *str)
{
if (str) {
- while (isspace(*str))
+ while (g_ascii_isspace(*str))
str++;
if (!*str)
str = NULL;
@@ -82,7 +82,7 @@ static char *get_combo_box_entry_text(GtkComboBox *combo_box, char **textp, cons
return NULL;
new = get_active_text(combo_box);
- while (isspace(*new))
+ while (g_ascii_isspace(*new))
new++;
/* If the master string didn't change, don't change other dives either! */
if (!text_changed(master,new))
@@ -724,7 +724,7 @@ static gboolean gps_entry_change_cb(GtkEntry *gps, GdkEvent *event, gpointer use
}
/* Otherwise, check if it's all empty.. */
- while (isspace(*string))
+ while (g_ascii_isspace(*string))
string++;
location_update.set_by_hand = !!*string;