1 diff -r lua-5.0.2/COPYRIGHT lua-5.0.3/COPYRIGHT
3 < Copyright (C) 2003-2004 Tecgraf, PUC-Rio.
5 > Copyright (C) 2003-2006 Tecgraf, PUC-Rio.
6 diff -r lua-5.0.2/include/lua.h lua-5.0.3/include/lua.h
8 < ** $Id: lua.h,v 1.175b 2003/03/18 12:31:39 roberto Exp $
10 > ** $Id: lua.h,v 1.175c 2003/03/18 12:31:39 roberto Exp $
12 < #define LUA_VERSION "Lua 5.0.2"
13 < #define LUA_COPYRIGHT "Copyright (C) 1994-2004 Tecgraf, PUC-Rio"
15 > #define LUA_VERSION "Lua 5.0.3"
16 > #define LUA_COPYRIGHT "Copyright (C) 1994-2006 Tecgraf, PUC-Rio"
18 < * Copyright (C) 1994-2004 Tecgraf, PUC-Rio. All rights reserved.
20 > * Copyright (C) 1994-2006 Tecgraf, PUC-Rio. All rights reserved.
21 diff -r lua-5.0.2/src/lapi.c lua-5.0.3/src/lapi.c
23 < ** $Id: lapi.c,v 1.235 2003/04/07 14:36:08 roberto Exp $
25 > ** $Id: lapi.c,v 1.235a 2003/04/07 14:36:08 roberto Exp $
27 < if (n > f->c.nupvalues) return NULL;
29 > if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
31 < if (n > p->sizeupvalues) return NULL;
33 > if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
34 diff -r lua-5.0.2/src/lcode.c lua-5.0.3/src/lcode.c
36 < ** $Id: lcode.c,v 1.117 2003/04/03 13:35:34 roberto Exp $
38 > ** $Id: lcode.c,v 1.117a 2003/04/03 13:35:34 roberto Exp $
40 < if (GET_OPCODE(i) != OP_TEST || GETARG_C(i) != cond) return 1;
42 > if (GET_OPCODE(i) != OP_TEST ||
43 > GETARG_A(i) != NO_REG ||
44 > GETARG_C(i) != cond)
47 < static void luaK_patchlistaux (FuncState *fs, int list,
48 < int ttarget, int treg, int ftarget, int freg, int dtarget) {
50 > static void removevalues (FuncState *fs, int list) {
51 > for (; list != NO_JUMP; list = luaK_getjump(fs, list)) {
52 > Instruction *i = getjumpcontrol(fs, list);
53 > if (GET_OPCODE(*i) == OP_TEST)
54 > patchtestreg(i, NO_REG);
59 > static void luaK_patchlistaux (FuncState *fs, int list, int vtarget, int reg,
62 < if (GET_OPCODE(*i) != OP_TEST) {
63 < lua_assert(dtarget != NO_JUMP);
64 < luaK_fixjump(fs, list, dtarget); /* jump to default target */
68 < lua_assert(ttarget != NO_JUMP);
69 < patchtestreg(i, treg);
70 < luaK_fixjump(fs, list, ttarget);
73 < lua_assert(ftarget != NO_JUMP);
74 < patchtestreg(i, freg);
75 < luaK_fixjump(fs, list, ftarget);
78 > if (GET_OPCODE(*i) == OP_TEST && GETARG_A(*i) == NO_REG) {
79 > patchtestreg(i, reg);
80 > luaK_fixjump(fs, list, vtarget);
83 > luaK_fixjump(fs, list, dtarget); /* jump to default target */
85 < luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc);
87 > luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
89 < luaK_patchlistaux(fs, list, target, NO_REG, target, NO_REG, target);
91 > luaK_patchlistaux(fs, list, target, NO_REG, target);
93 < luaK_patchlistaux(fs, e->f, p_f, NO_REG, final, reg, p_f);
94 < luaK_patchlistaux(fs, e->t, final, reg, p_t, NO_REG, p_t);
96 > luaK_patchlistaux(fs, e->f, final, reg, p_f);
97 > luaK_patchlistaux(fs, e->t, final, reg, p_t);
99 < return luaK_condjump(fs, OP_TEST, NO_REG, GETARG_B(ie), !cond);
101 > return luaK_condjump(fs, OP_TEST, GETARG_B(ie), GETARG_B(ie), !cond);
103 > removevalues(fs, e->f);
104 > removevalues(fs, e->t);
105 diff -r lua-5.0.2/src/lfunc.c lua-5.0.3/src/lfunc.c
107 < ** $Id: lfunc.c,v 1.67 2003/03/18 12:50:04 roberto Exp $
109 > ** $Id: lfunc.c,v 1.67a 2003/03/18 12:50:04 roberto Exp $
113 < #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
114 < cast(int, sizeof(TObject)*((n)-1)))
116 < #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
117 < cast(int, sizeof(TObject *)*((n)-1)))
119 diff -r lua-5.0.2/src/lfunc.h lua-5.0.3/src/lfunc.h
121 < ** $Id: lfunc.h,v 1.21 2003/03/18 12:50:04 roberto Exp $
123 > ** $Id: lfunc.h,v 1.21a 2003/03/18 12:50:04 roberto Exp $
127 > #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
128 > cast(int, sizeof(TObject)*((n)-1)))
130 > #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
131 > cast(int, sizeof(TObject *)*((n)-1)))
132 diff -r lua-5.0.2/src/lgc.c lua-5.0.3/src/lgc.c
134 < ** $Id: lgc.c,v 1.171a 2003/04/03 13:35:34 roberto Exp $
136 > ** $Id: lgc.c,v 1.171b 2003/04/03 13:35:34 roberto Exp $
139 < markobject(st, &u->value);
143 > markobject(st, u->v);
146 < static void propagatemarks (GCState *st) {
148 > static lu_mem propagatemarks (GCState *st) {
151 > mf += sizeof(Table) + sizeof(TObject) * h->sizearray +
152 > sizeof(Node) * sizenode(h);
154 > mf += (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
155 > sizeLclosure(cl->l.nupvalues);
157 > mf += sizeof(lua_State) + sizeof(TObject) * th->stacksize +
158 > sizeof(CallInfo) * th->size_ci;
160 > /* do not need 'mf' for this case (cannot happen inside a udata) */
164 < if (curr->gch.marked > limit) {
166 > if ((curr->gch.marked & ~(KEYWEAK | VALUEWEAK)) > limit) {
168 < propagatemarks(&st); /* remark, to propagate `preserveness' */
170 > deadmem += propagatemarks(&st); /* remark, to propagate `preserveness' */
171 diff -r lua-5.0.2/src/lib/lbaselib.c lua-5.0.3/src/lib/lbaselib.c
173 < ** $Id: lbaselib.c,v 1.130b 2003/04/03 13:35:34 roberto Exp $
175 > ** $Id: lbaselib.c,v 1.130c 2003/04/03 13:35:34 roberto Exp $
180 diff -r lua-5.0.2/src/lib/liolib.c lua-5.0.3/src/lib/liolib.c
182 < ** $Id: liolib.c,v 2.39a 2003/03/19 21:16:12 roberto Exp $
184 > ** $Id: liolib.c,v 2.39b 2003/03/19 21:16:12 roberto Exp $
186 > typedef struct FileHandle {
193 < static FILE **topfile (lua_State *L, int findex) {
194 < FILE **f = (FILE **)luaL_checkudata(L, findex, FILEHANDLE);
195 < if (f == NULL) luaL_argerror(L, findex, "bad file");
198 > static FileHandle *topfile (lua_State *L, int findex) {
199 > FileHandle *fh = (FileHandle *)luaL_checkudata(L, findex, FILEHANDLE);
200 > if (fh == NULL) luaL_argerror(L, findex, "bad file");
203 < FILE **f = (FILE **)luaL_checkudata(L, 1, FILEHANDLE);
204 < if (f == NULL) lua_pushnil(L);
205 < else if (*f == NULL)
207 > FileHandle *fh = (FileHandle *)luaL_checkudata(L, 1, FILEHANDLE);
208 > if (fh == NULL) lua_pushnil(L);
209 > else if (fh->f == NULL)
211 < static FILE *tofile (lua_State *L, int findex) {
212 < FILE **f = topfile(L, findex);
215 > #define tofile(L,i) (tofileh(L,i)->f)
217 > static FileHandle *tofileh (lua_State *L, int findex) {
218 > FileHandle *fh = topfile(L, findex);
225 > #define newfile(L) (&(newfileh(L)->f))
228 < static FILE **newfile (lua_State *L) {
229 < FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
230 < *pf = NULL; /* file handle is currently `closed' */
232 > static FileHandle *newfileh (lua_State *L) {
233 > FileHandle *fh = (FileHandle *)lua_newuserdata(L, sizeof(FileHandle));
234 > fh->f = NULL; /* file handle is currently `closed' */
241 < FILE *f = tofile(L, 1);
243 > FileHandle *fh = tofileh(L, 1);
246 < int ok = (pclose(f) != -1) || (fclose(f) == 0);
248 < *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */
250 > int ok = fh->ispipe ? (pclose(f) != -1) : (fclose(f) == 0);
251 > fh->f = NULL; /* mark file as closed */
253 < FILE **f = topfile(L, 1);
254 < if (*f != NULL) /* ignore closed files */
256 > FileHandle *fh = topfile(L, 1);
257 > if (fh->f != NULL) /* ignore closed files */
259 < FILE **f = topfile(L, 1);
262 > FileHandle *fh = topfile(L, 1);
265 < FILE **pf = newfile(L);
266 < *pf = popen(filename, mode);
267 < return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
269 > FileHandle *fh = newfileh(L);
270 > fh->f = popen(filename, mode);
272 > return (fh->f == NULL) ? pushresult(L, 0, filename) : 1;
273 diff -r lua-5.0.2/src/lvm.c lua-5.0.3/src/lvm.c
275 < ** $Id: lvm.c,v 1.284b 2003/04/03 13:35:34 roberto Exp $
277 > ** $Id: lvm.c,v 1.284c 2003/04/03 13:35:34 roberto Exp $
279 < lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) +
280 < cast(lu_mem, tsvalue(top-2)->tsv.len);
282 > size_t tl = tsvalue(top-1)->tsv.len;
284 < while (n < total && tostring(L, top-n-1)) { /* collect total length */
285 < tl += tsvalue(top-n-1)->tsv.len;
288 > /* collect total length */
289 > for (n = 1; n < total && tostring(L, top-n-1); n++) {
290 > size_t l = tsvalue(top-n-1)->tsv.len;
291 > if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
294 < if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow");