Commit e953531e authored by Sebastien Barre's avatar Sebastien Barre
Browse files

ENH: try to bypass Microsoft assert() on isspace, isalpha, etc.

parent 818e531f
......@@ -836,7 +836,14 @@ kwsys_stl::string SystemTools::CapitalizedWords(const kwsys_stl::string& s)
kwsys_stl::string n(s);
for (size_t i = 0; i < s.size(); i++)
{
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
// MS has an assert that will fail if s[i] < 0; setting
// LC_CTYPE using setlocale() does *not* help. Painful.
if ((int)s[i] >= 0 && isalpha(s[i]) &&
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
#else
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
#endif
{
n[i] = static_cast<kwsys_stl::string::value_type>(toupper(s[i]));
}
......@@ -850,7 +857,14 @@ kwsys_stl::string SystemTools::UnCapitalizedWords(const kwsys_stl::string& s)
kwsys_stl::string n(s);
for (size_t i = 0; i < s.size(); i++)
{
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
// MS has an assert that will fail if s[i] < 0; setting
// LC_CTYPE using setlocale() does *not* help. Painful.
if ((int)s[i] >= 0 && isalpha(s[i]) &&
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
#else
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
#endif
{
n[i] = static_cast<kwsys_stl::string::value_type>(tolower(s[i]));
}
......
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