History

Lua 4.0.1

Lua Team committed 24 years ago

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

Showing the changes to src (8 of 11 files). Show all

Unified · Split

8 files
  1. src/lapi.c +2 −2
  2. src/ldo.c +7 −4
  3. src/lgc.c +2 −2
  4. src/lgc.h +2 −1
  5. src/lib/lbaselib.c +4 −4
  6. src/lparser.c +2 −2
  7. src/lstring.c +2 −2
  8. src/lvm.c +2 −2
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t