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.
This commit is contained in:
parent
dc13914cd6
commit
63d718e9f2
|
@ -60,7 +60,7 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self)
|
||||||
char const* last = self.Data + self.Size;
|
char const* last = self.Data + self.Size;
|
||||||
for(char const* ci = first; ci != last; ++ci)
|
for(char const* ci = first; ci != last; ++ci)
|
||||||
{
|
{
|
||||||
char c = *ci;
|
unsigned char c = static_cast<unsigned char>(*ci);
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '&': os << "&"; break;
|
case '&': os << "&"; break;
|
||||||
|
@ -74,16 +74,15 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self)
|
||||||
default:
|
default:
|
||||||
if(c >= 0x20 && c <= 0x7f)
|
if(c >= 0x20 && c <= 0x7f)
|
||||||
{
|
{
|
||||||
os.put(c);
|
os.put(static_cast<char>(c));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: More complete treatment of program output character
|
// TODO: More complete treatment of program output character
|
||||||
// encoding. Instead of escaping these bytes, we should
|
// encoding. Instead of escaping these bytes, we should
|
||||||
// handle the current locale and its encoding.
|
// handle the current locale and its encoding.
|
||||||
unsigned char uc = static_cast<unsigned char>(c);
|
|
||||||
char buf[16];
|
char buf[16];
|
||||||
sprintf(buf, "&#x%hx;", static_cast<unsigned short>(uc));
|
sprintf(buf, "&#x%hx;", static_cast<unsigned short>(c));
|
||||||
os << buf;
|
os << buf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue