Imported from ../lua-5.0.3.tar.gz.
[lua.git] / DIFFS
blobc236ff8b9a190d573a60b4f2758ca685a7044479
1 diff -r lua-5.0.2/COPYRIGHT lua-5.0.3/COPYRIGHT
2 12c12
3 < Copyright (C) 2003-2004 Tecgraf, PUC-Rio.
4 ---
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
7 2c2
8 < ** $Id: lua.h,v 1.175b 2003/03/18 12:31:39 roberto Exp $
9 ---
10 > ** $Id: lua.h,v 1.175c 2003/03/18 12:31:39 roberto Exp $
11 17,18c17,18
12 < #define LUA_VERSION   "Lua 5.0.2"
13 < #define LUA_COPYRIGHT "Copyright (C) 1994-2004 Tecgraf, PUC-Rio"
14 ---
15 > #define LUA_VERSION   "Lua 5.0.3"
16 > #define LUA_COPYRIGHT "Copyright (C) 1994-2006 Tecgraf, PUC-Rio"
17 368c368
18 < * Copyright (C) 1994-2004 Tecgraf, PUC-Rio.  All rights reserved.
19 ---
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
22 2c2
23 < ** $Id: lapi.c,v 1.235 2003/04/07 14:36:08 roberto Exp $
24 ---
25 > ** $Id: lapi.c,v 1.235a 2003/04/07 14:36:08 roberto Exp $
26 882c882
27 <     if (n > f->c.nupvalues) return NULL;
28 ---
29 >     if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
30 888c888
31 <     if (n > p->sizeupvalues) return NULL;
32 ---
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
35 2c2
36 < ** $Id: lcode.c,v 1.117 2003/04/03 13:35:34 roberto Exp $
37 ---
38 > ** $Id: lcode.c,v 1.117a 2003/04/03 13:35:34 roberto Exp $
39 105c105,108
40 <     if (GET_OPCODE(i) != OP_TEST || GETARG_C(i) != cond) return 1;
41 ---
42 >     if (GET_OPCODE(i) != OP_TEST ||
43 >         GETARG_A(i) != NO_REG ||
44 >         GETARG_C(i) != cond)
45 >       return 1;
46 117,118c120,130
47 < static void luaK_patchlistaux (FuncState *fs, int list,
48 <           int ttarget, int treg, int ftarget, int freg, int dtarget) {
49 ---
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);
55 >   }
56 > }
57
58
59 > static void luaK_patchlistaux (FuncState *fs, int list, int vtarget, int reg,
60 >                                int dtarget) {
61 122,136c134,136
62 <     if (GET_OPCODE(*i) != OP_TEST) {
63 <       lua_assert(dtarget != NO_JUMP);
64 <       luaK_fixjump(fs, list, dtarget);  /* jump to default target */
65 <     }
66 <     else {
67 <       if (GETARG_C(*i)) {
68 <         lua_assert(ttarget != NO_JUMP);
69 <         patchtestreg(i, treg);
70 <         luaK_fixjump(fs, list, ttarget);
71 <       }
72 <       else {
73 <         lua_assert(ftarget != NO_JUMP);
74 <         patchtestreg(i, freg);
75 <         luaK_fixjump(fs, list, ftarget);
76 <       }
77 ---
78 >     if (GET_OPCODE(*i) == OP_TEST && GETARG_A(*i) == NO_REG) {
79 >         patchtestreg(i, reg);
80 >         luaK_fixjump(fs, list, vtarget);
81 137a138,139
82 >     else
83 >       luaK_fixjump(fs, list, dtarget);  /* jump to default target */
84 144c146
85 <   luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc);
86 ---
87 >   luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
88 154c156
89 <     luaK_patchlistaux(fs, list, target, NO_REG, target, NO_REG, target);
90 ---
91 >     luaK_patchlistaux(fs, list, target, NO_REG, target);
92 357,358c359,360
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);
95 ---
96 >     luaK_patchlistaux(fs, e->f, final, reg, p_f);
97 >     luaK_patchlistaux(fs, e->t, final, reg, p_t);
98 476c478
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);
102 566a569,570
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 $
110 19,26d18
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 $
124 11a12,18
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 $
137 221,224c221,222
138 <       if (!u->marked) {
139 <         markobject(st, &u->value);
140 <         u->marked = 1;
141 <       }
143 >       markobject(st, u->v);
144 >       u->marked = 1;
145 261c259,260
146 < static void propagatemarks (GCState *st) {
148 > static lu_mem propagatemarks (GCState *st) {
149 >   lu_mem mf = 0;
150 267a267,268
151 >         mf += sizeof(Table) + sizeof(TObject) * h->sizearray +
152 >                               sizeof(Node) * sizenode(h);
153 273a275,276
154 >         mf += (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
155 >                             sizeLclosure(cl->l.nupvalues);
156 279a283,284
157 >         mf += sizeof(lua_State) + sizeof(TObject) * th->stacksize +
158 >                                   sizeof(CallInfo) * th->size_ci;
159 285a291
160 >         /* do not need 'mf' for this case (cannot happen inside a udata) */
161 290a297
162 >   return mf;
163 371c378
164 <     if (curr->gch.marked > limit) {
166 >     if ((curr->gch.marked & ~(KEYWEAK | VALUEWEAK)) > limit) {
167 473c480
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 $
176 175a176
177 >   lua_settop(L, 2);
178 183a185
179 >   lua_settop(L, 3);
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 $
185 22a23,28
186 > typedef struct FileHandle {
187 >   FILE *f;
188 >   int ispipe;
189 > } FileHandle;
192 89,92c95,98
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");
196 <   return f;
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");
201 >   return fh;
202 97,99c103,105
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)
210 107,109c113,117
211 < static FILE *tofile (lua_State *L, int findex) {
212 <   FILE **f = topfile(L, findex);
213 <   if (*f == NULL)
215 > #define tofile(L,i)   (tofileh(L,i)->f)
217 > static FileHandle *tofileh (lua_State *L, int findex) {
218 >   FileHandle *fh = topfile(L, findex);
219 >   if (fh->f == NULL)
220 111c119
221 <   return *f;
223 >   return fh;
224 115a124,125
225 > #define newfile(L)    (&(newfileh(L)->f))
227 121,123c131,134
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' */
235 >   fh->ispipe = 0;
236 126c137
237 <   return pf;
239 >   return fh;
240 148c159,160
241 <   FILE *f = tofile(L, 1);
243 >   FileHandle *fh = tofileh(L, 1);
244 >   FILE *f = fh->f;
245 152,154c164,165
246 <     int ok = (pclose(f) != -1) || (fclose(f) == 0);
247 <     if (ok)
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 */
252 170,171c181,182
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 */
258 179,180c190,191
259 <   FILE **f = topfile(L, 1);
260 <   if (*f == NULL)
262 >   FileHandle *fh = topfile(L, 1);
263 >   if (fh->f == NULL)
264 205,207c216,219
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);
271 >   fh->ispipe = 1;
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 $
278 324,325c324
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;
283 328,330c327,331
284 <       while (n < total && tostring(L, top-n-1)) {  /* collect total length */
285 <         tl += tsvalue(top-n-1)->tsv.len;
286 <         n++;
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");
292 >         tl += l;
293 332d332
294 <       if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow");