aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLittleboy2011-06-23 05:42:48 -0400
committerLittleboy2011-06-23 08:52:52 -0400
commitb694a78f62a02253bca2a5611314599ae7fce725 (patch)
tree115573b00e3b025ed334f9eadeadfb6161286089
parent7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f (diff)
downloadscummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.tar.gz
scummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.tar.bz2
scummvm-rg350-b694a78f62a02253bca2a5611314599ae7fce725.zip
ANALYSIS: Add static casts to is* functions
This fixes a potential problem with passing char values that would be sign-extended and yield unexpected results. See http://msdn.microsoft.com/en-us/library/ms245348.aspx
-rw-r--r--base/commandLine.cpp2
-rw-r--r--common/config-file.cpp6
-rw-r--r--common/config-manager.cpp6
-rw-r--r--common/str.cpp6
-rw-r--r--common/xmlparser.cpp10
-rw-r--r--common/xmlparser.h2
-rw-r--r--engines/agi/wagparser.cpp4
-rw-r--r--engines/agos/script_pn.cpp8
-rw-r--r--engines/cine/detection.cpp2
-rw-r--r--engines/drascula/interface.cpp2
-rw-r--r--engines/hugo/parser.cpp2
-rw-r--r--engines/hugo/util.cpp2
-rw-r--r--engines/kyra/gui.cpp2
-rw-r--r--engines/m4/dialogs.cpp2
-rw-r--r--engines/parallaction/parser_br.cpp12
-rw-r--r--engines/parallaction/parser_ns.cpp2
-rw-r--r--engines/queen/talk.cpp2
-rw-r--r--engines/sci/engine/kstring.cpp4
-rw-r--r--engines/sci/graphics/text16.cpp2
-rw-r--r--engines/sci/resource.cpp4
-rw-r--r--engines/sci/resource_audio.cpp2
-rw-r--r--engines/scumm/smush/smush_player.cpp4
-rw-r--r--engines/scumm/string.cpp8
-rw-r--r--engines/sky/detection.cpp2
-rw-r--r--engines/sword1/animation.cpp2
-rw-r--r--engines/sword25/util/lua/llex.cpp2
-rw-r--r--engines/touche/menu.cpp2
-rw-r--r--graphics/font.cpp2
28 files changed, 53 insertions, 53 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 6cb858525e..2620d69ba2 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -279,7 +279,7 @@ void registerDefaults() {
// resp. between "--some-option" and "--no-some-option".
#define DO_OPTION_BOOL(shortCmd, longCmd) \
if (isLongCmd ? (!strcmp(s+2, longCmd) || !strcmp(s+2, "no-"longCmd)) : (tolower(s[1]) == shortCmd)) { \
- bool boolValue = (islower(s[1]) != 0); \
+ bool boolValue = (islower(static_cast<unsigned char>(s[1])) != 0); \
s += 2; \
if (isLongCmd) { \
boolValue = !strcmp(s, longCmd); \
diff --git a/common/config-file.cpp b/common/config-file.cpp
index 55941131ac..ea3feff8ae 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -38,7 +38,7 @@ namespace Common {
*/
bool ConfigFile::isValidName(const Common::String &name) {
const char *p = name.c_str();
- while (*p && (isalnum(*p) || *p == '-' || *p == '_' || *p == '.'))
+ while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_' || *p == '.'))
p++;
return *p == 0;
}
@@ -116,7 +116,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
// is, verify that it only consists of alphanumerics,
// periods, dashes and underscores). Mohawk Living Books games
// can have periods in their section names.
- while (*p && (isalnum(*p) || *p == '-' || *p == '_' || *p == '.'))
+ while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_' || *p == '.'))
p++;
if (*p == '\0')
@@ -139,7 +139,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
// Skip leading whitespaces
const char *t = line.c_str();
- while (isspace(*t))
+ while (isspace(static_cast<unsigned char>(*t)))
t++;
// Skip empty lines / lines with only whitespace
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 3941e27cc1..a9d8c89035 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -31,7 +31,7 @@ DECLARE_SINGLETON(Common::ConfigManager);
static bool isValidDomainName(const Common::String &domName) {
const char *p = domName.c_str();
- while (*p && (isalnum(*p) || *p == '-' || *p == '_'))
+ while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_'))
p++;
return *p == 0;
}
@@ -187,7 +187,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// Get the domain name, and check whether it's valid (that
// is, verify that it only consists of alphanumerics,
// dashes and underscores).
- while (*p && (isalnum(*p) || *p == '-' || *p == '_'))
+ while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_'))
p++;
if (*p == '\0')
@@ -205,7 +205,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// Skip leading whitespaces
const char *t = line.c_str();
- while (isspace(*t))
+ while (isspace(static_cast<unsigned char>(*t)))
t++;
// Skip empty lines / lines with only whitespace
diff --git a/common/str.cpp b/common/str.cpp
index a2cd4a0193..32f4b44e79 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -405,7 +405,7 @@ void String::trim() {
makeUnique();
// Trim trailing whitespace
- while (_size >= 1 && isspace(_str[_size - 1]))
+ while (_size >= 1 && isspace(static_cast<unsigned char>(_str[_size - 1])))
--_size;
_str[_size] = 0;
@@ -606,14 +606,14 @@ String operator+(const String &x, char y) {
}
char *ltrim(char *t) {
- while (isspace(*t))
+ while (isspace(static_cast<unsigned char>(*t)))
t++;
return t;
}
char *rtrim(char *t) {
int l = strlen(t) - 1;
- while (l >= 0 && isspace(t[l]))
+ while (l >= 0 && isspace(static_cast<unsigned char>(t[l])))
t[l--] = 0;
return t;
}
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 5217c4e82c..623619914a 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -263,7 +263,7 @@ bool XMLParser::vparseIntegerKey(const char *key, int count, va_list args) {
int *num_ptr;
while (count--) {
- while (isspace(*key))
+ while (isspace(static_cast<unsigned char>(*key)))
key++;
num_ptr = va_arg(args, int*);
@@ -271,7 +271,7 @@ bool XMLParser::vparseIntegerKey(const char *key, int count, va_list args) {
key = parseEnd;
- while (isspace(*key))
+ while (isspace(static_cast<unsigned char>(*key)))
key++;
if (count && *key++ != ',')
@@ -463,10 +463,10 @@ bool XMLParser::parse() {
}
bool XMLParser::skipSpaces() {
- if (!isspace(_char))
+ if (!isspace(static_cast<unsigned char>(_char)))
return false;
- while (_char && isspace(_char))
+ while (_char && isspace(static_cast<unsigned char>(_char)))
_char = _stream->readByte();
return true;
@@ -516,7 +516,7 @@ bool XMLParser::parseToken() {
_char = _stream->readByte();
}
- return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
+ return isspace(static_cast<unsigned char>(_char)) != 0 || _char == '>' || _char == '=' || _char == '/';
}
} // End of namespace Common
diff --git a/common/xmlparser.h b/common/xmlparser.h
index 7923e43a37..40c779b87e 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -294,7 +294,7 @@ protected:
* in their name.
*/
virtual inline bool isValidNameChar(char c) {
- return isalnum(c) || c == '_';
+ return isalnum(static_cast<unsigned char>(c)) || c == '_';
}
/**
diff --git a/engines/agi/wagparser.cpp b/engines/agi/wagparser.cpp
index 14159c0147..39f9e0dd92 100644
--- a/engines/agi/wagparser.cpp
+++ b/engines/agi/wagparser.cpp
@@ -112,11 +112,11 @@ WagFileParser::~WagFileParser() {
bool WagFileParser::checkAgiVersionProperty(const WagProperty &version) const {
if (version.getCode() == WagProperty::PC_INTVERSION && // Must be AGI interpreter version property
version.getSize() >= 3 && // Need at least three characters for a version number like "X.Y"
- isdigit(version.getData()[0]) && // And the first character must be a digit
+ isdigit(static_cast<unsigned char>(version.getData()[0])) && // And the first character must be a digit
(version.getData()[1] == ',' || version.getData()[1] == '.')) { // And the second a comma or a period
for (int i = 2; i < version.getSize(); i++) // And the rest must all be digits
- if (!isdigit(version.getData()[i]))
+ if (!isdigit(static_cast<unsigned char>(version.getData()[i])))
return false; // Bail out if found a non-digit after the decimal point
return true;
diff --git a/engines/agos/script_pn.cpp b/engines/agos/script_pn.cpp
index bde59b71b8..3bd8ce19a3 100644
--- a/engines/agos/script_pn.cpp
+++ b/engines/agos/script_pn.cpp
@@ -465,8 +465,8 @@ void AGOSEngine_PN::opn_opcode35() {
void AGOSEngine_PN::opn_opcode36() {
for (int i = 0; i < _dataBase[57] + 1; ++i)
_wordcp[i] = 0;
- if (isspace(*_inpp))
- while ((*_inpp) && (isspace(*_inpp)))
+ if (isspace(static_cast<unsigned char>(*_inpp)))
+ while ((*_inpp) && (isspace(static_cast<unsigned char>(*_inpp))))
_inpp++;
if (*_inpp == 0) {
setScriptReturn(false);
@@ -480,7 +480,7 @@ void AGOSEngine_PN::opn_opcode36() {
}
int ct = 1;
- while ((*_inpp != '.') && (*_inpp != ',') && (!isspace(*_inpp)) && (*_inpp != '\0') &&
+ while ((*_inpp != '.') && (*_inpp != ',') && (!isspace(static_cast<unsigned char>(*_inpp))) && (*_inpp != '\0') &&
(*_inpp!='"')) {
if (ct < _dataBase[57])
_wordcp[ct++] = *_inpp;
@@ -580,7 +580,7 @@ void AGOSEngine_PN::opn_opcode46() {
return;
}
x++;
- while ((*x != '.') && (*x != ',') && (*x != '"') && (!isspace(*x)) && (*x != '\0'))
+ while ((*x != '.') && (*x != ',') && (*x != '"') && (!isspace(static_cast<unsigned char>(*x))) && (*x != '\0'))
pcf(*x++);
setScriptReturn(true);
}
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index cffeb29418..ba0251520b 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -141,7 +141,7 @@ SaveStateList CineMetaEngine::listSaves(const char *target) const {
for (file = filenames.begin(); file != filenames.end(); ++file) {
// Jump over savegame files that don't end with a digit (e.g. "fw.3" is ok, "fw.a" is not).
- if (!isdigit(file->lastChar()))
+ if (!isdigit(static_cast<unsigned char>(file->lastChar())))
continue;
// Obtain the last digit of the filename, since they correspond to the save slot
diff --git a/engines/drascula/interface.cpp b/engines/drascula/interface.cpp
index eb36baed18..e3a97087c0 100644
--- a/engines/drascula/interface.cpp
+++ b/engines/drascula/interface.cpp
@@ -159,7 +159,7 @@ void DrasculaEngine::enterName() {
key = getScan();
if (key != 0) {
- if (key >= 0 && key <= 0xFF && isalpha(key))
+ if (key >= 0 && key <= 0xFF && isalpha(static_cast<unsigned char>(key)))
select2[v] = tolower(key);
else if ((key >= Common::KEYCODE_0 && key <= Common::KEYCODE_9) || key == Common::KEYCODE_SPACE)
select2[v] = key;
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 5cb97f2dc5..38a8e4e3ff 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -235,7 +235,7 @@ void Parser::charHandler() {
if (_cmdLineIndex >= kMaxLineSize) {
//MessageBeep(MB_ICONASTERISK);
warning("STUB: MessageBeep() - Command line too long");
- } else if (isprint(c)) {
+ } else if (isprint(static_cast<unsigned char>(c))) {
_cmdLine[_cmdLineIndex++] = c;
_cmdLine[_cmdLineIndex] = '\0';
}
diff --git a/engines/hugo/util.cpp b/engines/hugo/util.cpp
index a936a23de1..6dc9890c3a 100644
--- a/engines/hugo/util.cpp
+++ b/engines/hugo/util.cpp
@@ -119,7 +119,7 @@ char *strlwr(char *buffer) {
char *result = buffer;
while (*buffer != '\0') {
- if (isupper(*buffer))
+ if (isupper(static_cast<unsigned char>(*buffer)))
*buffer = tolower(*buffer);
buffer++;
}
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index f58ca0117c..29cbe20b23 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -375,7 +375,7 @@ void GUI::updateSaveList(bool excludeQuickSaves) {
s1 = (*i)[i->size()-3];
s2 = (*i)[i->size()-2];
s3 = (*i)[i->size()-1];
- if (!isdigit(s1) || !isdigit(s2) || !isdigit(s3))
+ if (!isdigit(static_cast<unsigned char>(s1)) || !isdigit(static_cast<unsigned char>(s2)) || !isdigit(static_cast<unsigned char>(s3)))
continue;
s1 -= '0';
s2 -= '0';
diff --git a/engines/m4/dialogs.cpp b/engines/m4/dialogs.cpp
index 390ca711d1..2b2c479673 100644
--- a/engines/m4/dialogs.cpp
+++ b/engines/m4/dialogs.cpp
@@ -265,7 +265,7 @@ void Dialog::setupInputArea() {
*/
bool Dialog::matchCommand(const char *s1, const char *s2) {
bool result = scumm_strnicmp(s1, s2, strlen(s2)) == 0;
- _commandCase = isupper(*s1);
+ _commandCase = isupper(static_cast<unsigned char>(*s1));
return result;
}
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index f53d71caec..df53ecca3f 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -524,14 +524,14 @@ DECLARE_COMMAND_PARSER(location) {
ctxt.cmd->_startPos.x = -1000;
ctxt.cmd->_startPos2.x = -1000;
if (_tokens[ctxt.nextToken][0] != '\0') {
- if (isdigit(_tokens[ctxt.nextToken][0]) || _tokens[ctxt.nextToken][0] == '-') {
+ if (isdigit(static_cast<unsigned char>(_tokens[ctxt.nextToken][0])) || _tokens[ctxt.nextToken][0] == '-') {
ctxt.cmd->_startPos.x = atoi(_tokens[ctxt.nextToken]);
ctxt.nextToken++;
ctxt.cmd->_startPos.y = atoi(_tokens[ctxt.nextToken]);
ctxt.nextToken++;
}
- if (isdigit(_tokens[ctxt.nextToken][0]) || _tokens[ctxt.nextToken][0] == '-') {
+ if (isdigit(static_cast<unsigned char>(_tokens[ctxt.nextToken][0])) || _tokens[ctxt.nextToken][0] == '-') {
ctxt.cmd->_startPos2.x = atoi(_tokens[ctxt.nextToken]);
ctxt.nextToken++;
ctxt.cmd->_startPos2.y = atoi(_tokens[ctxt.nextToken]);
@@ -677,7 +677,7 @@ DECLARE_COMMAND_PARSER(text) {
createCommand(_parser->_lookup);
- if (isdigit(_tokens[1][1])) {
+ if (isdigit(static_cast<unsigned char>(_tokens[1][1]))) {
ctxt.cmd->_zeta0 = atoi(_tokens[1]);
ctxt.nextToken++;
} else {
@@ -714,7 +714,7 @@ DECLARE_COMMAND_PARSER(unary) {
DECLARE_ZONE_PARSER(limits) {
debugC(7, kDebugParser, "ZONE_PARSER(limits) ");
- if (isalpha(_tokens[1][1])) {
+ if (isalpha(static_cast<unsigned char>(_tokens[1][1]))) {
ctxt.z->_flags |= kFlagsAnimLinked;
ctxt.z->_linkedName = _tokens[1];
} else {
@@ -1003,7 +1003,7 @@ DECLARE_INSTRUCTION_PARSER(text) {
int _si = 1;
- if (isdigit(_tokens[1][1])) {
+ if (isdigit(static_cast<unsigned char>(_tokens[1][1]))) {
ctxt.inst->_y = atoi(_tokens[1]);
_si = 2;
} else {
@@ -1066,7 +1066,7 @@ DECLARE_INSTRUCTION_PARSER(endif) {
void ProgramParser_br::parseRValue(ScriptVar &v, const char *str) {
- if (isdigit(str[0]) || str[0] == '-') {
+ if (isdigit(static_cast<unsigned char>(str[0])) || str[0] == '-') {
v.setImmediate(atoi(str));
return;
}
diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp
index 213f0ae191..100b608172 100644
--- a/engines/parallaction/parser_ns.cpp
+++ b/engines/parallaction/parser_ns.cpp
@@ -534,7 +534,7 @@ DECLARE_INSTRUCTION_PARSER(endscript) {
void ProgramParser_ns::parseRValue(ScriptVar &v, const char *str) {
- if (isdigit(str[0]) || str[0] == '-') {
+ if (isdigit(static_cast<unsigned char>(str[0])) || str[0] == '-') {
v.setImmediate(atoi(str));
return;
}
diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp
index b83bf60435..1f8d9b29f9 100644
--- a/engines/queen/talk.cpp
+++ b/engines/queen/talk.cpp
@@ -658,7 +658,7 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i
} else if (parameters->animation[0] == 'E') {
// Talking head animation
return;
- } else if (!isdigit(parameters->animation[0])) {
+ } else if (!isdigit(static_cast<unsigned char>(parameters->animation[0]))) {
debug(6, "Error in speak string animation: '%s'", parameters->animation);
return;
} else
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 07b87a7cbc..9f10691767 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -238,14 +238,14 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) {
/* int writelength; -- unused atm */
- if (xfer && (isdigit(xfer) || xfer == '-' || xfer == '=')) {
+ if (xfer && (isdigit(static_cast<unsigned char>(xfer)) || xfer == '-' || xfer == '=')) {
char *destp;
if (xfer == '0')
fillchar = '0';
else if (xfer == '=')
align = ALIGN_CENTER;
- else if (isdigit(xfer) || (xfer == '-'))
+ else if (isdigit(static_cast<unsigned char>(xfer)) || (xfer == '-'))
source--; // Go to start of length argument
str_leng = strtol(source, &destp, 10);
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp
index c2f71a0e54..84547d9828 100644
--- a/engines/sci/graphics/text16.cpp
+++ b/engines/sci/graphics/text16.cpp
@@ -100,7 +100,7 @@ int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int1
// cX -> sets textColor to _textColors[X-1]
curCode = textCode[0];
curCodeParm = textCode[1];
- if (isdigit(curCodeParm)) {
+ if (isdigit(static_cast<unsigned char>(curCodeParm))) {
curCodeParm -= '0';
} else {
curCodeParm = -1;
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index fa70481bdc..f18b6c91f5 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1555,7 +1555,7 @@ void ResourceManager::readResourcePatches() {
name = (*x)->getName();
// SCI1 scheme
- if (isdigit(name[0])) {
+ if (isdigit(static_cast<unsigned char>(name[0]))) {
char *end = 0;
resourceNr = strtol(name.c_str(), &end, 10);
bAdd = (*end == '.'); // Ensure the next character is the period
@@ -1563,7 +1563,7 @@ void ResourceManager::readResourcePatches() {
// SCI0 scheme
int resname_len = strlen(szResType);
if (scumm_strnicmp(name.c_str(), szResType, resname_len) == 0
- && !isalpha(name[resname_len + 1])) {
+ && !isalpha(static_cast<unsigned char>(name[resname_len + 1]))) {
resourceNr = atoi(name.c_str() + resname_len + 1);
bAdd = true;
}
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 032040fc2c..f3a3c8dd5b 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -197,7 +197,7 @@ void ResourceManager::readWaveAudioPatches() {
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
Common::String name = (*x)->getName();
- if (isdigit(name[0]))
+ if (isdigit(static_cast<unsigned char>(name[0])))
processWavePatch(ResourceId(kResourceTypeAudio, atoi(name.c_str())), name);
}
}
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 66502572de..2f4e86bf61 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -90,13 +90,13 @@ public:
assert(def_end != NULL);
char *id_end = def_end;
- while (id_end >= def_start && !isdigit(*(id_end-1))) {
+ while (id_end >= def_start && !isdigit(static_cast<unsigned char>(*(id_end-1)))) {
id_end--;
}
assert(id_end > def_start);
char *id_start = id_end;
- while (isdigit(*(id_start - 1))) {
+ while (isdigit(static_cast<unsigned char>(*(id_start - 1)))) {
id_start--;
}
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index 4b3207c6bf..2d2209c155 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1383,10 +1383,10 @@ void ScummEngine_v7::loadLanguageBundle() {
} else if (*ptr == '#') {
// Number of subtags following a given basetag. We don't need that
// information so we just skip it
- } else if (isdigit(*ptr)) {
+ } else if (isdigit(static_cast<unsigned char>(*ptr))) {
int idx = 0;
// A number (up to three digits)...
- while (isdigit(*ptr)) {
+ while (isdigit(static_cast<unsigned char>(*ptr))) {
idx = idx * 10 + (*ptr - '0');
ptr++;
}
@@ -1424,12 +1424,12 @@ void ScummEngine_v7::loadLanguageBundle() {
for (i = 0; i < _languageIndexSize; i++) {
// First 8 chars in the line give the string ID / 'tag'
int j;
- for (j = 0; j < 8 && !isspace(*ptr); j++, ptr++)
+ for (j = 0; j < 8 && !isspace(static_cast<unsigned char>(*ptr)); j++, ptr++)
_languageIndex[i].tag[j] = toupper(*ptr);
_languageIndex[i].tag[j] = 0;
// After that follows a single space which we skip
- assert(isspace(*ptr));
+ assert(isspace(static_cast<unsigned char>(*ptr)));
ptr++;
// Then comes the translated string: we record an offset to that.
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index f3cce06ad6..a1067496da 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -206,7 +206,7 @@ SaveStateList SkyMetaEngine::listSaves(const char *target) const {
// Extract the extension
Common::String ext = file->c_str() + file->size() - 3;
ext.toUppercase();
- if (isdigit(ext[0]) && isdigit(ext[1]) && isdigit(ext[2])){
+ if (isdigit(static_cast<unsigned char>(ext[0])) && isdigit(static_cast<unsigned char>(ext[1])) && isdigit(static_cast<unsigned char>(ext[2]))){
int slotNum = atoi(ext.c_str());
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 4ce3e2e88d..f19efd2635 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -114,7 +114,7 @@ bool MoviePlayer::load(uint32 id) {
int startFrame = strtoul(ptr, const_cast<char **>(&ptr), 10);
int endFrame = strtoul(ptr, const_cast<char **>(&ptr), 10);
- while (*ptr && isspace(*ptr))
+ while (*ptr && isspace(static_cast<unsigned char>(*ptr)))
ptr++;
if (startFrame > endFrame) {
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp
index 4d73a6a600..b456ee2dfe 100644
--- a/engines/sword25/util/lua/llex.cpp
+++ b/engines/sword25/util/lua/llex.cpp
@@ -188,7 +188,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
sprintf(buf, "%.1f", 1.0);
ls->decpoint = '.';
for (i = 0; buf[i]; i++) {
- if (!isspace(buf[i]) && !isdigit(buf[i])) {
+ if (!isspace(static_cast<unsigned char>(buf[i])) && !isdigit(static_cast<unsigned char>(buf[i]))) {
ls->decpoint = buf[i];
break;
}
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index f469a95803..c58e2f1a33 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -103,7 +103,7 @@ struct MenuData {
void addCharToDescription(int slot, char chr) {
char *description = saveLoadDescriptionsTable[slot];
int descriptionLen = strlen(description);
- if (descriptionLen < 32 && isprint(chr)) {
+ if (descriptionLen < 32 && isprint(static_cast<unsigned char>(chr))) {
description[descriptionLen] = chr;
description[descriptionLen + 1] = 0;
}
diff --git a/graphics/font.cpp b/graphics/font.cpp
index d254c64264..0c180ee47d 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -948,7 +948,7 @@ int Font::wordWrapText(const Common::String &str, int maxWidth, Common::Array<Co
if (lineWidth > 0) {
wrapper.add(line, lineWidth);
// Trim left side
- while (tmpStr.size() && isspace(tmpStr[0])) {
+ while (tmpStr.size() && isspace(static_cast<unsigned char>(tmpStr[0]))) {
tmpWidth -= getCharWidth(tmpStr[0]);
tmpStr.deleteChar(0);
}