[Scummvm-git-logs] scummvm master -> 690f9d2a5c0128478d81bc49315fd9774714f093

aquadran noreply at scummvm.org
Thu Jan 6 17:26:38 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
690f9d2a5c GRIM,LUA: Janitorial


Commit: 690f9d2a5c0128478d81bc49315fd9774714f093
    https://github.com/scummvm/scummvm/commit/690f9d2a5c0128478d81bc49315fd9774714f093
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2022-01-06T18:26:30+01:00

Commit Message:
GRIM,LUA: Janitorial

Changed paths:
    engines/grim/lua/lapi.cpp
    engines/grim/lua/lauxlib.h
    engines/grim/lua/lbuffer.cpp
    engines/grim/lua/lbuiltin.cpp
    engines/grim/lua/ldo.cpp
    engines/grim/lua/lfunc.cpp
    engines/grim/lua/lgc.cpp
    engines/grim/lua/liolib.cpp
    engines/grim/lua/llex.cpp
    engines/grim/lua/lmathlib.cpp
    engines/grim/lua/lmem.h
    engines/grim/lua/lobject.cpp
    engines/grim/lua/lobject.h
    engines/grim/lua/lopcodes.h
    engines/grim/lua/lrestore.cpp
    engines/grim/lua/lsave.cpp
    engines/grim/lua/lstate.cpp
    engines/grim/lua/lstate.h
    engines/grim/lua/lstring.cpp
    engines/grim/lua/lstrlib.cpp
    engines/grim/lua/ltable.cpp
    engines/grim/lua/ltask.cpp
    engines/grim/lua/ltm.cpp
    engines/grim/lua/ltm.h
    engines/grim/lua/lua.h
    engines/grim/lua/lualib.h
    engines/grim/lua/lundump.cpp
    engines/grim/lua/lundump.h
    engines/grim/lua/lvm.cpp
    engines/grim/lua/lzio.h


diff --git a/engines/grim/lua/lapi.cpp b/engines/grim/lua/lapi.cpp
index 67d6eed7fdd..66836dc89ad 100644
--- a/engines/grim/lua/lapi.cpp
+++ b/engines/grim/lua/lapi.cpp
@@ -27,8 +27,6 @@ namespace Grim {
 char lua_ident[] = "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
 "$Autores:  " LUA_AUTHORS " $";
 
-
-
 TObject *luaA_Address(lua_Object o) {
 	return Address(o);
 }
@@ -307,7 +305,6 @@ void lua_pushobject(lua_Object o) {
 	}
 }
 
