Unified · Split
| @@ -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); | |
| @@ -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. | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Lua - An Extensible Extension Language |
| 4 | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
| 5 | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
| @@ -22,7 +22,7 @@ · 16 unmodified lines | ||
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | |
| 25 | −#define LUA_VERSION "Lua 4.0" | |
| 25 | +#define LUA_VERSION "Lua 4.0.1" | |
| 26 | 26 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" |
| 27 | 27 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
| 28 | 28 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Lua API |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -485,7 +485,7 @@ LUA_API void lua_concat (lua_State *L, int n) { · 479 unmodified lines | ||
| 485 | 485 | |
| 486 | 486 | |
| 487 | 487 | 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); | |
| 489 | 489 | tsvalue(L->top) = ts; |
| 490 | 490 | ttype(L->top) = LUA_TUSERDATA; |
| 491 | 491 | api_incr_top(L); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Stack and Call structure of Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -244,7 +244,9 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) { · 238 unmodified lines | ||
| 244 | 244 | unsigned long old_blocks; |
| 245 | 245 | int status; |
| 246 | 246 | 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); | |
| 248 | 250 | old_blocks = L->nblocks; |
| 249 | 251 | status = luaD_runprotected(L, f_parser, &p); |
| 250 | 252 | if (status == 0) { |
| @@ -274,10 +276,11 @@ static int parse_file (lua_State *L, const char *filename) { · 23 unmodified lines | ||
| 274 | 276 | lua_pushstring(L, "@"); |
| 275 | 277 | lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); |
| 276 | 278 | 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 */ | |
| 279 | 281 | luaZ_Fopen(&z, f, filename); |
| 280 | 282 | status = protectedparser(L, &z, bin); |
| 283 | + lua_remove(L, c); /* remove `filename' from the stack */ | |
| 281 | 284 | if (f != stdin) |
| 282 | 285 | fclose(f); |
| 283 | 286 | return status; |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Garbage Collector |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -336,7 +336,7 @@ void luaC_collect (lua_State *L, int all) { · 330 unmodified lines | ||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
| 339 | −static void luaC_collectgarbage (lua_State *L) { | |
| 339 | +void luaC_collectgarbage (lua_State *L) { | |
| 340 | 340 | markall(L); |
| 341 | 341 | invalidaterefs(L); /* check unlocked references */ |
| 342 | 342 | luaC_collect(L, 0); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Garbage Collector |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -12,6 +12,7 @@ · 6 unmodified lines | ||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | void luaC_collect (lua_State *L, int all); |
| 15 | +void luaC_collectgarbage (lua_State *L); | |
| 15 | 16 | void luaC_checkGC (lua_State *L); |
| 16 | 17 | |
| 17 | 18 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Basic library |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -165,7 +165,7 @@ static int luaB_globals (lua_State *L) { · 159 unmodified lines | ||
| 165 | 165 | static int luaB_rawget (lua_State *L) { |
| 166 | 166 | luaL_checktype(L, 1, LUA_TTABLE); |
| 167 | 167 | luaL_checkany(L, 2); |
| 168 | − lua_rawget(L, -2); | |
| 168 | + lua_rawget(L, 1); | |
| 169 | 169 | return 1; |
| 170 | 170 | } |
| 171 | 171 | |
| @@ -173,7 +173,7 @@ static int luaB_rawset (lua_State *L) { · 1 unmodified line | ||
| 173 | 173 | luaL_checktype(L, 1, LUA_TTABLE); |
| 174 | 174 | luaL_checkany(L, 2); |
| 175 | 175 | luaL_checkany(L, 3); |
| 176 | − lua_rawset(L, -3); | |
| 176 | + lua_rawset(L, 1); | |
| 177 | 177 | return 1; |
| 178 | 178 | } |
| 179 | 179 | |
| @@ -257,7 +257,7 @@ static int luaB_dostring (lua_State *L) { · 77 unmodified lines | ||
| 257 | 257 | int oldtop = lua_gettop(L); |
| 258 | 258 | size_t l; |
| 259 | 259 | 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... */ | |
| 261 | 261 | lua_error(L, "`dostring' cannot run pre-compiled code"); |
| 262 | 262 | return passresults(L, lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)), oldtop); |
| 263 | 263 | } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** LL(1) Parser and code generator for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -997,7 +997,7 @@ static void retstat (LexState *ls) { · 991 unmodified lines | ||
| 997 | 997 | /* stat -> RETURN explist */ |
| 998 | 998 | FuncState *fs = ls->fs; |
| 999 | 999 | next(ls); /* skip RETURN */ |
| 1000 | − if (!block_follow(ls->t.token)) | |
| 1000 | + if (!block_follow(ls->t.token) && ls->t.token != ';') | |
| 1001 | 1001 | explist1(ls); /* optional return values */ |
| 1002 | 1002 | luaK_code1(fs, OP_RETURN, ls->fs->nactloc); |
| 1003 | 1003 | fs->stacklevel = fs->nactloc; /* removes all temp values */ |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** String table (keeps all strings handled by Lua) |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -119,7 +119,7 @@ TString *luaS_newudata (lua_State *L, size_t s, void *udata) { · 113 unmodified lines | ||
| 119 | 119 | ts->nexthash = NULL; |
| 120 | 120 | ts->len = s; |
| 121 | 121 | 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; | |
| 123 | 123 | L->nblocks += sizestring(s); |
| 124 | 124 | /* insert it on table */ |
| 125 | 125 | newentry(L, &L->udt, ts, IntPoint(ts->u.d.value) & (L->udt.size-1)); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 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 $ | |
| 3 | 3 | ** Lua virtual machine |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -79,7 +79,7 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) { · 73 unmodified lines | ||
| 79 | 79 | if (newline != ci->line || pc <= ci->lastpc) { |
| 80 | 80 | ci->line = newline; |
| 81 | 81 | L->top = top; |
| 82 | − luaD_lineHook(L, base-2, newline, linehook); | |
| 82 | + luaD_lineHook(L, base-1, newline, linehook); | |
| 83 | 83 | } |
| 84 | 84 | ci->lastpc = pc; |
| 85 | 85 | } |