aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/util
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/util')
-rw-r--r--engines/sword25/util/lua/lbaselib.cpp7
-rw-r--r--engines/sword25/util/lua/llex.cpp26
-rw-r--r--engines/sword25/util/lua/lobject.cpp8
-rw-r--r--engines/sword25/util/lua/lstrlib.cpp2
-rw-r--r--engines/sword25/util/lua/luaconf.h5
-rw-r--r--engines/sword25/util/lua/scummvm_file.cpp2
-rw-r--r--engines/sword25/util/pluto/pluto.cpp26
7 files changed, 34 insertions, 42 deletions
diff --git a/engines/sword25/util/lua/lbaselib.cpp b/engines/sword25/util/lua/lbaselib.cpp
index 3f0b645164..659c61d956 100644
--- a/engines/sword25/util/lua/lbaselib.cpp
+++ b/engines/sword25/util/lua/lbaselib.cpp
@@ -6,10 +6,7 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "common/util.h"
#define lbaselib_c
#define LUA_LIB
@@ -62,7 +59,7 @@ static int luaB_tonumber (lua_State *L) {
luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
n = strtoul(s1, &s2, base);
if (s1 != s2) { /* at least one valid digit? */
- while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ while (Common::isSpace(*s2)) s2++; /* skip trailing spaces */
if (*s2 == '\0') { /* no invalid trailing characters? */
lua_pushnumber(L, (lua_Number)n);
return 1;
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp
index 464ab3ec15..f8433d3afa 100644
--- a/engines/sword25/util/lua/llex.cpp
+++ b/engines/sword25/util/lua/llex.cpp
@@ -5,9 +5,7 @@
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
+#include "common/util.h"
#define llex_c
#define LUA_CORE
@@ -188,7 +186,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
sprintf(buf, "%.1f", 1.0);
ls->decpoint = '.';
for (i = 0; buf[i]; i++) {
- if (!isspace(static_cast<unsigned char>(buf[i])) && !isdigit(static_cast<unsigned char>(buf[i]))) {
+ if (!Common::isSpace(buf[i]) && !Common::isDigit(buf[i])) {
ls->decpoint = buf[i];
break;
}
@@ -204,13 +202,13 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
/* LUA_NUMBER */
static void read_numeral (LexState *ls, SemInfo *seminfo) {
- lua_assert(isdigit(ls->current));
+ lua_assert(Common::isDigit(ls->current));
do {
save_and_next(ls);
- } while (isdigit(ls->current) || ls->current == '.');
+ } while (Common::isDigit(ls->current) || ls->current == '.');
if (check_next(ls, "Ee")) /* `E'? */
check_next(ls, "+-"); /* optional exponent sign */
- while (isalnum(ls->current) || ls->current == '_')
+ while (Common::isAlnum(ls->current) || ls->current == '_')
save_and_next(ls);
save(ls, '\0');
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
@@ -313,7 +311,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
case '\r': save(ls, '\n'); inclinenumber(ls); continue;
case EOZ: continue; /* will raise an error next loop */
default: {
- if (!isdigit(ls->current))
+ if (!Common::isDigit(ls->current))
save_and_next(ls); /* handles \\, \", \', and \? */
else { /* \xxx */
int i = 0;
@@ -321,7 +319,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
do {
c = 10*c + (ls->current-'0');
next(ls);
- } while (++i<3 && isdigit(ls->current));
+ } while (++i<3 && Common::isDigit(ls->current));
if (c > UCHAR_MAX)
luaX_lexerror(ls, "escape sequence too large", TK_STRING);
save(ls, c);
@@ -412,7 +410,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
return TK_DOTS; /* ... */
else return TK_CONCAT; /* .. */
}
- else if (!isdigit(ls->current)) return '.';
+ else if (!Common::isDigit(ls->current)) return '.';
else {
read_numeral(ls, seminfo);
return TK_NUMBER;
@@ -422,21 +420,21 @@ static int llex (LexState *ls, SemInfo *seminfo) {
return TK_EOS;
}
default: {
- if (isspace(ls->current)) {
+ if (Common::isSpace(ls->current)) {
lua_assert(!currIsNewline(ls));
next(ls);
continue;
}
- else if (isdigit(ls->current)) {
+ else if (Common::isDigit(ls->current)) {
read_numeral(ls, seminfo);
return TK_NUMBER;
}
- else if (isalpha(ls->current) || ls->current == '_') {
+ else if (Common::isAlpha(ls->current) || ls->current == '_') {
/* identifier or reserved word */
TString *ts;
do {
save_and_next(ls);
- } while (isalnum(ls->current) || ls->current == '_');
+ } while (Common::isAlnum(ls->current) || ls->current == '_');
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
luaZ_bufflen(ls->buff));
if (ts->tsv.reserved > 0) /* reserved word? */
diff --git a/engines/sword25/util/lua/lobject.cpp b/engines/sword25/util/lua/lobject.cpp
index 24718931ed..1ffee52556 100644
--- a/engines/sword25/util/lua/lobject.cpp
+++ b/engines/sword25/util/lua/lobject.cpp
@@ -4,11 +4,7 @@
** See Copyright Notice in lua.h
*/
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "common/util.h"
#define lobject_c
#define LUA_CORE
@@ -94,7 +90,7 @@ int luaO_str2d (const char *s, lua_Number *result) {
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
*result = cast_num(strtoul(s, &endptr, 16));
if (*endptr == '\0') return 1; /* most common case */
- while (isspace(cast(unsigned char, *endptr))) endptr++;
+ while (Common::isSpace(*endptr)) endptr++;
if (*endptr != '\0') return 0; /* invalid trailing characters? */
return 1;
}
diff --git a/engines/sword25/util/lua/lstrlib.cpp b/engines/sword25/util/lua/lstrlib.cpp
index bcc869cb98..ed68a2fa00 100644
--- a/engines/sword25/util/lua/lstrlib.cpp
+++ b/engines/sword25/util/lua/lstrlib.cpp
@@ -5,6 +5,8 @@
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_ctype_h
+
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
diff --git a/engines/sword25/util/lua/luaconf.h b/engines/sword25/util/lua/luaconf.h
index f5affe9fd7..53d0f55290 100644
--- a/engines/sword25/util/lua/luaconf.h
+++ b/engines/sword25/util/lua/luaconf.h
@@ -182,8 +182,7 @@
#define LUAI_FUNC static
#define LUAI_DATA /* empty */
-#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
- defined(__ELF__) && !defined(__PLAYSTATION2__)
+#elif GCC_ATLEAST(3, 2) && defined(__ELF__) && !defined(__PLAYSTATION2__)
/*
** The PS2 gcc compiler doesn't like the visibility attribute, so
** we use the normal "extern" definitions in the block below
@@ -643,7 +642,7 @@ union luai_Cast { double l_d; long l_l; };
** CHANGE it if you have a way to implement it in your system.
*/
#define lua_popen(L,c,m) ((void)((void)c, m), \
- luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
+ luaL_error(L, LUA_QL("popen") " not supported"), (FILE *)0)
#define lua_pclose(L,file) ((void)((void)L, file), 0)
/*
diff --git a/engines/sword25/util/lua/scummvm_file.cpp b/engines/sword25/util/lua/scummvm_file.cpp
index 33053a71cb..b5f1388129 100644
--- a/engines/sword25/util/lua/scummvm_file.cpp
+++ b/engines/sword25/util/lua/scummvm_file.cpp
@@ -22,7 +22,7 @@
#include "sword25/util/lua/scummvm_file.h"
#include "common/config-manager.h"
-#include "common/util.h"
+#include "common/language.h"
namespace Sword25 {
diff --git a/engines/sword25/util/pluto/pluto.cpp b/engines/sword25/util/pluto/pluto.cpp
index 957f5af795..d645e5ed2a 100644
--- a/engines/sword25/util/pluto/pluto.cpp
+++ b/engines/sword25/util/pluto/pluto.cpp
@@ -159,7 +159,7 @@ static int persistspecialobject(PersistInfo *pi, int defaction)
lua_pushvalue(pi->L, -3);
/* perms reftbl ... obj mt __persist obj */
#ifdef PLUTO_PASS_USERDATA_TO_PERSIST
- lua_pushlightuserdata(pi->L, (void*)pi->writer);
+ lua_pushlightuserdata(pi->L, (void *)pi->writer);
lua_pushlightuserdata(pi->L, pi->ud);
/* perms reftbl ... obj mt __persist obj ud */
lua_call(pi->L, 3, 1);
@@ -663,7 +663,7 @@ static void persist(PersistInfo *pi)
}
lua_pushvalue(pi->L, -1);
/* perms reftbl ... obj obj */
- lua_pushlightuserdata(pi->L, (void*)(++(pi->counter)));
+ lua_pushlightuserdata(pi->L, (void *)(++(pi->counter)));
/* perms reftbl ... obj obj ref */
lua_rawset(pi->L, 2);
/* perms reftbl ... obj */
@@ -854,7 +854,7 @@ static void registerobject(int ref, UnpersistInfo *upi)
{
/* perms reftbl ... obj */
lua_checkstack(upi->L, 2);
- lua_pushlightuserdata(upi->L, (void*)ref);
+ lua_pushlightuserdata(upi->L, (void *)ref);
/* perms reftbl ... obj ref */
lua_pushvalue(upi->L, -2);
/* perms reftbl ... obj ref obj */
@@ -989,7 +989,7 @@ static void unpersisttable(int ref, UnpersistInfo *upi)
static UpVal *makeupval(lua_State *L, int stackpos)
{
UpVal *uv = pdep_new(L, UpVal);
- pdep_link(L, (GCObject*)uv, LUA_TUPVAL);
+ pdep_link(L, (GCObject *)uv, LUA_TUPVAL);
uv->tt = LUA_TUPVAL;
uv->v = &uv->u.value;
uv->u.l.prev = NULL;
@@ -1025,8 +1025,8 @@ static Proto *makefakeproto(lua_State *L, lu_byte nups)
static void boxupval_start(lua_State *L)
{
LClosure *lcl;
- lcl = (LClosure*)pdep_newLclosure(L, 1, hvalue(&L->l_gt));
- pushclosure(L, (Closure*)lcl);
+ lcl = (LClosure *)pdep_newLclosure(L, 1, hvalue(&L->l_gt));
+ pushclosure(L, (Closure *)lcl);
/* ... func */
lcl->p = makefakeproto(L, 1);
@@ -1053,7 +1053,7 @@ static void unboxupval(lua_State *L)
LClosure *lcl;
UpVal *uv;
- lcl = (LClosure*)clvalue(getobject(L, -1));
+ lcl = (LClosure *)clvalue(getobject(L, -1));
uv = lcl->upvals[0];
lua_pop(L, 1);
/* ... */
@@ -1071,8 +1071,8 @@ static void unpersistfunction(int ref, UnpersistInfo *upi)
verify(LIF(Z,read)(&upi->zio, &nupvalues, sizeof(lu_byte)) == 0);
- lcl = (LClosure*)pdep_newLclosure(upi->L, nupvalues, hvalue(&upi->L->l_gt));
- pushclosure(upi->L, (Closure*)lcl);
+ lcl = (LClosure *)pdep_newLclosure(upi->L, nupvalues, hvalue(&upi->L->l_gt));
+ pushclosure(upi->L, (Closure *)lcl);
/* perms reftbl ... func */
/* Put *some* proto in the closure, before the GC can find it */
@@ -1393,9 +1393,9 @@ static void unpersistthread(int ref, UnpersistInfo *upi)
verify(LIF(Z,read)(&upi->zio, &stackpos, sizeof(size_t)) == 0);
uv->v = L2->stack + stackpos;
- gcunlink(upi->L, (GCObject*)uv);
+ gcunlink(upi->L, (GCObject *)uv);
uv->marked = luaC_white(g);
- *nextslot = (GCObject*)uv;
+ *nextslot = (GCObject *)uv;
nextslot = &uv->next;
uv->u.l.prev = &G(L2)->uvhead;
uv->u.l.next = G(L2)->uvhead.u.l.next;
@@ -1482,7 +1482,7 @@ static int inreftable(lua_State *L, int ref)
int res;
lua_checkstack(L, 1);
/* perms reftbl ... */
- lua_pushlightuserdata(L, (void*)ref);
+ lua_pushlightuserdata(L, (void *)ref);
/* perms reftbl ... ref */
lua_gettable(L, 2);
/* perms reftbl ... obj? */
@@ -1571,7 +1571,7 @@ static void unpersist(UnpersistInfo *upi)
lua_pushnil(upi->L);
/* perms reftbl ... nil */
} else {
- lua_pushlightuserdata(upi->L, (void*)ref);
+ lua_pushlightuserdata(upi->L, (void *)ref);
/* perms reftbl ... ref */
lua_gettable(upi->L, 2);
/* perms reftbl ... obj? */