|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70664 - trunk/boost/property_tree/detail
From: sebastian.redl_at_[hidden]
Date: 2011-03-28 09:32:19
Author: cornedbee
Date: 2011-03-28 09:32:19 EDT (Mon, 28 Mar 2011)
New Revision: 70664
URL: http://svn.boost.org/trac/boost/changeset/70664
Log:
Slightly improve UTF-8 support in INFO parser. Don't crash on non-ASCII sequences.
Text files modified:
trunk/boost/property_tree/detail/info_parser_read.hpp | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
Modified: trunk/boost/property_tree/detail/info_parser_read.hpp
==============================================================================
--- trunk/boost/property_tree/detail/info_parser_read.hpp (original)
+++ trunk/boost/property_tree/detail/info_parser_read.hpp 2011-03-28 09:32:19 EDT (Mon, 28 Mar 2011)
@@ -60,13 +60,24 @@
}
return result;
}
+
+ // Detect whitespace in a not very smart way.
+ template <class Ch>
+ bool is_ascii_space(Ch c)
+ {
+ // Everything outside ASCII is not space.
+ unsigned n = c;
+ if (n > 127)
+ return false;
+ return isspace(c);
+ }
// Advance pointer past whitespace
template<class Ch>
void skip_whitespace(const Ch *&text)
{
using namespace std;
- while (isspace(*text))
+ while (is_ascii_space(*text))
++text;
}
@@ -77,7 +88,7 @@
using namespace std;
skip_whitespace(text);
const Ch *start = text;
- while (!isspace(*text) && *text != Ch(';') && *text != Ch('\0'))
+ while (!is_ascii_space(*text) && *text != Ch(';') && *text != Ch('\0'))
++text;
return expand_escapes(start, text);
}
@@ -91,7 +102,7 @@
const Ch *start = text;
while (*text != Ch('\0') && *text != Ch(';'))
++text;
- while (text > start && isspace(*(text - 1)))
+ while (text > start && is_ascii_space(*(text - 1)))
--text;
return expand_escapes(start, text);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk