History

Lua 4.0.1

Lua Team committed 24 years ago

Commit c2bb7181 parent e22497f11 files · +141 −21Browse files

Unified · Split

11 files
  1. DIFFS +97 −0
  2. UPDATE +19 −0
  3. include/lua.h +2 −2
  4. src/lapi.c +2 −2
  5. src/ldo.c +7 −4
  6. src/lgc.c +2 −2
  7. src/lgc.h +2 −1
  8. src/lib/lbaselib.c +4 −4
  9. src/lparser.c +2 −2
  10. src/lstring.c +2 −2
  11. src/lvm.c +2 −2
DIFFS+97−0
@@ -0,0 +1,97 @@
1+diff -r lua-4.0/include/lua.h lua/include/lua.h
2+2c2
3+< ** $Id: lua.h,v 1.79 2000/10/31 12:44:07 roberto Exp $
4+---
5+> ** $Id: lua.h,v 1.79a 2000/10/31 12:44:07 roberto Exp $
6+25c25
7+< #define LUA_VERSION "Lua 4.0"
8+---
9+> #define LUA_VERSION "Lua 4.0.1"
10+diff -r lua-4.0/src/lapi.c lua/src/lapi.c
11+2c2
12+< ** $Id: lapi.c,v 1.110 2000/10/30 12:50:09 roberto Exp $
13+---
14+> ** $Id: lapi.c,v 1.110a 2000/10/30 12:50:09 roberto Exp $
15+488c488
16+< TString *ts = luaS_newudata(L, size, NULL);
17+---
18+> TString *ts = luaS_newudata(L, (size==0) ? 1 : size, NULL);
19+diff -r lua-4.0/src/ldo.c lua/src/ldo.c
20+2c2
21+< ** $Id: ldo.c,v 1.109 2000/10/30 12:38:50 roberto Exp $
22+---
23+> ** $Id: ldo.c,v 1.109a 2000/10/30 12:38:50 roberto Exp $
24+247c247,249
25+< luaC_checkGC(L);
26+---
27+> /* before parsing, give a (good) chance to GC */
28+> if (L->nblocks/8 >= L->GCthreshold/10)
29+> luaC_collectgarbage(L);
30+277,278c279,280
31+< filename = lua_tostring(L, -1); /* filename = '@'..filename */
32+< lua_pop(L, 1); /* OK: there is no GC during parser */
33+---
34+> c = lua_gettop(L);
35+> filename = lua_tostring(L, c); /* filename = '@'..filename */
36+280a283
37+> lua_remove(L, c); /* remove `filename' from the stack */
38+diff -r lua-4.0/src/lgc.c lua/src/lgc.c
39+2c2
40+< ** $Id: lgc.c,v 1.72 2000/10/26 12:47:05 roberto Exp $
41+---
42+> ** $Id: lgc.c,v 1.72+ 2000/10/26 12:47:05 roberto Exp $
43+339c339
44+< static void luaC_collectgarbage (lua_State *L) {
45+---
46+> void luaC_collectgarbage (lua_State *L) {
47+diff -r lua-4.0/src/lgc.h lua/src/lgc.h
48+2c2
49+< ** $Id: lgc.h,v 1.8 2000/10/02 14:47:43 roberto Exp $
50+---
51+> ** $Id: lgc.h,v 1.9 2001/02/02 16:23:20 roberto Exp $
52+14a15
53+> void luaC_collectgarbage (lua_State *L);
54+diff -r lua-4.0/src/lib/lbaselib.c lua/src/lib/lbaselib.c
55+2c2
56+< ** $Id: lbaselib.c,v 1.17 2000/11/06 13:45:18 roberto Exp $
57+---
58+> ** $Id: lbaselib.c,v 1.17a 2000/11/06 13:45:18 roberto Exp $
59+168c168
60+< lua_rawget(L, -2);
61+---
62+> lua_rawget(L, 1);
63+176c176
64+< lua_rawset(L, -3);
65+---
66+> lua_rawset(L, 1);
67+260c260
68+< if (*s == '\27') /* binary files start with ESC... */
69+---
70+> if (*s == '\33') /* binary files start with ESC... */
71+diff -r lua-4.0/src/lparser.c lua/src/lparser.c
72+2c2
73+< ** $Id: lparser.c,v 1.116 2000/10/27 11:39:52 roberto Exp $
74+---
75+> ** $Id: lparser.c,v 1.117 2000/11/29 11:57:42 roberto Exp $
76+1000c1000
77+< if (!block_follow(ls->t.token))
78+---
79+> if (!block_follow(ls->t.token) && ls->t.token != ';')
80+diff -r lua-4.0/src/lstring.c lua/src/lstring.c
81+2c2
82+< ** $Id: lstring.c,v 1.45 2000/10/30 17:49:19 roberto Exp $
83+---
84+> ** $Id: lstring.c,v 1.45a 2000/10/30 17:49:19 roberto Exp $
85+122c122
86+< ts->u.d.value = (udata == NULL) ? uts+1 : udata;
87+---
88+> ts->u.d.value = (s > 0) ? uts+1 : udata;
89+diff -r lua-4.0/src/lvm.c lua/src/lvm.c
90+2c2
91+< ** $Id: lvm.c,v 1.146 2000/10/26 12:47:05 roberto Exp $
92+---
93+> ** $Id: lvm.c,v 1.146a 2000/10/26 12:47:05 roberto Exp $
94+82c82
95+< luaD_lineHook(L, base-2, newline, linehook);
96+---
97+> luaD_lineHook(L, base-1, newline, linehook);
UPDATE+19−0
@@ -0,0 +1,19 @@
1+This is an update of Lua 4.0 that includes the following bug fixes and
2+improvements:
3+
4+lua/src/lapi.c
5+lua/src/lstring.c
6+ Fixed a bug in lua_pushuserdata(L, NULL)
7+lua/src/ldo.c
8+lua/src/lgc.c
9+lua/src/lgc.h
10+ Give a good chance for GC before parsing
11+lua/src/lparser.c
12+ Fixed a bug (did not accept `;' after a `return')
13+lua/src/lvm.c
14+ Fixed a bug (linehook off by 1)
15+lua/src/lib/lbaselib.c
16+ Fixed a bug in rawget and rawset (seg. fault if given extra arguments)
17+ Fixed a bug in dostring (identification of precompiled chunks)
18+
19+To use simply open this tarball over the original Lua 4.0 source.
include/lua.h+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.h,v 1.79 2000/10/31 12:44:07 roberto Exp $
2+** $Id: lua.h,v 1.79a 2000/10/31 12:44:07 roberto Exp $
33 ** Lua - An Extensible Extension Language
44 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
55 ** e-mail: lua@tecgraf.puc-rio.br
@@ -22,7 +22,7 @@ · 16 unmodified lines
2222 #endif
2323
2424
25−#define LUA_VERSION "Lua 4.0"
25+#define LUA_VERSION "Lua 4.0.1"
2626 #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio"
2727 #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
2828
src/lapi.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lapi.c,v 1.110 2000/10/30 12:50:09 roberto Exp $
2+** $Id: lapi.c,v 1.110a 2000/10/30 12:50:09 roberto Exp $
33 ** Lua API
44 ** See Copyright Notice in lua.h
55 */
@@ -485,7 +485,7 @@ LUA_API void lua_concat (lua_State *L, int n) { · 479 unmodified lines
485485
486486
487487 LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
488− TString *ts = luaS_newudata(L, size, NULL);
488+ TString *ts = luaS_newudata(L, (size==0) ? 1 : size, NULL);
489489 tsvalue(L->top) = ts;
490490 ttype(L->top) = LUA_TUSERDATA;
491491 api_incr_top(L);
src/ldo.c+7−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldo.c,v 1.109 2000/10/30 12:38:50 roberto Exp $
2+** $Id: ldo.c,v 1.109a 2000/10/30 12:38:50 roberto Exp $
33 ** Stack and Call structure of Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -244,7 +244,9 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) { · 238 unmodified lines
244244 unsigned long old_blocks;
245245 int status;
246246 p.z = z; p.bin = bin;
247− luaC_checkGC(L);
247+ /* before parsing, give a (good) chance to GC */
248+ if (L->nblocks/8 >= L->GCthreshold/10)
249+ luaC_collectgarbage(L);
248250 old_blocks = L->nblocks;
249251 status = luaD_runprotected(L, f_parser, &p);
250252 if (status == 0) {
@@ -274,10 +276,11 @@ static int parse_file (lua_State *L, const char *filename) { · 23 unmodified lines
274276 lua_pushstring(L, "@");
275277 lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename);
276278 lua_concat(L, 2);
277− filename = lua_tostring(L, -1); /* filename = '@'..filename */
278− lua_pop(L, 1); /* OK: there is no GC during parser */
279+ c = lua_gettop(L);
280+ filename = lua_tostring(L, c); /* filename = '@'..filename */
279281 luaZ_Fopen(&z, f, filename);
280282 status = protectedparser(L, &z, bin);
283+ lua_remove(L, c); /* remove `filename' from the stack */
281284 if (f != stdin)
282285 fclose(f);
283286 return status;
src/lgc.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lgc.c,v 1.72 2000/10/26 12:47:05 roberto Exp $
2+** $Id: lgc.c,v 1.72+ 2000/10/26 12:47:05 roberto Exp $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
@@ -336,7 +336,7 @@ void luaC_collect (lua_State *L, int all) { · 330 unmodified lines
336336 }
337337
338338
339−static void luaC_collectgarbage (lua_State *L) {
339+void luaC_collectgarbage (lua_State *L) {
340340 markall(L);
341341 invalidaterefs(L); /* check unlocked references */
342342 luaC_collect(L, 0);
src/lgc.h+2−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lgc.h,v 1.8 2000/10/02 14:47:43 roberto Exp $
2+** $Id: lgc.h,v 1.9 2001/02/02 16:23:20 roberto Exp $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
@@ -12,6 +12,7 @@ · 6 unmodified lines
1212
1313
1414 void luaC_collect (lua_State *L, int all);
15+void luaC_collectgarbage (lua_State *L);
1516 void luaC_checkGC (lua_State *L);
1617
1718
src/lib/lbaselib.c+4−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lbaselib.c,v 1.17 2000/11/06 13:45:18 roberto Exp $
2+** $Id: lbaselib.c,v 1.17a 2000/11/06 13:45:18 roberto Exp $
33 ** Basic library
44 ** See Copyright Notice in lua.h
55 */
@@ -165,7 +165,7 @@ static int luaB_globals (lua_State *L) { · 159 unmodified lines
165165 static int luaB_rawget (lua_State *L) {
166166 luaL_checktype(L, 1, LUA_TTABLE);
167167 luaL_checkany(L, 2);
168− lua_rawget(L, -2);
168+ lua_rawget(L, 1);
169169 return 1;
170170 }
171171
@@ -173,7 +173,7 @@ static int luaB_rawset (lua_State *L) { · 1 unmodified line
173173 luaL_checktype(L, 1, LUA_TTABLE);
174174 luaL_checkany(L, 2);
175175 luaL_checkany(L, 3);
176− lua_rawset(L, -3);
176+ lua_rawset(L, 1);
177177 return 1;
178178 }
179179
@@ -257,7 +257,7 @@ static int luaB_dostring (lua_State *L) { · 77 unmodified lines
257257 int oldtop = lua_gettop(L);
258258 size_t l;
259259 const char *s = luaL_check_lstr(L, 1, &l);
260− if (*s == '\27') /* binary files start with ESC... */
260+ if (*s == '\33') /* binary files start with ESC... */
261261 lua_error(L, "`dostring' cannot run pre-compiled code");
262262 return passresults(L, lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)), oldtop);
263263 }
src/lparser.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lparser.c,v 1.116 2000/10/27 11:39:52 roberto Exp $
2+** $Id: lparser.c,v 1.117 2000/11/29 11:57:42 roberto Exp $
33 ** LL(1) Parser and code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -997,7 +997,7 @@ static void retstat (LexState *ls) { · 991 unmodified lines
997997 /* stat -> RETURN explist */
998998 FuncState *fs = ls->fs;
999999 next(ls); /* skip RETURN */
1000− if (!block_follow(ls->t.token))
1000+ if (!block_follow(ls->t.token) && ls->t.token != ';')
10011001 explist1(ls); /* optional return values */
10021002 luaK_code1(fs, OP_RETURN, ls->fs->nactloc);
10031003 fs->stacklevel = fs->nactloc; /* removes all temp values */
src/lstring.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstring.c,v 1.45 2000/10/30 17:49:19 roberto Exp $
2+** $Id: lstring.c,v 1.45a 2000/10/30 17:49:19 roberto Exp $
33 ** String table (keeps all strings handled by Lua)
44 ** See Copyright Notice in lua.h
55 */
@@ -119,7 +119,7 @@ TString *luaS_newudata (lua_State *L, size_t s, void *udata) { · 113 unmodified lines
119119 ts->nexthash = NULL;
120120 ts->len = s;
121121 ts->u.d.tag = 0;
122− ts->u.d.value = (udata == NULL) ? uts+1 : udata;
122+ ts->u.d.value = (s > 0) ? uts+1 : udata;
123123 L->nblocks += sizestring(s);
124124 /* insert it on table */
125125 newentry(L, &L->udt, ts, IntPoint(ts->u.d.value) & (L->udt.size-1));
src/lvm.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lvm.c,v 1.146 2000/10/26 12:47:05 roberto Exp $
2+** $Id: lvm.c,v 1.146a 2000/10/26 12:47:05 roberto Exp $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -79,7 +79,7 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) { · 73 unmodified lines
7979 if (newline != ci->line || pc <= ci->lastpc) {
8080 ci->line = newline;
8181 L->top = top;
82− luaD_lineHook(L, base-2, newline, linehook);
82+ luaD_lineHook(L, base-1, newline, linehook);
8383 }
8484 ci->lastpc = pc;
8585 }