History

Lua 5.2.1-rc3

Lua Team committed 14 years ago

Commit daa74971 parent b19ccd47 files · +114 −85Browse files

Unified · Split

7 files
  1. README +1 −1
  2. doc/manual.html +45 −46
  3. doc/readme.html +1 −2
  4. src/lauxlib.c +3 −3
  5. src/lgc.c +59 −28
  6. src/loadlib.c +3 −3
  7. src/lstate.c +2 −2
README+1−1
@@ -1,5 +1,5 @@
11
2−This is Lua 5.2.1, released on 23 May 2012.
2+This is Lua 5.2.1, released on 01 Jun 2012.
33
44 For installation instructions, license details, and
55 further information about Lua, see doc/readme.html.
doc/manual.html+45−46
@@ -33,7 +33,7 @@ Freely available under the terms of the · 32 unmodified lines
3333 <!-- ====================================================================== -->
3434 <p>
3535
36−<!-- $Id: manual.of,v 1.97 2012/05/23 15:50:01 roberto Exp $ -->
36+<!-- $Id: manual.of,v 1.98 2012/05/31 13:01:09 roberto Exp $ -->
3737
3838
3939
@@ -2828,8 +2828,7 @@ by looking only at its arguments · 2788 unmodified lines
28282828 The third field, <code>x</code>,
28292829 tells whether the function may throw errors:
28302830 '<code>-</code>' means the function never throws any error;
2831−'<code>m</code>' means the function may throw only memory allocation errors;
2832−'<code>e</code>' means the function may throw other kinds of errors;
2831+'<code>e</code>' means the function may throw errors;
28332832 '<code>v</code>' means the function may throw an error on purpose.
28342833
28352834
@@ -3191,7 +3190,7 @@ without shifting any element · 355 unmodified lines
31913190
31923191
31933192 <hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
3194−<span class="apii">[-0, +1, <em>m</em>]</span>
3193+<span class="apii">[-0, +1, <em>e</em>]</span>
31953194 <pre>void lua_createtable (lua_State *L, int narr, int nrec);</pre>
31963195
31973196 <p>
@@ -3210,7 +3209,7 @@ Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</c · 12 unmodified lines
32103209
32113210
32123211 <hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
3213−<span class="apii">[-0, +0, <em>m</em>]</span>
3212+<span class="apii">[-0, +0, <em>e</em>]</span>
32143213 <pre>int lua_dump (lua_State *L, lua_Writer writer, void *data);</pre>
32153214
32163215 <p>
@@ -3748,7 +3747,7 @@ passes to the allocator in every call. · 531 unmodified lines
37483747
37493748
37503749 <hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
3751−<span class="apii">[-0, +1, <em>m</em>]</span>
3750+<span class="apii">[-0, +1, <em>e</em>]</span>
37523751 <pre>void lua_newtable (lua_State *L);</pre>
37533752
37543753 <p>
@@ -3760,7 +3759,7 @@ It is equivalent to <code>lua_createtable(L, 0, 0)</code>. · 5 unmodified lines
37603759
37613760
37623761 <hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
3763−<span class="apii">[-0, +1, <em>m</em>]</span>
3762+<span class="apii">[-0, +1, <em>e</em>]</span>
37643763 <pre>lua_State *lua_newthread (lua_State *L);</pre>
37653764
37663765 <p>
@@ -3781,7 +3780,7 @@ like any Lua object. · 14 unmodified lines
37813780
37823781
37833782 <hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
3784−<span class="apii">[-0, +1, <em>m</em>]</span>
3783+<span class="apii">[-0, +1, <em>e</em>]</span>
37853784 <pre>void *lua_newuserdata (lua_State *L, size_t size);</pre>
37863785
37873786 <p>
@@ -3967,7 +3966,7 @@ Pushes a boolean value with value <code>b</code> onto the stack. · 179 unmodified lines
39673966
39683967
39693968 <hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
3970−<span class="apii">[-n, +1, <em>m</em>]</span>
3969+<span class="apii">[-n, +1, <em>e</em>]</span>
39713970 <pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
39723971
39733972 <p>
@@ -4033,7 +4032,7 @@ Note that <code>f</code> is used twice. · 59 unmodified lines
40334032
40344033
40354034 <hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
4036−<span class="apii">[-0, +1, <em>m</em>]</span>
4035+<span class="apii">[-0, +1, <em>e</em>]</span>
40374036 <pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
40384037
40394038 <p>
@@ -4100,7 +4099,7 @@ light userdata with the same C&nbsp;address. · 60 unmodified lines
41004099
41014100
41024101 <hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
4103−<span class="apii">[-0, +1, <em>m</em>]</span>
4102+<span class="apii">[-0, +1, <em>e</em>]</span>
41044103 <pre>const char *lua_pushliteral (lua_State *L, const char *s);</pre>
41054104
41064105 <p>
@@ -4113,7 +4112,7 @@ It automatically provides the string length. · 6 unmodified lines
41134112
41144113
41154114 <hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
4116−<span class="apii">[-0, +1, <em>m</em>]</span>
4115+<span class="apii">[-0, +1, <em>e</em>]</span>
41174116 <pre>const char *lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
41184117
41194118 <p>
@@ -4156,7 +4155,7 @@ Pushes a number with value <code>n</code> onto the stack. · 36 unmodified lines
41564155
41574156
41584157 <hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
4159−<span class="apii">[-0, +1, <em>m</em>]</span>
4158+<span class="apii">[-0, +1, <em>e</em>]</span>
41604159 <pre>const char *lua_pushstring (lua_State *L, const char *s);</pre>
41614160
41624161 <p>
@@ -4203,7 +4202,7 @@ onto the stack. · 40 unmodified lines
42034202
42044203
42054204 <hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
4206−<span class="apii">[-0, +1, <em>m</em>]</span>
4205+<span class="apii">[-0, +1, <em>e</em>]</span>
42074206 <pre>const char *lua_pushvfstring (lua_State *L,
42084207 const char *fmt,
42094208 va_list argp);</pre>
@@ -4290,7 +4289,7 @@ for other values, it is&nbsp;0. · 80 unmodified lines
42904289
42914290
42924291 <hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
4293−<span class="apii">[-2, +0, <em>m</em>]</span>
4292+<span class="apii">[-2, +0, <em>e</em>]</span>
42944293 <pre>void lua_rawset (lua_State *L, int index);</pre>
42954294
42964295 <p>
@@ -4302,7 +4301,7 @@ Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw · 5 unmodified lines
43024301
43034302
43044303 <hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
4305−<span class="apii">[-1, +0, <em>m</em>]</span>
4304+<span class="apii">[-1, +0, <em>e</em>]</span>
43064305 <pre>void lua_rawseti (lua_State *L, int index, int n);</pre>
43074306
43084307 <p>
@@ -4321,7 +4320,7 @@ that is, it does not invoke metamethods. · 12 unmodified lines
43214320
43224321
43234322 <hr><h3><a name="lua_rawsetp"><code>lua_rawsetp</code></a></h3><p>
4324−<span class="apii">[-1, +0, <em>m</em>]</span>
4323+<span class="apii">[-1, +0, <em>e</em>]</span>
43254324 <pre>void lua_rawsetp (lua_State *L, int index, const void *p);</pre>
43264325
43274326 <p>
@@ -4669,7 +4668,7 @@ indicates whether the operation succeeded. · 341 unmodified lines
46694668
46704669
46714670 <hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
4672−<span class="apii">[-0, +0, <em>m</em>]</span>
4671+<span class="apii">[-0, +0, <em>e</em>]</span>
46734672 <pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
46744673
46754674 <p>
@@ -4752,7 +4751,7 @@ Typically this function is used only for debug information. · 76 unmodified lines
47524751
47534752
47544753 <hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
4755−<span class="apii">[-0, +0, <em>m</em>]</span>
4754+<span class="apii">[-0, +0, <em>e</em>]</span>
47564755 <pre>const char *lua_tostring (lua_State *L, int index);</pre>
47574756
47584757 <p>
@@ -5154,7 +5153,7 @@ Returns the current hook mask. · 395 unmodified lines
51545153
51555154
51565155 <hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
5157−<span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
5156+<span class="apii">[-(0|1), +(0|1|2), <em>e</em>]</span>
51585157 <pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
51595158
51605159 <p>
@@ -5553,7 +5552,7 @@ in alphabetical order. · 392 unmodified lines
55535552
55545553
55555554 <hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
5556−<span class="apii">[-?, +?, <em>m</em>]</span>
5555+<span class="apii">[-?, +?, <em>e</em>]</span>
55575556 <pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
55585557
55595558 <p>
@@ -5565,7 +5564,7 @@ Adds the byte <code>c</code> to the buffer <code>B</code> · 5 unmodified lines
55655564
55665565
55675566 <hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
5568−<span class="apii">[-?, +?, <em>m</em>]</span>
5567+<span class="apii">[-?, +?, <em>e</em>]</span>
55695568 <pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
55705569
55715570 <p>
@@ -5579,7 +5578,7 @@ The string can contain embedded zeros. · 7 unmodified lines
55795578
55805579
55815580 <hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
5582−<span class="apii">[-?, +?, <em>m</em>]</span>
5581+<span class="apii">[-?, +?, <em>e</em>]</span>
55835582 <pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
55845583
55855584 <p>
@@ -5592,7 +5591,7 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>). · 6 unmodified lines
55925591
55935592
55945593 <hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
5595−<span class="apii">[-?, +?, <em>m</em>]</span>
5594+<span class="apii">[-?, +?, <em>e</em>]</span>
55965595 <pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
55975596
55985597 <p>
@@ -5606,7 +5605,7 @@ The string cannot contain embedded zeros. · 7 unmodified lines
56065605
56075606
56085607 <hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
5609−<span class="apii">[-1, +?, <em>m</em>]</span>
5608+<span class="apii">[-1, +?, <em>e</em>]</span>
56105609 <pre>void luaL_addvalue (luaL_Buffer *B);</pre>
56115610
56125611 <p>
@@ -5743,7 +5742,7 @@ the buffer must be declared as a variable · 130 unmodified lines
57435742
57445743
57455744 <hr><h3><a name="luaL_buffinitsize"><code>luaL_buffinitsize</code></a></h3><p>
5746−<span class="apii">[-?, +?, <em>m</em>]</span>
5745+<span class="apii">[-?, +?, <em>e</em>]</span>
57475746 <pre>char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
57485747
57495748 <p>
@@ -5970,7 +5969,7 @@ are using the same address space. · 220 unmodified lines
59705969
59715970
59725971 <hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
5973−<span class="apii">[-0, +?, <em>m</em>]</span>
5972+<span class="apii">[-0, +?, <em>e</em>]</span>
59745973 <pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
59755974
59765975 <p>
@@ -6029,7 +6028,7 @@ as <code>return luaL_error(<em>args</em>)</code>. · 52 unmodified lines
60296028
60306029
60316030 <hr><h3><a name="luaL_execresult"><code>luaL_execresult</code></a></h3><p>
6032−<span class="apii">[-0, +3, <em>m</em>]</span>
6031+<span class="apii">[-0, +3, <em>e</em>]</span>
60336032 <pre>int luaL_execresult (lua_State *L, int stat);</pre>
60346033
60356034 <p>
@@ -6042,7 +6041,7 @@ process-related functions in the standard library · 6 unmodified lines
60426041
60436042
60446043 <hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>
6045−<span class="apii">[-0, +(1|3), <em>m</em>]</span>
6044+<span class="apii">[-0, +(1|3), <em>e</em>]</span>
60466045 <pre>int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre>
60476046
60486047 <p>
@@ -6055,7 +6054,7 @@ file-related functions in the standard library · 6 unmodified lines
60556054
60566055
60576056 <hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
6058−<span class="apii">[-0, +(0|1), <em>m</em>]</span>
6057+<span class="apii">[-0, +(0|1), <em>e</em>]</span>
60596058 <pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
60606059
60616060 <p>
@@ -6082,7 +6081,7 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code> · 20 unmodified lines
60826081
60836082
60846083 <hr><h3><a name="luaL_getsubtable"><code>luaL_getsubtable</code></a></h3><p>
6085−<span class="apii">[-0, +1, <em>m</em>]</span>
6084+<span class="apii">[-0, +1, <em>e</em>]</span>
60866085 <pre>int luaL_getsubtable (lua_State *L, int idx, const char *fname);</pre>
60876086
60886087 <p>
@@ -6098,7 +6097,7 @@ and false if it creates a new table. · 9 unmodified lines
60986097
60996098
61006099 <hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
6101−<span class="apii">[-0, +1, <em>m</em>]</span>
6100+<span class="apii">[-0, +1, <em>e</em>]</span>
61026101 <pre>const char *luaL_gsub (lua_State *L,
61036102 const char *s,
61046103 const char *p,
@@ -6168,7 +6167,7 @@ The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_ · 63 unmodified lines
61686167
61696168
61706169 <hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
6171−<span class="apii">[-0, +1, <em>m</em>]</span>
6170+<span class="apii">[-0, +1, <em>e</em>]</span>
61726171 <pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
61736172
61746173 <p>
@@ -6179,7 +6178,7 @@ Equivalent to <a href="#luaL_loadfilex"><code>luaL_loadfilex</code></a> with <co · 4 unmodified lines
61796178
61806179
61816180 <hr><h3><a name="luaL_loadfilex"><code>luaL_loadfilex</code></a></h3><p>
6182−<span class="apii">[-0, +1, <em>m</em>]</span>
6181+<span class="apii">[-0, +1, <em>e</em>]</span>
61836182 <pre>int luaL_loadfilex (lua_State *L, const char *filename,
61846183 const char *mode);</pre>
61856184
@@ -6233,7 +6232,7 @@ it does not run it. · 47 unmodified lines
62336232
62346233
62356234 <hr><h3><a name="luaL_newlib"><code>luaL_newlib</code></a></h3><p>
6236−<span class="apii">[-0, +1, <em>m</em>]</span>
6235+<span class="apii">[-0, +1, <em>e</em>]</span>
62376236 <pre>int luaL_newlib (lua_State *L, const luaL_Reg *l);</pre>
62386237
62396238 <p>
@@ -6249,7 +6248,7 @@ It is implemented as the following macro: · 9 unmodified lines
62496248
62506249
62516250 <hr><h3><a name="luaL_newlibtable"><code>luaL_newlibtable</code></a></h3><p>
6252−<span class="apii">[-0, +1, <em>m</em>]</span>
6251+<span class="apii">[-0, +1, <em>e</em>]</span>
62536252 <pre>int luaL_newlibtable (lua_State *L, const luaL_Reg l[]);</pre>
62546253
62556254 <p>
@@ -6270,7 +6269,7 @@ not a pointer to it. · 14 unmodified lines
62706269
62716270
62726271 <hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
6273−<span class="apii">[-0, +1, <em>m</em>]</span>
6272+<span class="apii">[-0, +1, <em>e</em>]</span>
62746273 <pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
62756274
62766275 <p>
@@ -6442,7 +6441,7 @@ Otherwise, raises an error. · 165 unmodified lines
64426441
64436442
64446443 <hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
6445−<span class="apii">[-?, +?, <em>m</em>]</span>
6444+<span class="apii">[-?, +?, <em>e</em>]</span>
64466445 <pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
64476446
64486447 <p>
@@ -6454,7 +6453,7 @@ with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</co · 5 unmodified lines
64546453
64556454
64566455 <hr><h3><a name="luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a></h3><p>
6457−<span class="apii">[-?, +?, <em>m</em>]</span>
6456+<span class="apii">[-?, +?, <em>e</em>]</span>
64586457 <pre>char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
64596458
64606459 <p>
@@ -6470,7 +6469,7 @@ it to the buffer. · 9 unmodified lines
64706469
64716470
64726471 <hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
6473−<span class="apii">[-?, +1, <em>m</em>]</span>
6472+<span class="apii">[-?, +1, <em>e</em>]</span>
64746473 <pre>void luaL_pushresult (luaL_Buffer *B);</pre>
64756474
64766475 <p>
@@ -6482,7 +6481,7 @@ the top of the stack. · 5 unmodified lines
64826481
64836482
64846483 <hr><h3><a name="luaL_pushresultsize"><code>luaL_pushresultsize</code></a></h3><p>
6485−<span class="apii">[-?, +1, <em>m</em>]</span>
6484+<span class="apii">[-?, +1, <em>e</em>]</span>
64866485 <pre>void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
64876486
64886487 <p>
@@ -6493,7 +6492,7 @@ Equivalent to the sequence <a href="#luaL_addsize"><code>luaL_addsize</code></a> · 4 unmodified lines
64936492
64946493
64956494 <hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
6496−<span class="apii">[-1, +0, <em>m</em>]</span>
6495+<span class="apii">[-1, +0, <em>e</em>]</span>
64976496 <pre>int luaL_ref (lua_State *L, int t);</pre>
64986497
64996498 <p>
@@ -6597,7 +6596,7 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code> · 97 unmodified lines
65976596
65986597
65996598 <hr><h3><a name="luaL_testudata"><code>luaL_testudata</code></a></h3><p>
6600−<span class="apii">[-0, +0, <em>m</em>]</span>
6599+<span class="apii">[-0, +0, <em>e</em>]</span>
66016600 <pre>void *luaL_testudata (lua_State *L, int arg, const char *tname);</pre>
66026601
66036602 <p>
@@ -6633,7 +6632,7 @@ and uses the result of the call as its result. · 29 unmodified lines
66336632
66346633
66356634 <hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p>
6636−<span class="apii">[-0, +1, <em>m</em>]</span>
6635+<span class="apii">[-0, +1, <em>e</em>]</span>
66376636 <pre>void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
66386637 int level);</pre>
66396638
@@ -6680,7 +6679,7 @@ If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a · 40 unmodified lines
66806679
66816680
66826681 <hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
6683−<span class="apii">[-0, +1, <em>m</em>]</span>
6682+<span class="apii">[-0, +1, <em>e</em>]</span>
66846683 <pre>void luaL_where (lua_State *L, int lvl);</pre>
66856684
66866685 <p>
@@ -10407,7 +10406,7 @@ Here is the complete syntax of Lua in extended BNF. · 3720 unmodified lines
1040710406 <HR>
1040810407 <SMALL CLASS="footer">
1040910408 Last update:
10410−Wed May 23 13:28:41 BRT 2012
10409+Fri Jun 1 12:38:38 BRT 2012
1041110410 </SMALL>
1041210411 <!--
1041310412 Last change: revised for Lua 5.2.1
doc/readme.html+1−2
@@ -43,7 +43,6 @@ Welcome to Lua 5.2 · 42 unmodified lines
4343 <A HREF="#license">license</A>
4444 &middot;
4545 <A HREF="contents.html">reference manual</A>
46−<HR>
4746
4847 <H2><A NAME="about">About Lua</A></H2>
4948
@@ -401,7 +400,7 @@ THE SOFTWARE. · 351 unmodified lines
401400 <HR>
402401 <SMALL CLASS="footer">
403402 Last update:
404−Thu May 17 11:09:49 BRT 2012
403+Tue May 29 21:57:51 BRT 2012
405404 </SMALL>
406405 <!--
407406 Last change: revised for Lua 5.2.1
src/lauxlib.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lauxlib.c,v 1.243 2012/04/20 17:05:17 roberto Exp $
2+** $Id: lauxlib.c,v 1.244 2012/05/31 20:28:45 roberto Exp $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -520,11 +520,11 @@ LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { · 514 unmodified lines
520520
521521 LUALIB_API int luaL_ref (lua_State *L, int t) {
522522 int ref;
523− t = lua_absindex(L, t);
524523 if (lua_isnil(L, -1)) {
525524 lua_pop(L, 1); /* remove from stack */
526525 return LUA_REFNIL; /* `nil' has a unique fixed reference */
527526 }
527+ t = lua_absindex(L, t);
528528 lua_rawgeti(L, t, freelist); /* get first free element */
529529 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
530530 lua_pop(L, 1); /* remove it from stack */
@@ -866,8 +866,8 @@ LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { · 335 unmodified lines
866866 lua_getfield(L, idx, fname);
867867 if (lua_istable(L, -1)) return 1; /* table already there */
868868 else {
869− idx = lua_absindex(L, idx);
870869 lua_pop(L, 1); /* remove previous result */
870+ idx = lua_absindex(L, idx);
871871 lua_newtable(L);
872872 lua_pushvalue(L, -1); /* copy to be left at top */
873873 lua_setfield(L, idx, fname); /* assign new table to field */
src/lgc.c+59−28
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lgc.c,v 2.129 2012/05/28 20:41:00 roberto Exp $
2+** $Id: lgc.c,v 2.133 2012/05/31 21:28:59 roberto Exp $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
@@ -753,6 +753,21 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { · 747 unmodified lines
753753 return (*p == NULL) ? NULL : p;
754754 }
755755
756+
757+/*
758+** sweep a list until a live object (or end of list)
759+*/
760+static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
761+ GCObject ** old = p;
762+ int i = 0;
763+ do {
764+ i++;
765+ p = sweeplist(L, p, 1);
766+ } while (p == old);
767+ if (n) *n += i;
768+ return p;
769+}
770+
756771 /* }====================================================== */
757772
758773
@@ -812,12 +827,14 @@ static void GCTM (lua_State *L, int propagateerrors) { · 53 unmodified lines
812827 L->allowhook = oldah; /* restore hooks */
813828 g->gcrunning = running; /* restore state */
814829 if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
815− if (status == LUA_ERRRUN) { /* is there an error msg.? */
816− luaO_pushfstring(L, "error in __gc metamethod (%s)",
817− lua_tostring(L, -1));
830+ if (status == LUA_ERRRUN) { /* is there an error object? */
831+ const char *msg = (ttisstring(L->top - 1))
832+ ? svalue(L->top - 1)
833+ : "no message";
834+ luaO_pushfstring(L, "error in __gc metamethod (%s)", msg);
818835 status = LUA_ERRGCMM; /* error in __gc metamethod */
819836 }
820− luaD_throw(L, status); /* re-send error */
837+ luaD_throw(L, status); /* re-throw error */
821838 }
822839 }
823840 }
@@ -864,10 +881,9 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { · 40 unmodified lines
864881 else { /* move 'o' to 'finobj' list */
865882 GCObject **p;
866883 GCheader *ho = gch(o);
867− /* avoid removing current sweep object */
868− if (g->sweepgc == &ho->next) {
869− /* step to next object in the list */
870− g->sweepgc = (ho->next == NULL) ? NULL : &gch(ho->next)->next;
884+ if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */
885+ lua_assert(issweepphase(g));
886+ g->sweepgc = sweeptolive(L, g->sweepgc, NULL);
871887 }
872888 /* search for pointer pointing to 'o' */
873889 for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ }
@@ -875,7 +891,10 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { · 1 unmodified line
875891 ho->next = g->finobj; /* link it in list 'finobj' */
876892 g->finobj = o;
877893 l_setbit(ho->marked, SEPARATED); /* mark it as such */
878− resetoldbit(o); /* see MOVE OLD rule */
894+ if (!keepinvariant(g)) /* not keeping invariant? */
895+ makewhite(g, o); /* "sweep" object */
896+ else
897+ resetoldbit(o); /* see MOVE OLD rule */
879898 }
880899 }
881900
@@ -895,18 +914,22 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { · 13 unmodified lines
895914
896915 /*
897916 ** enter first sweep phase (strings) and prepare pointers for other
898−** sweep phases. The calls to 'sweeplist' attempt to make pointers
899−** point to an object inside the list (instead of to the header), so
900−** that the real sweep do not need to skip objects created between "now"
901−** and the start of the real sweep.
917+** sweep phases. The calls to 'sweeptolive' make pointers point to an
918+** object inside the list (instead of to the header), so that the real
919+** sweep do not need to skip objects created between "now" and the start
920+** of the real sweep.
921+** Returns how many objects it sweeped.
902922 */
903−static void entersweep (lua_State *L) {
923+static int entersweep (lua_State *L) {
904924 global_State *g = G(L);
925+ int n = 0;
905926 g->gcstate = GCSsweepstring;
906927 lua_assert(g->sweepgc == NULL && g->sweepfin == NULL);
907− g->sweepstrgc = 0; /* prepare to sweep strings, ... */
908− g->sweepfin = sweeplist(L, &g->finobj, 1); /* finalizable objects, ... */
909− g->sweepgc = sweeplist(L, &g->allgc, 1); /* and regular objects */
928+ /* prepare to sweep strings, finalizable objects, and regular objects */
929+ g->sweepstrgc = 0;
930+ g->sweepfin = sweeptolive(L, &g->finobj, &n);
931+ g->sweepgc = sweeptolive(L, &g->allgc, &n);
932+ return n;
910933 }
911934
912935
@@ -962,7 +985,7 @@ void luaC_freeallobjects (lua_State *L) { · 49 unmodified lines
962985
963986 static l_mem atomic (lua_State *L) {
964987 global_State *g = G(L);
965− l_mem trav = g->GCmemtrav;
988+ l_mem work = -g->GCmemtrav; /* start counting work */
966989 GCObject *origweak, *origall;
967990 lua_assert(!iswhite(obj2gco(g->mainthread)));
968991 markobject(g, L); /* mark running thread */
@@ -971,18 +994,22 @@ static l_mem atomic (lua_State *L) { · 2 unmodified lines
971994 markmt(g); /* mark basic metatables */
972995 /* remark occasional upvalues of (maybe) dead threads */
973996 remarkupvals(g);
997+ propagateall(g); /* propagate changes */
998+ work += g->GCmemtrav; /* stop counting (do not (re)count grays) */
974999 /* traverse objects caught by write barrier and by 'remarkupvals' */
9751000 retraversegrays(g);
1001+ work -= g->GCmemtrav; /* restart counting */
9761002 convergeephemerons(g);
9771003 /* at this point, all strongly accessible objects are marked. */
9781004 /* clear values from weak tables, before checking finalizers */
9791005 clearvalues(g, g->weak, NULL);
9801006 clearvalues(g, g->allweak, NULL);
9811007 origweak = g->weak; origall = g->allweak;
1008+ work += g->GCmemtrav; /* stop counting (objects being finalized) */
9821009 separatetobefnz(L, 0); /* separate objects to be finalized */
983− markbeingfnz(g); /* mark userdata that will be finalized */
1010+ markbeingfnz(g); /* mark objects that will be finalized */
9841011 propagateall(g); /* remark, to propagate `preserveness' */
985− trav = g->GCmemtrav - trav; /* avoid adding convergence twice */
1012+ work -= g->GCmemtrav; /* restart counting */
9861013 convergeephemerons(g);
9871014 /* at this point, all resurrected objects are marked. */
9881015 /* remove dead objects from weak tables */
@@ -992,9 +1019,8 @@ static l_mem atomic (lua_State *L) { · 3 unmodified lines
9921019 clearvalues(g, g->weak, origweak);
9931020 clearvalues(g, g->allweak, origall);
9941021 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
995− entersweep(L); /* prepare to sweep strings */
996− /*lua_checkmemory(L);*/
997− return trav; /* reasonable estimate of the work done by 'atomic' */
1022+ work += g->GCmemtrav; /* complete counting */
1023+ return work; /* estimate of memory marked by 'atomic' */
9981024 }
9991025
10001026
@@ -1018,9 +1044,14 @@ static lu_mem singlestep (lua_State *L) { · 17 unmodified lines
10181044 return g->GCmemtrav - oldtrav; /* memory traversed in this step */
10191045 }
10201046 else { /* no more `gray' objects */
1047+ lu_mem work;
1048+ int sw;
10211049 g->gcstate = GCSatomic; /* finish mark phase */
1022− g->GCestimate = g->GCmemtrav; /* save what was counted */
1023− return atomic(L);
1050+ g->GCestimate = g->GCmemtrav; /* save what was counted */;
1051+ work = atomic(L); /* add what was traversed by 'atomic' */
1052+ g->GCestimate += work; /* estimate of total memory traversed */
1053+ sw = entersweep(L);
1054+ return work + sw * GCSWEEPCOST;
10241055 }
10251056 }
10261057 case GCSsweepstring: {
@@ -1089,7 +1120,7 @@ static void generationalcollection (lua_State *L) { · 62 unmodified lines
10891120 }
10901121
10911122
1092−static void step (lua_State *L) {
1123+static void incstep (lua_State *L) {
10931124 global_State *g = G(L);
10941125 l_mem debt = g->GCdebt;
10951126 int stepmul = g->gcstepmul;
@@ -1116,7 +1147,7 @@ void luaC_forcestep (lua_State *L) { · 20 unmodified lines
11161147 global_State *g = G(L);
11171148 int i;
11181149 if (isgenerational(g)) generationalcollection(L);
1119− else step(L);
1150+ else incstep(L);
11201151 /* run a few finalizers (or all of them at the end of a collect cycle) */
11211152 for (i = 0; g->tobefnz && (i < GCFINALIZENUM || g->gcstate == GCSpause); i++)
11221153 GCTM(L, 1); /* call one finalizer */
src/loadlib.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: loadlib.c,v 1.110 2012/04/26 19:38:52 roberto Exp $
2+** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $
33 ** Dynamic library loader for Lua
44 ** See Copyright Notice in lua.h
55 **
@@ -482,9 +482,9 @@ static void findloader (lua_State *L, const char *name) { · 476 unmodified lines
482482 lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */
483483 if (!lua_istable(L, 3))
484484 luaL_error(L, LUA_QL("package.searchers") " must be a table");
485− /* iterate over available seachers to find a loader */
485+ /* iterate over available searchers to find a loader */
486486 for (i = 1; ; i++) {
487− lua_rawgeti(L, 3, i); /* get a seacher */
487+ lua_rawgeti(L, 3, i); /* get a searcher */
488488 if (lua_isnil(L, -1)) { /* no more searchers? */
489489 lua_pop(L, 1); /* remove nil */
490490 luaL_pushresult(&msg); /* create error message */
src/lstate.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstate.c,v 2.97 2012/05/23 15:37:09 roberto Exp $
2+** $Id: lstate.c,v 2.98 2012/05/30 12:33:44 roberto Exp $
33 ** Global State
44 ** See Copyright Notice in lua.h
55 */
@@ -79,7 +79,7 @@ typedef struct LG { · 73 unmodified lines
7979
8080 /*
8181 ** Compute an initial seed as random as possible. In ANSI, rely on
82−** Address Space Layour Randomization (if present) to increase
82+** Address Space Layout Randomization (if present) to increase
8383 ** randomness..
8484 */
8585 #define addbuff(b,p,e) \