We have seen isspace(0xC3) return true on windows so we need to do something about this.
As a wise man said: Using "isspace()" and friends on anything but the 0-127 range is just fraught with danger, regardless of platform. We remedy this by checking that isascii() says that its a 7-bit ascii character, something isspace() knows how to handle Signed-off-by: Anton Lundin <[email protected]> --- save-xml.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/save-xml.c b/save-xml.c index 9c802b8..0a76753 100644 --- a/save-xml.c +++ b/save-xml.c @@ -35,12 +35,15 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co if (!text) return; /* remove leading and trailing space */ - while (isspace(*text)) + /* We need to combine isascii() with isspace(), + * because we can only trust isspace() with 7-bit ascii, + * on windows for example */ + while (isascii(*text) && isspace(*text)) text++; len = strlen(text); if (!len) return; - while (len && isspace(text[len - 1])) + while (len && isascii(text[len - 1]) && isspace(text[len - 1])) len--; /* strndup would be easier, but that doesn't appear to exist on Windows / Mac */ cleaned = strdup(text); -- 1.9.1 _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
