warnings by clinio

This commit is contained in:
Roberto Ierusalimschy
1999-05-10 10:54:01 -03:00
parent 288fa05602
commit 73308c7605
3 changed files with 34 additions and 25 deletions

33
ldo.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldo.c,v 1.40 1999/03/10 14:23:07 roberto Exp roberto $ ** $Id: ldo.c,v 1.41 1999/03/11 18:59:19 roberto Exp roberto $
** Stack and Call structure of Lua ** Stack and Call structure of Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -123,22 +123,21 @@ void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn)
** Cstack.num is the number of arguments; Cstack.lua2C points to the ** Cstack.num is the number of arguments; Cstack.lua2C points to the
** first argument. Returns an index to the first result from C. ** first argument. Returns an index to the first result from C.
*/ */
static StkId callC (lua_CFunction f, StkId base) static StkId callC (lua_CFunction f, StkId base) {
{ struct C_Lua_Stack *cls = &L->Cstack;
struct C_Lua_Stack *CS = &L->Cstack; struct C_Lua_Stack oldCLS = *cls;
struct C_Lua_Stack oldCLS = *CS;
StkId firstResult; StkId firstResult;
int numarg = (L->stack.top-L->stack.stack) - base; int numarg = (L->stack.top-L->stack.stack) - base;
CS->num = numarg; cls->num = numarg;
CS->lua2C = base; cls->lua2C = base;
CS->base = base+numarg; /* == top-stack */ cls->base = base+numarg; /* == top-stack */
if (L->callhook) if (L->callhook)
luaD_callHook(base, NULL, 0); luaD_callHook(base, NULL, 0);
(*f)(); /* do the actual call */ (*f)(); /* do the actual call */
if (L->callhook) /* func may have changed callhook */ if (L->callhook) /* func may have changed callhook */
luaD_callHook(base, NULL, 1); luaD_callHook(base, NULL, 1);
firstResult = CS->base; firstResult = cls->base;
*CS = oldCLS; *cls = oldCLS;
return firstResult; return firstResult;
} }
@@ -249,7 +248,7 @@ static void message (char *s) {
void lua_error (char *s) { void lua_error (char *s) {
if (s) message(s); if (s) message(s);
if (L->errorJmp) if (L->errorJmp)
longjmp(*((jmp_buf *)L->errorJmp), 1); longjmp(L->errorJmp->b, 1);
else { else {
message("exit(1). Unable to recover.\n"); message("exit(1). Unable to recover.\n");
exit(1); exit(1);
@@ -276,11 +275,11 @@ static void do_callinc (int nResults)
*/ */
int luaD_protectedrun (int nResults) { int luaD_protectedrun (int nResults) {
volatile struct C_Lua_Stack oldCLS = L->Cstack; volatile struct C_Lua_Stack oldCLS = L->Cstack;
jmp_buf myErrorJmp; struct lua_longjmp myErrorJmp;
volatile int status; volatile int status;
jmp_buf *volatile oldErr = L->errorJmp; struct lua_longjmp *volatile oldErr = L->errorJmp;
L->errorJmp = &myErrorJmp; L->errorJmp = &myErrorJmp;
if (setjmp(myErrorJmp) == 0) { if (setjmp(myErrorJmp.b) == 0) {
do_callinc(nResults); do_callinc(nResults);
status = 0; status = 0;
} }
@@ -299,12 +298,12 @@ int luaD_protectedrun (int nResults) {
*/ */
static int protectedparser (ZIO *z, int bin) { static int protectedparser (ZIO *z, int bin) {
volatile struct C_Lua_Stack oldCLS = L->Cstack; volatile struct C_Lua_Stack oldCLS = L->Cstack;
jmp_buf myErrorJmp; struct lua_longjmp myErrorJmp;
volatile int status; volatile int status;
TProtoFunc *volatile tf; TProtoFunc *volatile tf;
jmp_buf *volatile oldErr = L->errorJmp; struct lua_longjmp *volatile oldErr = L->errorJmp;
L->errorJmp = &myErrorJmp; L->errorJmp = &myErrorJmp;
if (setjmp(myErrorJmp) == 0) { if (setjmp(myErrorJmp.b) == 0) {
tf = bin ? luaU_undump1(z) : luaY_parser(z); tf = bin ? luaU_undump1(z) : luaY_parser(z);
status = 0; status = 0;
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 1.31 1999/03/25 21:06:57 roberto Exp roberto $ ** $Id: lparser.c,v 1.32 1999/05/06 14:41:41 roberto Exp roberto $
** LL(1) Parser and code generator for Lua ** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -50,7 +50,7 @@
*/ */
typedef enum {VGLOBAL, VLOCAL, VDOT, VINDEXED, VEXP} varkind; typedef enum {VGLOBAL, VLOCAL, VDOT, VINDEXED, VEXP} varkind;
typedef struct { typedef struct vardesc {
varkind k; varkind k;
int info; int info;
} vardesc; } vardesc;
@@ -62,7 +62,7 @@ typedef struct {
** and, if last expression is open (a function call), ** and, if last expression is open (a function call),
** where is its pc index of "nparam" ** where is its pc index of "nparam"
*/ */
typedef struct { typedef struct listdesc {
int n; int n;
int pc; /* 0 if last expression is closed */ int pc; /* 0 if last expression is closed */
} listdesc; } listdesc;
@@ -74,7 +74,7 @@ typedef struct {
** it is a list constructor (k = 0) or a record constructor (k = 1) ** it is a list constructor (k = 0) or a record constructor (k = 1)
** or empty (k = ';' or '}') ** or empty (k = ';' or '}')
*/ */
typedef struct { typedef struct constdesc {
int n; int n;
int k; int k;
} constdesc; } constdesc;
@@ -911,7 +911,7 @@ static OpCode opcodes [POW+1] = {NOTOP, MINUSOP, EQOP, NEQOP, GTOP, LTOP,
#define MAXOPS 20 /* op's stack size */ #define MAXOPS 20 /* op's stack size */
typedef struct { typedef struct stack_op {
int ops[MAXOPS]; int ops[MAXOPS];
int top; int top;
} stack_op; } stack_op;

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lstate.h,v 1.15 1999/02/25 15:17:01 roberto Exp roberto $ ** $Id: lstate.h,v 1.16 1999/04/13 19:30:51 roberto Exp roberto $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -21,6 +21,16 @@
typedef int StkId; /* index to stack elements */ typedef int StkId; /* index to stack elements */
/*
** "jmp_buf" may be an array, so it is better to make sure it has an
** address (and not that it *is* an address...)
*/
struct lua_longjmp {
jmp_buf b;
};
struct Stack { struct Stack {
TObject *top; TObject *top;
TObject *stack; TObject *stack;
@@ -35,7 +45,7 @@ struct C_Lua_Stack {
}; };
typedef struct { typedef struct stringtable {
int size; int size;
int nuse; /* number of elements (including EMPTYs) */ int nuse; /* number of elements (including EMPTYs) */
TaggedString **hash; TaggedString **hash;
@@ -54,7 +64,7 @@ struct lua_State {
/* thread-specific state */ /* thread-specific state */
struct Stack stack; /* Lua stack */ struct Stack stack; /* Lua stack */
struct C_Lua_Stack Cstack; /* C2lua struct */ struct C_Lua_Stack Cstack; /* C2lua struct */
jmp_buf *errorJmp; /* current error recover point */ struct lua_longjmp *errorJmp; /* current error recover point */
char *Mbuffer; /* global buffer */ char *Mbuffer; /* global buffer */
int Mbuffbase; /* current first position of Mbuffer */ int Mbuffbase; /* current first position of Mbuffer */
int Mbuffsize; /* size of Mbuffer */ int Mbuffsize; /* size of Mbuffer */