Browse Source

some C compilers cannot initialize a local struct

v5-2
Roberto Ierusalimschy 26 years ago
parent
commit
cdd0fe9946
  1. 5
      ltable.c
  2. 5
      ltm.c
  3. 16
      lvm.c

5
ltable.c

@ -1,5 +1,5 @@
/* /*
** $Id: ltable.c,v 1.20 1999/01/25 17:41:19 roberto Exp roberto $ ** $Id: ltable.c,v 1.21 1999/02/23 14:57:28 roberto Exp roberto $
** Lua tables (hash) ** Lua tables (hash)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -140,7 +140,8 @@ void luaH_set (Hash *t, TObject *ref, TObject *val) {
if (ttype(ref(n)) != LUA_T_NIL) if (ttype(ref(n)) != LUA_T_NIL)
*val(n) = *val; *val(n) = *val;
else { else {
TObject buff = *val; /* rehash may invalidate this address */ TObject buff;
buff = *val; /* rehash may invalidate this address */
if ((long)nuse(t)*3L > (long)nhash(t)*2L) { if ((long)nuse(t)*3L > (long)nhash(t)*2L) {
rehash(t); rehash(t);
n = luaH_present(t, ref); n = luaH_present(t, ref);

5
ltm.c

@ -1,5 +1,5 @@
/* /*
** $Id: ltm.c,v 1.23 1999/02/25 19:13:56 roberto Exp roberto $ ** $Id: ltm.c,v 1.24 1999/02/26 15:48:55 roberto Exp roberto $
** Tag methods ** Tag methods
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -129,7 +129,7 @@ TObject *luaT_gettagmethod (int t, char *event) {
void luaT_settagmethod (int t, char *event, TObject *func) { void luaT_settagmethod (int t, char *event, TObject *func) {
TObject temp = *func; TObject temp;
int e = luaI_checkevent(event, luaT_eventname); int e = luaI_checkevent(event, luaT_eventname);
checktag(t); checktag(t);
if (!luaT_validevent(t, e)) if (!luaT_validevent(t, e))
@ -137,6 +137,7 @@ void luaT_settagmethod (int t, char *event, TObject *func) {
luaT_eventname[e], luaO_typenames[-t], luaT_eventname[e], luaO_typenames[-t],
(t == LUA_T_ARRAY || t == LUA_T_USERDATA) ? " with default tag" (t == LUA_T_ARRAY || t == LUA_T_USERDATA) ? " with default tag"
: ""); : "");
temp = *func;
*func = *luaT_getim(t,e); *func = *luaT_getim(t,e);
*luaT_getim(t, e) = temp; *luaT_getim(t, e) = temp;
} }

16
lvm.c

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 1.55 1999/04/13 19:28:49 roberto Exp roberto $ ** $Id: lvm.c,v 1.56 1999/05/21 17:23:15 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -214,7 +214,8 @@ void luaV_setglobal (TaggedString *ts) {
else { else {
/* WARNING: caller must assure stack space */ /* WARNING: caller must assure stack space */
struct Stack *S = &L->stack; struct Stack *S = &L->stack;
TObject newvalue = *(S->top-1); TObject newvalue;
newvalue = *(S->top-1);
ttype(S->top-1) = LUA_T_STRING; ttype(S->top-1) = LUA_T_STRING;
tsvalue(S->top-1) = ts; tsvalue(S->top-1) = ts;
*S->top++ = *oldvalue; *S->top++ = *oldvalue;
@ -403,7 +404,8 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
case PUSHSELFW: aux += highbyte(*pc++); case PUSHSELFW: aux += highbyte(*pc++);
case PUSHSELF: aux += *pc++; { case PUSHSELF: aux += *pc++; {
TObject receiver = *(S->top-1); TObject receiver;
receiver = *(S->top-1);
*S->top++ = consts[aux]; *S->top++ = consts[aux];
luaV_gettable(); luaV_gettable();
*S->top++ = receiver; *S->top++ = receiver;
@ -439,17 +441,17 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
case SETLISTW: aux += highbyte(*pc++); case SETLISTW: aux += highbyte(*pc++);
case SETLIST: aux += *pc++; { case SETLIST: aux += *pc++; {
int n = *(pc++); int n = *(pc++);
TObject *arr = S->top-n-1; Hash *arr = avalue(S->top-n-1);
aux *= LFIELDS_PER_FLUSH; aux *= LFIELDS_PER_FLUSH;
for (; n; n--) for (; n; n--)
luaH_setint(avalue(arr), n+aux, --S->top); luaH_setint(arr, n+aux, --S->top);
break; break;
} }
case SETMAP: aux = *pc++; { case SETMAP: aux = *pc++; {
TObject *arr = S->top-(2*aux)-3; Hash *arr = avalue(S->top-(2*aux)-3);
do { do {
luaH_set(avalue(arr), S->top-2, S->top-1); luaH_set(arr, S->top-2, S->top-1);
S->top-=2; S->top-=2;
} while (aux--); } while (aux--);
break; break;

Loading…
Cancel
Save