-
 int32 lua_tag(lua_Object lo) {
 	if (lo == LUA_NOOBJECT)
 		return LUA_T_NIL;
@@ -323,7 +320,9 @@ int32 lua_tag(lua_Object lo) {
 			return LUA_T_PROTO;
 		case LUA_T_CMARK:
 			return LUA_T_CPROTO;
-		case LUA_T_CLOSURE: case LUA_T_CLMARK:
+		case LUA_T_CLOSURE:
+			// fall through
+		case LUA_T_CLMARK:
 			return o->value.cl->consts[0].ttype;
 #ifdef LUA_DEBUG
 		case LUA_T_LINE:
@@ -435,7 +434,7 @@ static int32 checkfunc (TObject *o) {
 
 const char *lua_getobjname (lua_Object o, const char **name) {
 	// try to find a name for given function
-	set_normalized(lua_state->stack.top, Address(o)); // to be accessed by "checkfunc
+	set_normalized(lua_state->stack.top, Address(o)); // to be accessed by "checkfunc"
 	*name = luaT_travtagmethods(checkfunc);
 	if (*name)
 		return "tag-method";
@@ -478,7 +477,6 @@ lua_Object lua_getref(int32 r) {
 	return (o ? put_luaObject(o) : LUA_NOOBJECT);
 }
 
-
 #ifdef LUA_COMPAT2_5
 /*
 ** API: set a function as a fallback
diff --git a/engines/grim/lua/lauxlib.h b/engines/grim/lua/lauxlib.h
index 36dd929df64..e1e48bbc588 100644
--- a/engines/grim/lua/lauxlib.h
+++ b/engines/grim/lua/lauxlib.h
@@ -25,8 +25,7 @@ struct luaL_libList {
 
 extern luaL_libList *list_of_libs;
 
-#define luaL_arg_check(cond, numarg, extramsg) if (!(cond)) \
-	luaL_argerror(numarg,extramsg)
+#define luaL_arg_check(cond, numarg, extramsg) if (!(cond)) luaL_argerror(numarg,extramsg)
 
 void luaL_openlib(luaL_reg *l, int32 n);
 void luaL_addlibtolist(luaL_reg *l, int32 n);
diff --git a/engines/grim/lua/lbuffer.cpp b/engines/grim/lua/lbuffer.cpp
index a6767ecb97a..7ae5e03e7c0 100644
--- a/engines/grim/lua/lbuffer.cpp
+++ b/engines/grim/lua/lbuffer.cpp
@@ -16,7 +16,7 @@ namespace Grim {
 **  Auxiliary buffer
 -------------------------------------------------------*/
 
-#define BUFF_STEP	32
+#define BUFF_STEP        32
 
 #define openspace(size)  if (Mbuffnext + (size) > Mbuffsize) Openspace(size)
 
diff --git a/engines/grim/lua/lbuiltin.cpp b/engines/grim/lua/lbuiltin.cpp
index bf99413cc99..be0e93c5886 100644
--- a/engines/grim/lua/lbuiltin.cpp
+++ b/engines/grim/lua/lbuiltin.cpp
@@ -56,11 +56,10 @@ static void nextvar() {
 
 static void foreachvar() {
 	TObject f = *luaA_Address(luaL_functionarg(1));
-	GCnode *g;
 	StkId name = lua_state->Cstack.base++;  // place to keep var name (to avoid GC)
 	ttype(lua_state->stack.stack + name) = LUA_T_NIL;
 	lua_state->stack.top++;
-	for (g = rootglobal.next; g; g = g->next) {
+	for (GCnode *g = rootglobal.next; g; g = g->next) {
 		TaggedString *s = (TaggedString *)g;
 		if (s->globalval.ttype != LUA_T_NIL) {
 			ttype(lua_state->stack.stack + name) = LUA_T_STRING;
@@ -91,8 +90,7 @@ static void next() {
 static void foreach() {
 	TObject t = *luaA_Address(luaL_tablearg(1));
 	TObject f = *luaA_Address(luaL_functionarg(2));
-	int32 i;
-	for (i = 0; i < avalue(&t)->nhash; i++) {
+	for (int32 i = 0; i < avalue(&t)->nhash; i++) {
 		Node *nd = &(avalue(&t)->node[i]);
 		if (ttype(ref(nd)) != LUA_T_NIL && ttype(val(nd)) != LUA_T_NIL) {
 			luaA_pushobject(&f);
@@ -119,6 +117,7 @@ static void internaldostring() {
 static const char *to_string(lua_Object obj) {
 	char *buff = luaL_openspace(30);
 	TObject *o = luaA_Address(obj);
+
 	switch (ttype(o)) {
 	case LUA_T_NUMBER:
 	case LUA_T_STRING:
@@ -199,9 +198,8 @@ static void tonumber() {
 	} else {
 		const char *s = luaL_check_string(1);
 		char *e;
-		int32 n;
 		luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
-		n = (int32)strtol(s, &e, base);
+		int32 n = (int32)strtol(s, &e, base);
 		while (Common::isSpace(*e))
 			e++; // skip trailing spaces
 		if (*e)
diff --git a/engines/grim/lua/ldo.cpp b/engines/grim/lua/ldo.cpp
index 8ce72f6de85..ccbb927cf18 100644
--- a/engines/grim/lua/ldo.cpp
+++ b/engines/grim/lua/ldo.cpp
@@ -39,7 +39,7 @@ namespace Grim {
 #endif
 
 // Extra stack size to run a function: LUA_T_LINE(1), TM calls(2), ...
-#define	EXTRA_STACK	5
+#define EXTRA_STACK     5
 
 /*
 ** Error messages
@@ -49,10 +49,10 @@ void stderrorim() {
 	fprintf(stderr, "lua error: %s\n", lua_getstring(lua_getparam(1)));
 }
 
-#define STACK_UNIT	256
+#define STACK_UNIT      256
 
 // Initial size for CallInfo array
-#define BASIC_CI_SIZE	8
+#define BASIC_CI_SIZE  8
 
 void luaD_init() {
 	ttype(&errorim) = LUA_T_CPROTO;
@@ -80,7 +80,7 @@ void luaD_checkstack(int32 n) {
 ** Adjust stack. Set top to the given value, pushing NILs if needed.
 */
 void luaD_adjusttop(StkId newtop) {
-	int32 diff = newtop-(lua_state->stack.top-lua_state->stack.stack);
+	int32 diff = newtop - (lua_state->stack.top - lua_state->stack.stack);
 	if (diff <= 0)
 		lua_state->stack.top += diff;
 	else {
@@ -285,8 +285,7 @@ int32 luaD_call(StkId base, int32 nResults) {
 }
 
 static void travstack(struct Stack *S, int32 (*fn)(TObject *)) {
-	StkId i;
-	for (i = (S->top - 1) - S->stack; i >= 0; i--)
+	for (StkId i = (S->top - 1) - S->stack; i >= 0; i--)
 		fn(S->stack + i);
 }
 
@@ -294,8 +293,7 @@ static void travstack(struct Stack *S, int32 (*fn)(TObject *)) {
 ** Traverse all objects on lua_state->stack.stack, and all other active stacks
 */
 void luaD_travstack(int32(*fn)(TObject *)) {
-	LState *t;
-	for (t = lua_rootState; t != nullptr; t = t->next) {
+	for (LState *t = lua_rootState; t != nullptr; t = t->next) {
 		travstack(&t->stack, fn);
 	}
 }
@@ -444,14 +442,13 @@ int32 lua_dostring(const char *str) {
 int32 lua_dobuffer(const char *buff, int32 size, const char *name) {
 	char newname[SIZE_PREF + 25];
 	ZIO z;
-	int32 status;
 
 	if (!name) {
 		build_name(buff, newname);
 		name = newname;
 	}
 	luaZ_mopen(&z, buff, size, name);
-	status = do_main(&z, buff[0] == ID_CHUNK);
+	int32 status = do_main(&z, buff[0] == ID_CHUNK);
 	return status;
 }
 
diff --git a/engines/grim/lua/lfunc.cpp b/engines/grim/lua/lfunc.cpp
index 39a290909fa..176ebaf0d8a 100644
--- a/engines/grim/lua/lfunc.cpp
+++ b/engines/grim/lua/lfunc.cpp
@@ -12,11 +12,9 @@
 
 namespace Grim {
 
-#define gcsizeproto(p)	5  /* approximate "weight" for a prototype */
+#define gcsizeproto(p)   5  /* approximate "weight" for a prototype */
 #define gcsizeclosure(c) 1  /* approximate "weight" for a closure */
 
-
-
 Closure *luaF_newclosure(int32 nelems) {
 	Closure *c = (Closure *)luaM_malloc(sizeof(Closure) + nelems * sizeof(TObject));
 	luaO_insertlist(&rootcl, (GCnode *)c);
@@ -54,7 +52,6 @@ void luaF_freeproto(TProtoFunc *l) {
 	}
 }
 
-
 void luaF_freeclosure(Closure *l) {
 	while (l) {
 		Closure *next = (Closure *)l->head.next;
@@ -64,7 +61,6 @@ void luaF_freeclosure(Closure *l) {
 	}
 }
 
-
 /*
 ** Look for n-th local variable at line "line" in function "func".
 ** Returns NULL if not found.
diff --git a/engines/grim/lua/lgc.cpp b/engines/grim/lua/lgc.cpp
index 5ab7866fef7..d791adba985 100644
--- a/engines/grim/lua/lgc.cpp
+++ b/engines/grim/lua/lgc.cpp
@@ -103,8 +103,7 @@ static int32 ismarked(TObject *o) {
 }
 
 static void invalidaterefs() {
-	int32 i;
-	for (i = 0; i < refSize; i++)
+	for (int32 i = 0; i < refSize; i++)
 		if (refArray[i].status == HOLD && !ismarked(&refArray[i].o))
 			refArray[i].status = COLLECTED;
 }
@@ -153,11 +152,10 @@ static void strmark(TaggedString *s) {
 static void protomark(TProtoFunc *f) {
 	if (!f->head.marked) {
 		LocVar *v = f->locvars;
-		int32 i;
 		f->head.marked = 1;
 		if (f->fileName)
 			strmark(f->fileName);
-		for (i = 0; i < f->nconsts; i++)
+		for (int32 i = 0; i < f->nconsts; i++)
 			markobject(&f->consts[i]);
 		if (v) {
 			for (; v->line != -1; v++) {
@@ -170,18 +168,16 @@ static void protomark(TProtoFunc *f) {
 
 static void closuremark(Closure *f) {
 	if (!f->head.marked) {
-		int32 i;
 		f->head.marked = 1;
-		for (i = f->nelems; i >= 0; i--)
+		for (int32 i = f->nelems; i >= 0; i--)
 			markobject(&f->consts[i]);
 	}
 }
 
 static void hashmark(Hash *h) {
 	if (!h->head.marked) {
-		int32 i;
 		h->head.marked = 1;
-		for (i = 0; i < nhash(h); i++) {
+		for (int32 i = 0; i < nhash(h); i++) {
 			Node *n = node(h, i);
 			if (ttype(ref(n)) != LUA_T_NIL) {
 				markobject(&n->ref);
diff --git a/engines/grim/lua/liolib.cpp b/engines/grim/lua/liolib.cpp
index bf517c5f999..b017888103a 100644
--- a/engines/grim/lua/liolib.cpp
+++ b/engines/grim/lua/liolib.cpp
@@ -28,13 +28,13 @@
 
 namespace Grim {
 
-#define CLOSEDTAG	2
-#define IOTAG		1
+#define CLOSEDTAG       2
+#define IOTAG           1
 
-#define FIRSTARG      3  // 1st and 2nd are upvalues
+#define FIRSTARG        3  // 1st and 2nd are upvalues
 
-#define FINPUT		"_INPUT"
-#define FOUTPUT		"_OUTPUT"
+#define FINPUT          "_INPUT"
+#define FOUTPUT         "_OUTPUT"
 
 LuaFile *g_stderr;
 
@@ -399,24 +399,23 @@ static void errorfb() {
 }
 
 static struct luaL_reg iolib[] = {
-	{ "date",			io_date },
-	{ "exit",			io_exit },
-	{ "print_stack",	errorfb }
+	{ "date",        io_date },
+	{ "exit",        io_exit },
+	{ "print_stack", errorfb }
 };
 
 static struct luaL_reg iolibtag[] = {
-	{ "readfrom",	io_readfrom },
-	{ "writeto",	io_writeto },
-	{ "appendto",	io_appendto },
-	{ "read",		io_read },
-	{ "write",		io_write }
+	{ "readfrom",    io_readfrom },
+	{ "writeto",     io_writeto },
+	{ "appendto",    io_appendto },
+	{ "read",        io_read },
+	{ "write",       io_write }
 };
 
 static void openwithtags() {
 	int32 iotag = lua_newtag();
 	int32 closedtag = lua_newtag();
-	uint32 i;
-	for (i = 0; i < sizeof(iolibtag) / sizeof(iolibtag[0]); i++) {
+	for (uint32 i = 0; i < sizeof(iolibtag) / sizeof(iolibtag[0]); i++) {
 		// put both tags as upvalues for these functions
 		lua_pushnumber(iotag);
 		lua_pushnumber(closedtag);
diff --git a/engines/grim/lua/llex.cpp b/engines/grim/lua/llex.cpp
index e6d939d8c5d..ca3b65f73dc 100644
--- a/engines/grim/lua/llex.cpp
+++ b/engines/grim/lua/llex.cpp
@@ -23,7 +23,7 @@ namespace Grim {
 
 int32 lua_debug = 0;
 
-#define next(LS)			(LS->current = zgetc(LS->lex_z))
+#define next(LS)         (LS->current = zgetc(LS->lex_z))
 
 static struct {
 	const char *name;
@@ -71,7 +71,7 @@ void luaX_setinput(ZIO *z) {
 ** =======================================================
 */
 
-#define PRAGMASIZE	20
+#define PRAGMASIZE      20
 
 static void skipspace(LexState *LS) {
 	while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r')
@@ -184,8 +184,8 @@ static void inclinenumber (LexState *LS) {
 ** =======================================================
 */
 
-#define save(c)				luaL_addchar(c)
-#define save_and_next(LS)	(save(LS->current), next(LS))
+#define save(c)                 luaL_addchar(c)
+#define save_and_next(LS)       (save(LS->current), next(LS))
 
 
 char *luaX_lasttoken() {
diff --git a/engines/grim/lua/lmathlib.cpp b/engines/grim/lua/lmathlib.cpp
index 1060a7951ad..a5f704546f6 100644
--- a/engines/grim/lua/lmathlib.cpp
+++ b/engines/grim/lua/lmathlib.cpp
@@ -112,27 +112,27 @@ static void math_randomseed() {
 }
 
 static struct luaL_reg mathlib[] = {
-	{ "abs",	math_abs},
-	{ "sin",	math_sin},
-	{ "cos",	math_cos},
-	{ "tan",	math_tan},
-	{ "asin",	math_asin},
-	{ "acos",	math_acos},
-	{ "atan",	math_atan},
-	{ "ceil",	math_ceil},
-	{ "floor",	math_floor},
-	{ "mod",	math_mod},
-	{ "sqrt",	math_sqrt},
-	{ "min",	math_min},
-	{ "max",	math_max},
-	{ "deg",	math_deg},
-	{ "rad",	math_rad},
-	{ "random",		math_random},
-	{ "randomseed",	math_randomseed}
+	{ "abs",        math_abs},
+	{ "sin",        math_sin},
+	{ "cos",        math_cos},
+	{ "tan",        math_tan},
+	{ "asin",       math_asin},
+	{ "acos",       math_acos},
+	{ "atan",       math_atan},
+	{ "ceil",       math_ceil},
+	{ "floor",      math_floor},
+	{ "mod",        math_mod},
+	{ "sqrt",       math_sqrt},
+	{ "min",        math_min},
+	{ "max",        math_max},
+	{ "deg",        math_deg},
+	{ "rad",        math_rad},
+	{ "random",     math_random},
+	{ "randomseed", math_randomseed}
 };
 
 static luaL_reg powFunc[] = {
-	{ "math_pow",	math_pow }
+	{ "math_pow",   math_pow }
 };
 
 /*
diff --git a/engines/grim/lua/lmem.h b/engines/grim/lua/lmem.h
index 50ff92cabb2..21a6440b2f9 100644
--- a/engines/grim/lua/lmem.h
+++ b/engines/grim/lua/lmem.h
@@ -11,21 +11,21 @@
 namespace Grim {
 
 // memory error messages
-#define codeEM		"code size overflow"
-#define constantEM	"constant table overflow"
-#define refEM		"reference table overflow"
-#define tableEM		"table overflow"
-#define memEM		"not enough memory"
+#define codeEM          "code size overflow"
+#define constantEM      "constant table overflow"
+#define refEM           "reference table overflow"
+#define tableEM         "table overflow"
+#define memEM           "not enough memory"
 
 void *luaM_realloc (void *oldblock, int32 size);
 int32 luaM_growaux (void **block, int32 nelems, int32 size, const char *errormsg, int32 limit);
 
-#define luaM_free(b)						free((b))
-#define luaM_malloc(t)						malloc((t))
-#define luaM_new(t)							((t *)malloc(sizeof(t)))
-#define luaM_newvector(n, t)				((t *)malloc((n) * sizeof(t)))
-#define luaM_growvector(old, n, t, e, l)	(luaM_growaux((void**)old, n, sizeof(t), e, l))
-#define luaM_reallocvector(v, n, t)			((t *)realloc(v,(n) * sizeof(t)))
+#define luaM_free(b)                            free((b))
+#define luaM_malloc(t)                          malloc((t))
+#define luaM_new(t)                             ((t *)malloc(sizeof(t)))
+#define luaM_newvector(n, t)                    ((t *)malloc((n) * sizeof(t)))
+#define luaM_growvector(old, n, t, e, l)        (luaM_growaux((void **)old, n, sizeof(t), e, l))
+#define luaM_reallocvector(v, n, t)             ((t *)realloc(v,(n) * sizeof(t)))
 
 #ifdef LUA_DEBUG
 extern int32 numblocks;
diff --git a/engines/grim/lua/lobject.cpp b/engines/grim/lua/lobject.cpp
index c63e655a246..26478ffbad0 100644
--- a/engines/grim/lua/lobject.cpp
+++ b/engines/grim/lua/lobject.cpp
@@ -29,8 +29,7 @@ static int32 dimensions[] = {
 };
 
 int32 luaO_redimension(int32 oldsize) {
-	int32 i;
-	for (i = 0; dimensions[i] < MAX_INT; i++) {
+	for (int32 i = 0; dimensions[i] < MAX_INT; i++) {
 		if (dimensions[i] > oldsize)
 			return dimensions[i];
 	}
@@ -69,9 +68,7 @@ int32 luaO_equalObj(TObject *t1, TObject *t2) {
 }
 
 int luaO_findstring(const char *name, const char *list[]) {
-	int i;
-
-	for (i = 0; list[i]; i++)
+	for (int i = 0; list[i]; i++)
 		if (strcmp(list[i], name) == 0)
 			return i;
 	return -1;  // name not found
diff --git a/engines/grim/lua/lobject.h b/engines/grim/lua/lobject.h
index d95f1cc0cb8..4261ffced2b 100644
--- a/engines/grim/lua/lobject.h
+++ b/engines/grim/lua/lobject.h
@@ -12,15 +12,15 @@ namespace Grim {
 
 #ifdef LUA_DEBUG
 #include "engines/grim/lua/lauxlib.h"
-#define LUA_INTERNALERROR(s)	luaL_verror("INTERNAL ERROR - %s [%s:%d]", (s), __FILE__, __LINE__)
-#define LUA_ASSERT(c, s)			{ if (!(c)) LUA_INTERNALERROR(s); }
+#define LUA_INTERNALERROR(s)    luaL_verror("INTERNAL ERROR - %s [%s:%d]", (s), __FILE__, __LINE__)
+#define LUA_ASSERT(c, s)        { if (!(c)) LUA_INTERNALERROR(s); }
 #else
-#define LUA_INTERNALERROR(s)	// empty
-#define LUA_ASSERT(c, s)			// empty
+#define LUA_INTERNALERROR(s)    // empty
+#define LUA_ASSERT(c, s)        // empty
 #endif
 
-#define MAX_INT			(2147483647 - 2)  // maximum value of an int (-2 for safety)
-#define MAX_WORD		(65534U)
+#define MAX_INT                 (2147483647 - 2)  // maximum value of an int (-2 for safety)
+#define MAX_WORD                (65534U)
 
 /*
 ** Lua TYPES
@@ -113,9 +113,8 @@ typedef struct LocVar {
 #define clvalue(o)      ((o)->value.cl)
 #define avalue(o)       ((o)->value.a)
 #define fvalue(o)       ((o)->value.f)
-#define tfvalue(o)		((o)->value.tf)
-#define protovalue(o)	((o)->value.cl->consts)
-
+#define tfvalue(o)      ((o)->value.tf)
+#define protovalue(o)   ((o)->value.cl->consts)
 
 /*
 ** Closures
@@ -147,8 +146,8 @@ int32 luaO_redimension(int32 oldsize);
 int luaO_findstring(const char *name, const char *list[]);
 void luaO_insertlist(GCnode *root, GCnode *node);
 
-#define luaO_memup(d, s, n)		memmove(d, s, n)
-#define luaO_memdown(d, s, n)	memmove(d, s, n)
+#define luaO_memup(d, s, n)     memmove(d, s, n)
+#define luaO_memdown(d, s, n)   memmove(d, s, n)
 
 } // end of namespace Grim
 
diff --git a/engines/grim/lua/lopcodes.h b/engines/grim/lua/lopcodes.h
index e050f3d54e7..a24957ac524 100644
--- a/engines/grim/lua/lopcodes.h
+++ b/engines/grim/lua/lopcodes.h
@@ -171,9 +171,9 @@ typedef enum {
 	POP1			//	-		-				-				TOP-=2
 } OpCode;
 
-#define RFIELDS_PER_FLUSH 32	// records (SETMAP)
+#define RFIELDS_PER_FLUSH 32    // records (SETMAP)
 #define LFIELDS_PER_FLUSH 64    // lists (SETLIST)
-#define ZEROVARARG	64
+#define ZEROVARARG        64
 
 } // end of namespace Grim
 
diff --git a/engines/grim/lua/lrestore.cpp b/engines/grim/lua/lrestore.cpp
index ae766eadaab..460510f12f4 100644
--- a/engines/grim/lua/lrestore.cpp
+++ b/engines/grim/lua/lrestore.cpp
@@ -148,7 +148,7 @@ static void recreateObj(TObject *obj) {
 			assert(obj->value.f);
 		}
 	} else if (obj->ttype == LUA_T_NIL || obj->ttype == LUA_T_LINE || obj->ttype == LUA_T_NUMBER ||
-			obj->ttype == LUA_T_TASK || obj->ttype == LUA_T_USERDATA) {
+		   obj->ttype == LUA_T_TASK || obj->ttype == LUA_T_USERDATA) {
 		return;
 	} else {
 		if (obj->value.i == 0)
@@ -405,7 +405,7 @@ void lua_Restore(SaveGame *savedState) {
 		ptr.id = savedState->readLEUint64();
 		tempObj.value.ts = (TaggedString *)makePointerFromId(ptr);
 		recreateObj(&tempObj);
- 		tempString = (TaggedString *)tempObj.value.ts;
+		tempString = (TaggedString *)tempObj.value.ts;
 		assert(tempString);
 		tempListString->head.next = (GCnode *)tempString;
 		tempListString = tempString;
@@ -448,8 +448,7 @@ void lua_Restore(SaveGame *savedState) {
 	Mbuffsize = savedState->readLESint32();
 	Mbuffer = (char *)luaM_malloc(Mbuffsize);
 	savedState->read(Mbuffer, Mbuffsize);
-	int32 MbaseOffset;
-	MbaseOffset = savedState->readLESint32();
+	int32 MbaseOffset = savedState->readLESint32();
 	Mbuffbase = MbaseOffset + Mbuffer;
 	Mbuffnext = savedState->readLESint32();
 
diff --git a/engines/grim/lua/lsave.cpp b/engines/grim/lua/lsave.cpp
index d27bcba272d..5b40d6ef7d8 100644
--- a/engines/grim/lua/lsave.cpp
+++ b/engines/grim/lua/lsave.cpp
@@ -124,7 +124,6 @@ void lua_Save(SaveGame *savedState) {
 	int32 countElements = 0;
 	int32 maxStringLength = 0;
 
-
 	// Check for max length for strings and count them
 	for (i = 0; i < NUM_HASHS; i++) {
 		stringtable *tempStringTable = &string_root[i];
@@ -143,7 +142,6 @@ void lua_Save(SaveGame *savedState) {
 	// save number of strings
 	savedState->writeLESint32(countElements);
 
-
 	// save number of closures
 	countElements = 0;
 	GCnode *tempNode;
diff --git a/engines/grim/lua/lstate.cpp b/engines/grim/lua/lstate.cpp
index b7dfddbde96..a8f93f733cd 100644
--- a/engines/grim/lua/lstate.cpp
+++ b/engines/grim/lua/lstate.cpp
@@ -70,7 +70,7 @@ static void lua_openthr() {
 	Mbuffer = nullptr;
 }
 
-#define STACK_UNIT	256
+#define STACK_UNIT      256
 
 void lua_stateinit(LState *state) {
 	state->prev = nullptr;
diff --git a/engines/grim/lua/lstate.h b/engines/grim/lua/lstate.h
index 6493c67fe54..28f2c855b83 100644
--- a/engines/grim/lua/lstate.h
+++ b/engines/grim/lua/lstate.h
@@ -12,7 +12,7 @@
 
 namespace Grim {
 
-#define MAX_C_BLOCKS 10
+#define MAX_C_BLOCKS  10
 #define GARBAGE_BLOCK 150
 
 /* The pause status for the scripts is stored in one byte in the savegame.
diff --git a/engines/grim/lua/lstring.cpp b/engines/grim/lua/lstring.cpp
index d0f285e5c70..632945a4da0 100644
--- a/engines/grim/lua/lstring.cpp
+++ b/engines/grim/lua/lstring.cpp
@@ -16,7 +16,7 @@
 
 namespace Grim {
 
-#define gcsizestring(l)	(1 + (l / 64))  // "weight" for a string with length 'l'
+#define gcsizestring(l)      (1 + (l / 64))  // "weight" for a string with length 'l'
 
 TaggedString EMPTY = {{nullptr, 2}, 0, 0L, {LUA_T_NIL, {nullptr}}, {0}};
 
@@ -155,12 +155,10 @@ static void remove_from_list(GCnode *l) {
 
 TaggedString *luaS_collector() {
 	TaggedString *frees = nullptr;
-	int32 i;
 	remove_from_list(&rootglobal);
-	for (i = 0; i < NUM_HASHS; i++) {
+	for (int32 i = 0; i < NUM_HASHS; i++) {
 		stringtable *tb = &string_root[i];
-		int32 j;
-		for (j = 0; j < tb->size; j++) {
+		for (int32 j = 0; j < tb->size; j++) {
 			TaggedString *t = tb->hash[j];
 			if (!t)
 				continue;
@@ -178,12 +176,10 @@ TaggedString *luaS_collector() {
 
 TaggedString *luaS_collectudata() {
 	TaggedString *frees = nullptr;
-	int32 i;
 	rootglobal.next = nullptr;  // empty list of globals
-	for (i = 0; i < NUM_HASHS; i++) {
+	for (int32 i = 0; i < NUM_HASHS; i++) {
 		stringtable *tb = &string_root[i];
-		int32 j;
-		for (j = 0; j < tb->size; j++) {
+		for (int32 j = 0; j < tb->size; j++) {
 			TaggedString *t = tb->hash[j];
 			if (!t || t == &EMPTY || t->constindex != -1)
 				continue;  // get only user data
@@ -196,8 +192,7 @@ TaggedString *luaS_collectudata() {
 }
 
 void luaS_freeall() {
-	int32 i;
-	for (i = 0; i < NUM_HASHS; i++) {
+	for (int32 i = 0; i < NUM_HASHS; i++) {
 		stringtable *tb = &string_root[i];
 		int32 j;
 		for (j = 0; j < tb->size; j++) {
diff --git a/engines/grim/lua/lstrlib.cpp b/engines/grim/lua/lstrlib.cpp
index 22aeb2a8ff4..8034dc88558 100644
--- a/engines/grim/lua/lstrlib.cpp
+++ b/engines/grim/lua/lstrlib.cpp
@@ -85,13 +85,11 @@ struct Capture {
 	} capture[MAX_CAPT];
 };
 
-#define ESC	'%'
+#define ESC       '%'
 #define SPECIALS  "^$*?.([%-"
 
 static void push_captures(Capture *cap) {
-	int i;
-
-	for (i = 0; i < cap->level; i++) {
+	for (int i = 0; i < cap->level; i++) {
 		int l = cap->capture[i].len;
 		char *buff = luaL_openspace(l+1);
 		if (l == -1)
diff --git a/engines/grim/lua/ltable.cpp b/engines/grim/lua/ltable.cpp
index 3ea0f7ce8cb..a2377ccd944 100644
--- a/engines/grim/lua/ltable.cpp
+++ b/engines/grim/lua/ltable.cpp
@@ -15,11 +15,11 @@
 
 namespace Grim {
 
-#define gcsize(n)		(1 + (n / 16))
-#define nuse(t)			((t)->nuse)
-#define nodevector(t)	((t)->node)
-#define REHASH_LIMIT	0.70    // avoid more than this % full
-#define TagDefault		LUA_T_ARRAY;
+#define gcsize(n)               (1 + (n / 16))
+#define nuse(t)                 ((t)->nuse)
+#define nodevector(t)           ((t)->node)
+#define REHASH_LIMIT            0.70    // avoid more than this % full
+#define TagDefault              LUA_T_ARRAY;
 
 static intptr hashindex(TObject *ref) {
 	intptr h;
diff --git a/engines/grim/lua/ltask.cpp b/engines/grim/lua/ltask.cpp
index 61d95a5c6a9..3b061487ee1 100644
--- a/engines/grim/lua/ltask.cpp
+++ b/engines/grim/lua/ltask.cpp
@@ -1,10 +1,6 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
 #define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
 
-#ifdef _MSC_VER
-#pragma warning(disable:4611)
-#endif
-
 #include "engines/grim/lua/ltask.h"
 #include "engines/grim/lua/lapi.h"
 #include "engines/grim/lua/lauxlib.h"
@@ -239,7 +235,6 @@ void pause_scripts() {
 	if (!lua_isnil(boolObj))
 		p = true;
 
-
 	for (t = lua_rootState->next; t != nullptr; t = t->next) {
 		if (lua_state != t) {
 			if (p) {
diff --git a/engines/grim/lua/ltm.cpp b/engines/grim/lua/ltm.cpp
index 5b9807ed774..2f3672d74e7 100644
--- a/engines/grim/lua/ltm.cpp
+++ b/engines/grim/lua/ltm.cpp
@@ -49,19 +49,17 @@ static int32 validevent(int32 t, int32 e) { // ORDER LUA_T
 }
 
 static void init_entry(int32 tag) {
-	int32 i;
-	for (i = 0; i < IM_N; i++)
+	for (int32 i = 0; i < IM_N; i++)
 		ttype(luaT_getim(tag, i)) = LUA_T_NIL;
 }
 
 static bool tmFBAdded = false;
 
 void luaT_init() {
-	int32 t;
 	IMtable_size = NUM_TAGS * 2;
 	last_tag = -(NUM_TAGS - 1);
 	IMtable = luaM_newvector(IMtable_size, struct IM);
-	for (t = -(IMtable_size - 1); t <= 0; t++)
+	for (int32 t = -(IMtable_size - 1); t <= 0; t++)
 		init_entry(t);
 
 	tmFBAdded = false;
@@ -135,7 +133,7 @@ void luaT_settagmethod(int32 t, const char *event, TObject *func) {
 	checktag(t);
 	if (!validevent(t, e))
 		luaL_verror("settagmethod: cannot change tag method `%.20s' for tag %d",
-		luaT_eventname[e], t);
+	luaT_eventname[e], t);
 	*func = *luaT_getim(t,e);
 	*luaT_getim(t, e) = temp;
 }
diff --git a/engines/grim/lua/ltm.h b/engines/grim/lua/ltm.h
index 664cc2a19bf..d829ecabf8b 100644
--- a/engines/grim/lua/ltm.h
+++ b/engines/grim/lua/ltm.h
@@ -6,7 +6,6 @@
 #ifndef GRIM_LTM_H
 #define GRIM_LTM_H
 
-
 #include "engines/grim/lua/lobject.h"
 #include "engines/grim/lua/lstate.h"
 
@@ -44,9 +43,8 @@ struct IM {
 	TObject int_method[IM_N];
 };
 
-
-#define luaT_getim(tag, event)	(&IMtable[-(tag)].int_method[event])
-#define luaT_getimbyObj(o, e)	(luaT_getim(luaT_efectivetag(o), (e)))
+#define luaT_getim(tag, event)  (&IMtable[-(tag)].int_method[event])
+#define luaT_getimbyObj(o, e)   (luaT_getim(luaT_efectivetag(o), (e)))
 
 extern const char *luaT_eventname[];
 
diff --git a/engines/grim/lua/lua.h b/engines/grim/lua/lua.h
index 868ee0ceba7..f450d7fd2ad 100644
--- a/engines/grim/lua/lua.h
+++ b/engines/grim/lua/lua.h
@@ -21,9 +21,9 @@ namespace Common {
 
 namespace Grim {
 
-#define LUA_VERSION		"Lua 3.1 (alpha)"
-#define LUA_COPYRIGHT	"Copyright (C) 1994-1998 TeCGraf, PUC-Rio"
-#define LUA_AUTHORS 	"W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
+#define LUA_VERSION     "Lua 3.1 (alpha)"
+#define LUA_COPYRIGHT   "Copyright (C) 1994-1998 TeCGraf, PUC-Rio"
+#define LUA_AUTHORS     "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
 
 #define LUA_NOOBJECT  0
 
@@ -87,8 +87,8 @@ void lua_endblock();
 
 lua_Object lua_lua2C(int32 number);
 
-#define lua_getparam(_)		lua_lua2C(_)
-#define	lua_getresult(_)	lua_lua2C(_)
+#define lua_getparam(_)         lua_lua2C(_)
+#define lua_getresult(_)        lua_lua2C(_)
 
 int32 lua_isnil                (lua_Object object);
 int32 lua_istable              (lua_Object object);
@@ -98,10 +98,10 @@ int32 lua_isnumber             (lua_Object object);
 int32 lua_isstring             (lua_Object object);
 int32 lua_isfunction           (lua_Object object);
 
-float lua_getnumber 		(lua_Object object);
-const char *lua_getstring 		(lua_Object object);
-lua_CFunction lua_getcfunction 	(lua_Object object);
-int32 lua_getuserdata		(lua_Object object);
+float lua_getnumber            (lua_Object object);
+const char *lua_getstring      (lua_Object object);
+lua_CFunction lua_getcfunction (lua_Object object);
+int32 lua_getuserdata          (lua_Object object);
 
 void lua_pushnil();
 void lua_pushnumber(float n);
@@ -135,19 +135,19 @@ void current_script();
 
 /* some useful macros/derived functions */
 
-#define lua_call(name)		lua_callfunction(lua_getglobal(name))
+#define lua_call(name)          lua_callfunction(lua_getglobal(name))
 
-#define lua_pushref(ref)	lua_pushobject(lua_getref(ref))
+#define lua_pushref(ref)        lua_pushobject(lua_getref(ref))
 
-#define lua_refobject(o,l)	(lua_pushobject(o), lua_ref(l))
+#define lua_refobject(o,l)      (lua_pushobject(o), lua_ref(l))
 
-#define lua_register(n, f)	(lua_pushcfunction(f), lua_setglobal(n))
+#define lua_register(n, f)      (lua_pushcfunction(f), lua_setglobal(n))
 
-#define lua_pushuserdata(u)	lua_pushusertag(u, 0)
+#define lua_pushuserdata(u)     lua_pushusertag(u, 0)
 
-#define lua_pushcfunction(f)	lua_pushCclosure(f, 0)
+#define lua_pushcfunction(f)    lua_pushCclosure(f, 0)
 
-#define lua_clonetag(t)		lua_copytagmethods(lua_newtag(), (t))
+#define lua_clonetag(t)         lua_copytagmethods(lua_newtag(), (t))
 
 /* ==========================================================================
 ** for compatibility with old versions. Avoid using these macros/functions
@@ -159,20 +159,20 @@ void current_script();
 
 lua_Object lua_setfallback(const char *event, lua_CFunction fallback);
 
-#define lua_storeglobal		lua_setglobal
-#define lua_type			lua_tag
-
-#define lua_lockobject(o)	lua_refobject(o,1)
-#define	lua_lock()			lua_ref(1)
-#define lua_getlocked		lua_getref
-#define	lua_pushlocked		lua_pushref
-#define	lua_unlock			lua_unref
-#define lua_pushliteral(o)  lua_pushstring(o)
-#define lua_getindexed(o, n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
-#define lua_getfield(o, f)  (lua_pushobject(o), lua_pushstring(f), lua_gettable())
-#define lua_copystring(o)	(strdup(lua_getstring(o)))
-#define lua_getsubscript	lua_gettable
-#define lua_storesubscript  lua_settable
+#define lua_storeglobal         lua_setglobal
+#define lua_type                lua_tag
+
+#define lua_lockobject(o)       lua_refobject(o,1)
+#define lua_lock()              lua_ref(1)
+#define lua_getlocked           lua_getref
+#define lua_pushlocked          lua_pushref
+#define lua_unlock              lua_unref
+#define lua_pushliteral(o)      lua_pushstring(o)
+#define lua_getindexed(o, n)    (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
+#define lua_getfield(o, f)      (lua_pushobject(o), lua_pushstring(f), lua_gettable())
+#define lua_copystring(o)       (strdup(lua_getstring(o)))
+#define lua_getsubscript        lua_gettable
+#define lua_storesubscript      lua_settable
 
 #endif
 
diff --git a/engines/grim/lua/lualib.h b/engines/grim/lua/lualib.h
index 03c569b0261..654303aa751 100644
--- a/engines/grim/lua/lualib.h
+++ b/engines/grim/lua/lualib.h
@@ -18,9 +18,9 @@ void lua_iolibclose();
 
 // To keep compatibility with old versions
 
-#define iolib_open		lua_iolibopen
-#define strlib_open		lua_strlibopen
-#define mathlib_open	lua_mathlibopen
+#define iolib_open      lua_iolibopen
+#define strlib_open     lua_strlibopen
+#define mathlib_open    lua_mathlibopen
 
 // Auxiliary functions (private)
 
diff --git a/engines/grim/lua/lundump.cpp b/engines/grim/lua/lundump.cpp
index b39f2d61f1d..42aed06e8a3 100644
--- a/engines/grim/lua/lundump.cpp
+++ b/engines/grim/lua/lundump.cpp
@@ -85,7 +85,7 @@ static void LoadLocals(TProtoFunc *tf, ZIO *Z) {
 		tf->locvars[i].line = LoadWord(Z);
 		tf->locvars[i].varname = LoadTString(Z);
 	}
-	tf->locvars[i].line = -1;		// flag end of vector
+	tf->locvars[i].line = -1; // flag end of vector
 	tf->locvars[i].varname = nullptr;
 }
 
@@ -155,9 +155,9 @@ static void LoadHeader(ZIO *Z) {
 	version = ezgetc(Z);
 	if (version > VERSION)
 		luaL_verror("%s too new: version=0x%02x; expected at most 0x%02x", zname(Z), version, VERSION);
-	if (version < VERSION)			// check last major change
+	if (version < VERSION) // check last major change
 		luaL_verror("%s too old: version=0x%02x; expected at least 0x%02x", zname(Z), version, VERSION);
-	sizeofR = ezgetc(Z);			// test number representation
+	sizeofR = ezgetc(Z); // test number representation
 	if (sizeofR != sizeof(float))
 		luaL_verror("number expected float in %s", zname(Z));
 	ezgetc(Z);
diff --git a/engines/grim/lua/lundump.h b/engines/grim/lua/lundump.h
index d333eec7e16..c92cf481589 100644
--- a/engines/grim/lua/lundump.h
+++ b/engines/grim/lua/lundump.h
@@ -11,19 +11,19 @@
 
 namespace Grim {
 
-#define ID_CHUNK		27              // ESC
-#define ID_FUNCTION		'#'
-#define ID_END			'$'
-#define ID_NUM			'N'
-#define ID_STR			'S'
-#define ID_FUN			'F'
-#define	SIGNATURE		"Lua"
-#define	VERSION			0x31		// last format change was in 3.1
-#define TEST_FLOAT		0.123456789e-23 // a float for testing representation
-
-#define IsMain(f)			(f->lineDefined == 0)
-
-TProtoFunc* luaU_undump1(ZIO* Z);      // load one chunk
+#define ID_CHUNK        27              // ESC
+#define ID_FUNCTION     '#'
+#define ID_END          '$'
+#define ID_NUM          'N'
+#define ID_STR          'S'
+#define ID_FUN          'F'
+#define SIGNATURE       "Lua"
+#define VERSION         0x31            // last format change was in 3.1
+#define TEST_FLOAT      0.123456789e-23 // a float for testing representation
+
+#define IsMain(f)       (f->lineDefined == 0)
+
+TProtoFunc *luaU_undump1(ZIO *Z);      // load one chunk
 
 } // end of namespace Grim
 
diff --git a/engines/grim/lua/lvm.cpp b/engines/grim/lua/lvm.cpp
index 1c6e440e644..97dfdc76347 100644
--- a/engines/grim/lua/lvm.cpp
+++ b/engines/grim/lua/lvm.cpp
@@ -22,11 +22,11 @@
 
 namespace Grim {
 
-#define skip_word(pc)	(pc += 2)
-#define get_word(pc)	((*((pc) + 1) << 8)|(*(pc)))
+#define skip_word(pc)   (pc += 2)
+#define get_word(pc)    ((*((pc) + 1) << 8)|(*(pc)))
 #define next_word(pc)   (pc += 2, get_word(pc - 2))
 
-#define	EXTRA_STACK	5
+#define EXTRA_STACK     5
 
 static TaggedString *strconc(char *l, char *r) {
 	size_t nl = strlen(l);
diff --git a/engines/grim/lua/lzio.h b/engines/grim/lua/lzio.h
index 3831e432393..180f9aaab8d 100644
--- a/engines/grim/lua/lzio.h
+++ b/engines/grim/lua/lzio.h
@@ -16,30 +16,30 @@ namespace Common {
 namespace Grim {
 
 // For Lua only
-#define zopen	luaZ_mopen
+#define zopen   luaZ_mopen
 
-#define EOZ	(-1)			// end of stream
+#define EOZ     (-1)                    // end of stream
 
 typedef struct zio ZIO;
 
 ZIO *zopen(ZIO *z, const char *b, int32 size, const char *name);
-int32 zread(ZIO *z, void *b, int32 n);	// read next n bytes
+int32 zread(ZIO *z, void *b, int32 n);  // read next n bytes
 int32 zgeteoz(ZIO *);
 
-#define zgetc(z)	(--(z)->n >= 0 ? ((int32)*(z)->p++): zgeteoz(z))
-#define zungetc(z)	(++(z)->n, --(z)->p)
-#define zname(z)	((z)->name)
+#define zgetc(z)        (--(z)->n >= 0 ? ((int32)*(z)->p++): zgeteoz(z))
+#define zungetc(z)      (++(z)->n, --(z)->p)
+#define zname(z)        ((z)->name)
 
 
 // --------- Private Part ------------------
 
-#define ZBSIZE	256			// buffer size
+#define ZBSIZE  256                     // buffer size
 
 struct zio {
-	int32 n;					// bytes still unread
-	const byte *p;				// current position in buffer
+	int32 n;                        // bytes still unread
+	const byte *p;                  // current position in buffer
 	const char *name;
-	byte buffer[ZBSIZE];		// buffer
+	byte buffer[ZBSIZE];            // buffer
 };
 
 } // end of namespace Grim




More information about the Scummvm-git-logs mailing list