From 658080deeda79d20ea40643569fbcb072573e7cf Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 28 Jan 2012 01:15:49 +0100 Subject: ALL: Avoid using is* macros from ctype.h On some systems, passing signed chars to macros like isspace() etc. lead to a runtime error. Hence, mark these macros as forbidden by default, and introduce otherwise equivalent alternatives for them. --- engines/parallaction/dialogue.cpp | 2 +- engines/parallaction/parser_br.cpp | 12 ++++++------ engines/parallaction/parser_ns.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/parallaction') diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index a908152bf8..3bb4404b98 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -381,7 +381,7 @@ protected: } void accumPassword(uint16 ascii) { - if (!isdigit(ascii)) { + if (!isDigit(ascii)) { return; } diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index df53ecca3f..fb6a4102d1 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(static_cast(_tokens[ctxt.nextToken][0])) || _tokens[ctxt.nextToken][0] == '-') { + if (isDigit(_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(static_cast(_tokens[ctxt.nextToken][0])) || _tokens[ctxt.nextToken][0] == '-') { + if (isDigit(_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(static_cast(_tokens[1][1]))) { + if (isDigit(_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(static_cast(_tokens[1][1]))) { + if (isAlpha(_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(static_cast(_tokens[1][1]))) { + if (isDigit(_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(static_cast(str[0])) || str[0] == '-') { + if (isDigit(str[0]) || str[0] == '-') { v.setImmediate(atoi(str)); return; } diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index a73f1558e8..13c42b30e1 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(static_cast(str[0])) || str[0] == '-') { + if (isDigit(str[0]) || str[0] == '-') { v.setImmediate(atoi(str)); return; } -- cgit v1.2.3 From 4f8665fc836898ebf54fc73b1061125b748183bc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 20 Feb 2012 16:03:39 +0100 Subject: COMMON: Move isFoo functions to namespace Common, add doxygen comments --- engines/parallaction/dialogue.cpp | 2 +- engines/parallaction/parser_br.cpp | 12 ++++++------ engines/parallaction/parser_ns.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/parallaction') diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 3bb4404b98..e0bd6a6677 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -381,7 +381,7 @@ protected: } void accumPassword(uint16 ascii) { - if (!isDigit(ascii)) { + if (!Common::isDigit(ascii)) { return; } diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index fb6a4102d1..82940340bc 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 (Common::isDigit(_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 (Common::isDigit(_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 (Common::isDigit(_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 (Common::isAlpha(_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 (Common::isDigit(_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 (Common::isDigit(str[0]) || str[0] == '-') { v.setImmediate(atoi(str)); return; } diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index 13c42b30e1..36b8640a60 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 (Common::isDigit(str[0]) || str[0] == '-') { v.setImmediate(atoi(str)); return; } -- cgit v1.2.3