diff options
author | Brad King <brad.king@kitware.com> | 2009-02-05 22:09:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-05 22:09:28 (GMT) |
commit | 63d718e9f2366ab01d8e8dbf9c551a28f98e4978 (patch) | |
tree | f484c083be8284b9d140e82b3067957c2357dca8 /Source | |
parent | dc13914cd698b49cbae491c1e1aebbcd44fbe932 (diff) | |
download | CMake-63d718e9f2366ab01d8e8dbf9c551a28f98e4978.zip CMake-63d718e9f2366ab01d8e8dbf9c551a28f98e4978.tar.gz CMake-63d718e9f2366ab01d8e8dbf9c551a28f98e4978.tar.bz2 |
COMP: Avoid warning about signed-char comparison
On some compilers 'char' is signed and is therefore always equal to or
less than 0x7f. In order to avoid the compiler warning we perform the
comparison with an unsigned char type.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmXMLSafe.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index 861d75c..21b6bc3 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -60,7 +60,7 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) char const* last = self.Data + self.Size; for(char const* ci = first; ci != last; ++ci) { - char c = *ci; + unsigned char c = static_cast<unsigned char>(*ci); switch(c) { case '&': os << "&"; break; @@ -74,16 +74,15 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) default: if(c >= 0x20 && c <= 0x7f) { - os.put(c); + os.put(static_cast<char>(c)); } else { // TODO: More complete treatment of program output character // encoding. Instead of escaping these bytes, we should // handle the current locale and its encoding. - unsigned char uc = static_cast<unsigned char>(c); char buf[16]; - sprintf(buf, "&#x%hx;", static_cast<unsigned short>(uc)); + sprintf(buf, "&#x%hx;", static_cast<unsigned short>(c)); os << buf; } break; |