aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25
diff options
context:
space:
mode:
authorCameron Cawley2019-07-24 15:23:02 +0100
committerFilippos Karapetis2019-07-24 22:47:40 +0300
commit090588fb41fbd2399d840266fbe9cae1e0517c4e (patch)
tree390763a85b456c6c7a36ac08b3dc75dea8596308 /engines/sword25
parent30edabf589953d701db118bf7085e372755c8c75 (diff)
downloadscummvm-rg350-090588fb41fbd2399d840266fbe9cae1e0517c4e.tar.gz
scummvm-rg350-090588fb41fbd2399d840266fbe9cae1e0517c4e.tar.bz2
scummvm-rg350-090588fb41fbd2399d840266fbe9cae1e0517c4e.zip
SWORD25: LUA: Remove direct use of ctype.h functions
Diffstat (limited to 'engines/sword25')
-rw-r--r--engines/sword25/util/lua/llex.cpp5
-rw-r--r--engines/sword25/util/lua/lstrlib.cpp37
2 files changed, 19 insertions, 23 deletions
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp
index ebda9ffbdf..ac9006ec3c 100644
--- a/engines/sword25/util/lua/llex.cpp
+++ b/engines/sword25/util/lua/llex.cpp
@@ -4,9 +4,6 @@
** See Copyright Notice in lua.h
*/
-// FIXME: Do not directly use iscntrl from ctype.h.
-#define FORBIDDEN_SYMBOL_EXCEPTION_iscntrl
-
#include "common/util.h"
#define llex_c
@@ -78,7 +75,7 @@ void luaX_init (lua_State *L) {
const char *luaX_token2str (LexState *ls, int token) {
if (token < FIRST_RESERVED) {
lua_assert(token == cast(unsigned char, token));
- return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
+ return (Common::isCntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
luaO_pushfstring(ls->L, "%c", token);
}
else
diff --git a/engines/sword25/util/lua/lstrlib.cpp b/engines/sword25/util/lua/lstrlib.cpp
index 78122030f9..719ab4d8b2 100644
--- a/engines/sword25/util/lua/lstrlib.cpp
+++ b/engines/sword25/util/lua/lstrlib.cpp
@@ -4,8 +4,7 @@
** See Copyright Notice in lua.h
*/
-
-#define FORBIDDEN_SYMBOL_EXCEPTION_ctype_h
+#include "common/util.h"
#define lstrlib_c
#define LUA_LIB
@@ -221,19 +220,19 @@ static const char *classend (MatchState *ms, const char *p) {
static int match_class (int c, int cl) {
int res;
switch (tolower(cl)) {
- case 'a' : res = isalpha(c); break;
- case 'c' : res = iscntrl(c); break;
- case 'd' : res = isdigit(c); break;
- case 'l' : res = islower(c); break;
- case 'p' : res = ispunct(c); break;
- case 's' : res = isspace(c); break;
- case 'u' : res = isupper(c); break;
- case 'w' : res = isalnum(c); break;
- case 'x' : res = isxdigit(c); break;
+ case 'a' : res = Common::isAlpha(c); break;
+ case 'c' : res = Common::isCntrl(c); break;
+ case 'd' : res = Common::isDigit(c); break;
+ case 'l' : res = Common::isLower(c); break;
+ case 'p' : res = Common::isPunct(c); break;
+ case 's' : res = Common::isSpace(c); break;
+ case 'u' : res = Common::isUpper(c); break;
+ case 'w' : res = Common::isAlnum(c); break;
+ case 'x' : res = Common::isXDigit(c); break;
case 'z' : res = (c == 0); break;
default: return (cl == c);
}
- return (islower(cl) ? res : !res);
+ return (Common::isLower(cl) ? res : !res);
}
@@ -389,7 +388,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) {
p=ep; goto init; /* else return match(ms, s, ep); */
}
default: {
- if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
+ if (Common::isDigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
s = match_capture(ms, s, uchar(*(p+1)));
if (s == NULL) return NULL;
p+=2; goto init; /* else return match(ms, s, p+2) */
@@ -591,7 +590,7 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
luaL_addchar(b, news[i]);
else {
i++; /* skip ESC */
- if (!isdigit(uchar(news[i])))
+ if (!Common::isDigit(uchar(news[i])))
luaL_addchar(b, news[i]);
else if (news[i] == '0')
luaL_addlstring(b, s, e - s);
@@ -722,14 +721,14 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
luaL_error(L, "invalid format (repeated flags)");
- if (isdigit(uchar(*p))) p++; /* skip width */
- if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
+ if (Common::isDigit(uchar(*p))) p++; /* skip width */
+ if (Common::isDigit(uchar(*p))) p++; /* (2 digits at most) */
if (*p == '.') {
p++;
- if (isdigit(uchar(*p))) p++; /* skip precision */
- if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
+ if (Common::isDigit(uchar(*p))) p++; /* skip precision */
+ if (Common::isDigit(uchar(*p))) p++; /* (2 digits at most) */
}
- if (isdigit(uchar(*p)))
+ if (Common::isDigit(uchar(*p)))
luaL_error(L, "invalid format (width or precision too long)");
*(form++) = '%';
strncpy(form, strfrmt, p - strfrmt + 1);