diffu-lua-5.5.0-lua-5.5.1
Makefile
@@ -36,7 +36,7 @@
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
# Convenience platforms targets.
-PLATS= guess aix bsd c89 freebsd generic ios linux macosx mingw posix solaris
+PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
@@ -46,7 +46,7 @@
# Lua version and release.
V= 5.5
-R= $V.0
+R= $V.1
# Targets start here.
all: $(PLAT)
README
@@ -1,5 +1,5 @@
-This is Lua 5.5.0, released on 15 Dec 2025.
+This is Lua 5.5.1, released on 24 Jul 2026.
For installation instructions, license details, and
further information about Lua, see doc/readme.html.
doc/contents.html
@@ -32,7 +32,7 @@
<P>
<SMALL>
-Copyright © 2020–2025 Lua.org, PUC-Rio.
+Copyright © 2020–2026 Lua.org, PUC-Rio.
Freely available under the terms of the
<A HREF="https://www.lua.org/license.html">Lua license</A>.
</SMALL>
@@ -705,10 +705,10 @@
<P CLASS="footer">
Last update:
-Thu Dec 4 17:32:26 UTC 2025
+Mon Jul 13 21:19:58 UTC 2026
</P>
<!--
-Last change: revised for Lua 5.5.0
+Last change: revised for Lua 5.5.1
-->
</BODY>
doc/manual.css
@@ -7,6 +7,10 @@
font-size: 12pt ;
}
+pre.api {
+ white-space: normal ;
+}
+
span.apii {
color: gray ;
float: right ;
doc/manual.html
@@ -19,7 +19,7 @@
<P>
<SMALL>
-Copyright © 2020–2025 Lua.org, PUC-Rio.
+Copyright © 2020–2026 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="https://www.lua.org/license.html">Lua license</a>.
</SMALL>
@@ -2100,7 +2100,7 @@
X = 1 -- ERROR
_ENV.X = 1 -- Ok
_G.print(X) -- Ok
- foo() -- 'foo' can freely change any global
+ foo() -- 'foo' can freely change any global
</pre>
<p>
@@ -3263,7 +3263,21 @@
<h3>4.1.3 – <a name="4.1.3">Pointers to Strings</a></h3>
<p>
-Several functions in the API return pointers (<code>const char*</code>)
+Several functions in the API have parameters
+that are pointers to C strings (<code>const char*</code>).
+Some of these parameters have an associated length (<code>size_t</code>).
+Unless stated otherwise,
+when there is an associated length,
+the string can contain embedded zeros;
+moreover, the pointer can be <code>NULL</code> if the length is zero.
+When there is no associated length,
+the pointer must point to a zero-terminated string.
+In any case, the string contents should remain unchanged
+until the function returns.
+
+
+<p>
+Several functions in the API also return pointers (<code>const char*</code>)
to Lua strings in the stack.
(See <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>, <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,
<a href="#lua_pushstring"><code>lua_pushstring</code></a>, and <a href="#lua_tolstring"><code>lua_tolstring</code></a>.
@@ -3672,7 +3686,7 @@
<hr><h3><a name="lua_absindex"><code>lua_absindex</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_absindex (lua_State *L, int idx);</pre>
+<pre class="api">int lua_absindex (lua_State *L, int idx);</pre>
<p>
Converts the acceptable index <code>idx</code>
@@ -3684,7 +3698,7 @@
<hr><h3><a name="lua_Alloc"><code>lua_Alloc</code></a></h3>
-<pre>typedef void * (*lua_Alloc) (void *ud,
+<pre class="api">typedef void * (*lua_Alloc) (void *ud,
void *ptr,
size_t osize,
size_t nsize);</pre>
@@ -3763,7 +3777,7 @@
<hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p>
<span class="apii">[-(2|1), +1, <em>e</em>]</span>
-<pre>void lua_arith (lua_State *L, int op);</pre>
+<pre class="api">void lua_arith (lua_State *L, int op);</pre>
<p>
Performs an arithmetic or bitwise operation over the two values
@@ -3802,7 +3816,7 @@
<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
+<pre class="api">lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
<p>
Sets a new panic function and returns the old one (see <a href="#4.4">§4.4</a>).
@@ -3813,7 +3827,7 @@
<hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
<span class="apii">[-(nargs+1), +nresults, <em>e</em>]</span>
-<pre>void lua_call (lua_State *L, int nargs, int nresults);</pre>
+<pre class="api">void lua_call (lua_State *L, int nargs, int nresults);</pre>
<p>
Calls a function.
@@ -3886,7 +3900,7 @@
<hr><h3><a name="lua_callk"><code>lua_callk</code></a></h3><p>
<span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
-<pre>void lua_callk (lua_State *L,
+<pre class="api">void lua_callk (lua_State *L,
int nargs,
int nresults,
lua_KContext ctx,
@@ -3901,7 +3915,7 @@
<hr><h3><a name="lua_CFunction"><code>lua_CFunction</code></a></h3>
-<pre>typedef int (*lua_CFunction) (lua_State *L);</pre>
+<pre class="api">typedef int (*lua_CFunction) (lua_State *L);</pre>
<p>
Type for C functions.
@@ -3953,7 +3967,7 @@
<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_checkstack (lua_State *L, int n);</pre>
+<pre class="api">int lua_checkstack (lua_State *L, int n);</pre>
<p>
Ensures that the stack has space for at least <code>n</code> extra elements,
@@ -3973,7 +3987,7 @@
<hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_close (lua_State *L);</pre>
+<pre class="api">void lua_close (lua_State *L);</pre>
<p>
Close all active to-be-closed variables in the main thread,
@@ -3995,7 +4009,7 @@
<hr><h3><a name="lua_closeslot"><code>lua_closeslot</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>void lua_closeslot (lua_State *L, int index);</pre>
+<pre class="api">void lua_closeslot (lua_State *L, int index);</pre>
<p>
Close the to-be-closed slot at the given index and set its value to <b>nil</b>.
@@ -4013,7 +4027,7 @@
<hr><h3><a name="lua_closethread"><code>lua_closethread</code></a></h3><p>
<span class="apii">[-0, +?, –]</span>
-<pre>int lua_closethread (lua_State *L, lua_State *from);</pre>
+<pre class="api">int lua_closethread (lua_State *L, lua_State *from);</pre>
<p>
Resets a thread, cleaning its call stack and closing all pending
@@ -4048,7 +4062,7 @@
<hr><h3><a name="lua_compare"><code>lua_compare</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>int lua_compare (lua_State *L, int index1, int index2, int op);</pre>
+<pre class="api">int lua_compare (lua_State *L, int index1, int index2, int op);</pre>
<p>
Compares two Lua values.
@@ -4076,7 +4090,7 @@
<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
<span class="apii">[-n, +1, <em>e</em>]</span>
-<pre>void lua_concat (lua_State *L, int n);</pre>
+<pre class="api">void lua_concat (lua_State *L, int n);</pre>
<p>
Concatenates the <code>n</code> values at the top of the stack,
@@ -4093,7 +4107,7 @@
<hr><h3><a name="lua_copy"><code>lua_copy</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_copy (lua_State *L, int fromidx, int toidx);</pre>
+<pre class="api">void lua_copy (lua_State *L, int fromidx, int toidx);</pre>
<p>
Copies the element at index <code>fromidx</code>
@@ -4107,7 +4121,7 @@
<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void lua_createtable (lua_State *L, int nseq, int nrec);</pre>
+<pre class="api">void lua_createtable (lua_State *L, int nseq, int nrec);</pre>
<p>
Creates a new empty table and pushes it onto the stack.
@@ -4126,7 +4140,7 @@
<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_dump (lua_State *L,
+<pre class="api">int lua_dump (lua_State *L,
lua_Writer writer,
void *data,
int strip);</pre>
@@ -4170,7 +4184,7 @@
<hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
<span class="apii">[-1, +0, <em>v</em>]</span>
-<pre>int lua_error (lua_State *L);</pre>
+<pre class="api">int lua_error (lua_State *L);</pre>
<p>
Raises a Lua error,
@@ -4185,7 +4199,7 @@
<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_gc (lua_State *L, int what, ...);</pre>
+<pre class="api">int lua_gc (lua_State *L, int what, ...);</pre>
<p>
Controls the garbage collector.
@@ -4270,7 +4284,7 @@
<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
+<pre class="api">lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
<p>
Returns the memory-allocator function of a given state.
@@ -4283,7 +4297,7 @@
<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>int lua_getfield (lua_State *L, int index, const char *k);</pre>
+<pre class="api">int lua_getfield (lua_State *L, int index, const char *k);</pre>
<p>
Pushes onto the stack the value <code>t[k]</code>,
@@ -4301,7 +4315,7 @@
<hr><h3><a name="lua_getextraspace"><code>lua_getextraspace</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void *lua_getextraspace (lua_State *L);</pre>
+<pre class="api">void *lua_getextraspace (lua_State *L);</pre>
<p>
Returns a pointer to a raw memory area associated with the
@@ -4326,7 +4340,7 @@
<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>int lua_getglobal (lua_State *L, const char *name);</pre>
+<pre class="api">int lua_getglobal (lua_State *L, const char *name);</pre>
<p>
Pushes onto the stack the value of the global <code>name</code>.
@@ -4338,7 +4352,7 @@
<hr><h3><a name="lua_geti"><code>lua_geti</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>int lua_geti (lua_State *L, int index, lua_Integer i);</pre>
+<pre class="api">int lua_geti (lua_State *L, int index, lua_Integer i);</pre>
<p>
Pushes onto the stack the value <code>t[i]</code>,
@@ -4356,7 +4370,7 @@
<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
<span class="apii">[-0, +(0|1), –]</span>
-<pre>int lua_getmetatable (lua_State *L, int index);</pre>
+<pre class="api">int lua_getmetatable (lua_State *L, int index);</pre>
<p>
If the value at the given index has a metatable,
@@ -4370,7 +4384,7 @@
<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
<span class="apii">[-1, +1, <em>e</em>]</span>
-<pre>int lua_gettable (lua_State *L, int index);</pre>
+<pre class="api">int lua_gettable (lua_State *L, int index);</pre>
<p>
Pushes onto the stack the value <code>t[k]</code>,
@@ -4394,7 +4408,7 @@
<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_gettop (lua_State *L);</pre>
+<pre class="api">int lua_gettop (lua_State *L);</pre>
<p>
Returns the index of the top element in the stack.
@@ -4408,7 +4422,7 @@
<hr><h3><a name="lua_getiuservalue"><code>lua_getiuservalue</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int lua_getiuservalue (lua_State *L, int index, int n);</pre>
+<pre class="api">int lua_getiuservalue (lua_State *L, int index, int n);</pre>
<p>
Pushes onto the stack the <code>n</code>-th user value associated with the
@@ -4426,7 +4440,7 @@
<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
<span class="apii">[-1, +1, –]</span>
-<pre>void lua_insert (lua_State *L, int index);</pre>
+<pre class="api">void lua_insert (lua_State *L, int index);</pre>
<p>
Moves the top element into the given valid index,
@@ -4439,7 +4453,7 @@
<hr><h3><a name="lua_Integer"><code>lua_Integer</code></a></h3>
-<pre>typedef ... lua_Integer;</pre>
+<pre class="api">typedef ... lua_Integer;</pre>
<p>
The type of integers in Lua.
@@ -4464,7 +4478,7 @@
<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isboolean (lua_State *L, int index);</pre>
+<pre class="api">int lua_isboolean (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a boolean,
@@ -4476,7 +4490,7 @@
<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_iscfunction (lua_State *L, int index);</pre>
+<pre class="api">int lua_iscfunction (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a C function,
@@ -4488,7 +4502,7 @@
<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isfunction (lua_State *L, int index);</pre>
+<pre class="api">int lua_isfunction (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a function
@@ -4500,7 +4514,7 @@
<hr><h3><a name="lua_isinteger"><code>lua_isinteger</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isinteger (lua_State *L, int index);</pre>
+<pre class="api">int lua_isinteger (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is an integer
@@ -4513,7 +4527,7 @@
<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_islightuserdata (lua_State *L, int index);</pre>
+<pre class="api">int lua_islightuserdata (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a light userdata,
@@ -4525,7 +4539,7 @@
<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isnil (lua_State *L, int index);</pre>
+<pre class="api">int lua_isnil (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is <b>nil</b>,
@@ -4537,7 +4551,7 @@
<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isnone (lua_State *L, int index);</pre>
+<pre class="api">int lua_isnone (lua_State *L, int index);</pre>
<p>
Returns 1 if the given index is not valid,
@@ -4549,7 +4563,7 @@
<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isnoneornil (lua_State *L, int index);</pre>
+<pre class="api">int lua_isnoneornil (lua_State *L, int index);</pre>
<p>
Returns 1 if the given index is not valid
@@ -4562,7 +4576,7 @@
<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isnumber (lua_State *L, int index);</pre>
+<pre class="api">int lua_isnumber (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a number
@@ -4575,7 +4589,7 @@
<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isstring (lua_State *L, int index);</pre>
+<pre class="api">int lua_isstring (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a string
@@ -4588,7 +4602,7 @@
<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_istable (lua_State *L, int index);</pre>
+<pre class="api">int lua_istable (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a table,
@@ -4600,7 +4614,7 @@
<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isthread (lua_State *L, int index);</pre>
+<pre class="api">int lua_isthread (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a thread,
@@ -4612,7 +4626,7 @@
<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isuserdata (lua_State *L, int index);</pre>
+<pre class="api">int lua_isuserdata (lua_State *L, int index);</pre>
<p>
Returns 1 if the value at the given index is a userdata
@@ -4624,7 +4638,7 @@
<hr><h3><a name="lua_isyieldable"><code>lua_isyieldable</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_isyieldable (lua_State *L);</pre>
+<pre class="api">int lua_isyieldable (lua_State *L);</pre>
<p>
Returns 1 if the given coroutine can yield,
@@ -4635,7 +4649,7 @@
<hr><h3><a name="lua_KContext"><code>lua_KContext</code></a></h3>
-<pre>typedef ... lua_KContext;</pre>
+<pre class="api">typedef ... lua_KContext;</pre>
<p>
The type for continuation-function contexts.
@@ -4650,7 +4664,7 @@
<hr><h3><a name="lua_KFunction"><code>lua_KFunction</code></a></h3>
-<pre>typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);</pre>
+<pre class="api">typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);</pre>
<p>
Type for continuation functions (see <a href="#4.5">§4.5</a>).
@@ -4661,7 +4675,7 @@
<hr><h3><a name="lua_len"><code>lua_len</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>void lua_len (lua_State *L, int index);</pre>
+<pre class="api">void lua_len (lua_State *L, int index);</pre>
<p>
Returns the length of the value at the given index.
@@ -4675,7 +4689,7 @@
<hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int lua_load (lua_State *L,
+<pre class="api">int lua_load (lua_State *L,
lua_Reader reader,
void *data,
const char *chunkname,
@@ -4755,7 +4769,7 @@
<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_State *lua_newstate (lua_Alloc f, void *ud,
+<pre class="api">lua_State *lua_newstate (lua_Alloc f, void *ud,
unsigned int seed);</pre>
<p>
@@ -4776,7 +4790,7 @@
<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void lua_newtable (lua_State *L);</pre>
+<pre class="api">void lua_newtable (lua_State *L);</pre>
<p>
Creates a new empty table and pushes it onto the stack.
@@ -4788,7 +4802,7 @@
<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>lua_State *lua_newthread (lua_State *L);</pre>
+<pre class="api">lua_State *lua_newthread (lua_State *L);</pre>
<p>
Creates a new thread, pushes it on the stack,
@@ -4808,14 +4822,20 @@
<hr><h3><a name="lua_newuserdatauv"><code>lua_newuserdatauv</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue);</pre>
+<pre class="api">void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue);</pre>
<p>
This function creates and pushes on the stack a new full userdata,
with <code>nuvalue</code> associated Lua values, called <code>user values</code>,
plus an associated block of raw memory with <code>size</code> bytes.
-(The user values can be set and read with the functions
-<a href="#lua_setiuservalue"><code>lua_setiuservalue</code></a> and <a href="#lua_getiuservalue"><code>lua_getiuservalue</code></a>.)
+
+
+<p>
+The user values can be set and read with the functions
+<a href="#lua_setiuservalue"><code>lua_setiuservalue</code></a> and <a href="#lua_getiuservalue"><code>lua_getiuservalue</code></a>.
+The block of memory is suitably aligned for any ISO C object.
+(See macro <code>LUAI_MAXALIGN</code> in file <code>luaconf.h</code> for other
+alignment requirements.)
<p>
@@ -4831,7 +4851,7 @@
<hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
<span class="apii">[-1, +(2|0), <em>v</em>]</span>
-<pre>int lua_next (lua_State *L, int index);</pre>
+<pre class="api">int lua_next (lua_State *L, int index);</pre>
<p>
Pops a key from the stack,
@@ -4869,15 +4889,17 @@
<p>
This function may raise an error if the given key
is neither <b>nil</b> nor present in the table.
-See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
-the table during its traversal.
+
+
+<p>
+See function <a href="#pdf-next"><code>next</code></a> for more details about the traversal.
<hr><h3><a name="lua_Number"><code>lua_Number</code></a></h3>
-<pre>typedef ... lua_Number;</pre>
+<pre class="api">typedef ... lua_Number;</pre>
<p>
The type of floats in Lua.
@@ -4893,7 +4915,7 @@
<hr><h3><a name="lua_numbertointeger"><code>lua_numbertointeger</code></a></h3>
-<pre>int lua_numbertointeger (lua_Number n, lua_Integer *p);</pre>
+<pre class="api">int lua_numbertointeger (lua_Number n, lua_Integer *p);</pre>
<p>
Tries to convert a Lua float to a Lua integer;
@@ -4915,7 +4937,7 @@
<hr><h3><a name="lua_numbertocstring"><code>lua_numbertocstring</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>unsigned lua_numbertocstring (lua_State *L, int idx,
+<pre class="api">unsigned lua_numbertocstring (lua_State *L, int idx,
char *buff);</pre>
<p>
@@ -4933,7 +4955,7 @@
<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
<span class="apii">[-(nargs + 1), +(nresults|1), –]</span>
-<pre>int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);</pre>
+<pre class="api">int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);</pre>
<p>
Calls a function (or a callable object) in protected mode.
@@ -4983,7 +5005,7 @@
<hr><h3><a name="lua_pcallk"><code>lua_pcallk</code></a></h3><p>
<span class="apii">[-(nargs + 1), +(nresults|1), –]</span>
-<pre>int lua_pcallk (lua_State *L,
+<pre class="api">int lua_pcallk (lua_State *L,
int nargs,
int nresults,
int msgh,
@@ -5000,7 +5022,7 @@
<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
<span class="apii">[-n, +0, <em>e</em>]</span>
-<pre>void lua_pop (lua_State *L, int n);</pre>
+<pre class="api">void lua_pop (lua_State *L, int n);</pre>
<p>
Pops <code>n</code> elements from the stack.
@@ -5012,7 +5034,7 @@
<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushboolean (lua_State *L, int b);</pre>
+<pre class="api">void lua_pushboolean (lua_State *L, int b);</pre>
<p>
Pushes a boolean value with value <code>b</code> onto the stack.
@@ -5023,7 +5045,7 @@
<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
<span class="apii">[-n, +1, <em>m</em>]</span>
-<pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
+<pre class="api">void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
<p>
Pushes a new C closure onto the stack.
@@ -5072,7 +5094,7 @@
<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
+<pre class="api">void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
<p>
Pushes a C function onto the stack.
@@ -5084,7 +5106,7 @@
<hr><h3><a name="lua_pushexternalstring"><code>lua_pushexternalstring</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>const char *lua_pushexternalstring (lua_State *L,
+<pre class="api">const char *lua_pushexternalstring (lua_State *L,
const char *s, size_t len, lua_Alloc falloc, void *ud);</pre>
<p>
@@ -5126,7 +5148,7 @@
<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
<span class="apii">[-0, +1, <em>v</em>]</span>
-<pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
+<pre class="api">const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
<p>
Pushes onto the stack a formatted string
@@ -5160,7 +5182,7 @@
<hr><h3><a name="lua_pushglobaltable"><code>lua_pushglobaltable</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushglobaltable (lua_State *L);</pre>
+<pre class="api">void lua_pushglobaltable (lua_State *L);</pre>
<p>
Pushes the global environment onto the stack.
@@ -5171,7 +5193,7 @@
<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
+<pre class="api">void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
<p>
Pushes an integer with value <code>n</code> onto the stack.
@@ -5182,7 +5204,7 @@
<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushlightuserdata (lua_State *L, void *p);</pre>
+<pre class="api">void lua_pushlightuserdata (lua_State *L, void *p);</pre>
<p>
Pushes a light userdata onto the stack.
@@ -5203,7 +5225,7 @@
<hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
<span class="apii">[-0, +1, <em>v</em>]</span>
-<pre>const char *lua_pushliteral (lua_State *L, const char *s);</pre>
+<pre class="api">const char *lua_pushliteral (lua_State *L, const char *s);</pre>
<p>
This macro is equivalent to <a href="#lua_pushstring"><code>lua_pushstring</code></a>,
@@ -5216,7 +5238,7 @@
<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
<span class="apii">[-0, +1, <em>v</em>]</span>
-<pre>const char *lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
+<pre class="api">const char *lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
<p>
Pushes the string pointed to by <code>s</code> with size <code>len</code>
@@ -5242,7 +5264,7 @@
<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushnil (lua_State *L);</pre>
+<pre class="api">void lua_pushnil (lua_State *L);</pre>
<p>
Pushes a nil value onto the stack.
@@ -5253,7 +5275,7 @@
<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushnumber (lua_State *L, lua_Number n);</pre>
+<pre class="api">void lua_pushnumber (lua_State *L, lua_Number n);</pre>
<p>
Pushes a float with value <code>n</code> onto the stack.
@@ -5264,7 +5286,7 @@
<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>const char *lua_pushstring (lua_State *L, const char *s);</pre>
+<pre class="api">const char *lua_pushstring (lua_State *L, const char *s);</pre>
<p>
Pushes the zero-terminated string pointed to by <code>s</code>
@@ -5287,7 +5309,7 @@
<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int lua_pushthread (lua_State *L);</pre>
+<pre class="api">int lua_pushthread (lua_State *L);</pre>
<p>
Pushes the thread represented by <code>L</code> onto the stack.
@@ -5299,7 +5321,7 @@
<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void lua_pushvalue (lua_State *L, int index);</pre>
+<pre class="api">void lua_pushvalue (lua_State *L, int index);</pre>
<p>
Pushes a copy of the element at the given index
@@ -5311,7 +5333,7 @@
<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>const char *lua_pushvfstring (lua_State *L,
+<pre class="api">const char *lua_pushvfstring (lua_State *L,
const char *fmt,
va_list argp);</pre>
@@ -5329,7 +5351,7 @@
<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
+<pre class="api">int lua_rawequal (lua_State *L, int index1, int index2);</pre>
<p>
Returns 1 if the two values in indices <code>index1</code> and
@@ -5344,7 +5366,7 @@
<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
<span class="apii">[-1, +1, –]</span>
-<pre>int lua_rawget (lua_State *L, int index);</pre>
+<pre class="api">int lua_rawget (lua_State *L, int index);</pre>
<p>
Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw access
@@ -5357,7 +5379,7 @@
<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int lua_rawgeti (lua_State *L, int index, lua_Integer n);</pre>
+<pre class="api">int lua_rawgeti (lua_State *L, int index, lua_Integer n);</pre>
<p>
Pushes onto the stack the value <code>t[n]</code>,
@@ -5375,7 +5397,7 @@
<hr><h3><a name="lua_rawgetp"><code>lua_rawgetp</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int lua_rawgetp (lua_State *L, int index, const void *p);</pre>
+<pre class="api">int lua_rawgetp (lua_State *L, int index, const void *p);</pre>
<p>
Pushes onto the stack the value <code>t[k]</code>,
@@ -5394,7 +5416,7 @@
<hr><h3><a name="lua_rawlen"><code>lua_rawlen</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Unsigned lua_rawlen (lua_State *L, int index);</pre>
+<pre class="api">lua_Unsigned lua_rawlen (lua_State *L, int index);</pre>
<p>
Returns the raw "length" of the value at the given index:
@@ -5411,7 +5433,7 @@
<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
<span class="apii">[-2, +0, <em>m</em>]</span>
-<pre>void lua_rawset (lua_State *L, int index);</pre>
+<pre class="api">void lua_rawset (lua_State *L, int index);</pre>
<p>
Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw assignment
@@ -5424,7 +5446,7 @@
<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
<span class="apii">[-1, +0, <em>m</em>]</span>
-<pre>void lua_rawseti (lua_State *L, int index, lua_Integer i);</pre>
+<pre class="api">void lua_rawseti (lua_State *L, int index, lua_Integer i);</pre>
<p>
Does the equivalent of <code>t[i] = v</code>,
@@ -5443,7 +5465,7 @@
<hr><h3><a name="lua_rawsetp"><code>lua_rawsetp</code></a></h3><p>
<span class="apii">[-1, +0, <em>m</em>]</span>
-<pre>void lua_rawsetp (lua_State *L, int index, const void *p);</pre>
+<pre class="api">void lua_rawsetp (lua_State *L, int index, const void *p);</pre>
<p>
Does the equivalent of <code>t[p] = v</code>,
@@ -5462,7 +5484,7 @@
<hr><h3><a name="lua_Reader"><code>lua_Reader</code></a></h3>
-<pre>typedef const char * (*lua_Reader) (lua_State *L,
+<pre class="api">typedef const char * (*lua_Reader) (lua_State *L,
void *data,
size_t *size);</pre>
@@ -5485,7 +5507,7 @@
<hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
+<pre class="api">void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
<p>
Sets the C function <code>f</code> as the new value of global <code>name</code>.
@@ -5501,7 +5523,7 @@
<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
<span class="apii">[-1, +0, –]</span>
-<pre>void lua_remove (lua_State *L, int index);</pre>
+<pre class="api">void lua_remove (lua_State *L, int index);</pre>
<p>
Removes the element at the given valid index,
@@ -5515,7 +5537,7 @@
<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
<span class="apii">[-1, +0, –]</span>
-<pre>void lua_replace (lua_State *L, int index);</pre>
+<pre class="api">void lua_replace (lua_State *L, int index);</pre>
<p>
Moves the top element into the given valid index
@@ -5529,7 +5551,7 @@
<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
<span class="apii">[-?, +?, –]</span>
-<pre>int lua_resume (lua_State *L, lua_State *from, int nargs,
+<pre class="api">int lua_resume (lua_State *L, lua_State *from, int nargs,
int *nresults);</pre>
<p>
@@ -5540,7 +5562,7 @@
To start a coroutine,
you push the main function plus any arguments
onto the empty stack of the thread.
-then you call <a href="#lua_resume"><code>lua_resume</code></a>,
+Then you call <a href="#lua_resume"><code>lua_resume</code></a>,
with <code>nargs</code> being the number of arguments.
The function returns when the coroutine suspends,
finishes its execution, or raises an unprotected error.
@@ -5578,7 +5600,7 @@
<hr><h3><a name="lua_rotate"><code>lua_rotate</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_rotate (lua_State *L, int idx, int n);</pre>
+<pre class="api">void lua_rotate (lua_State *L, int idx, int n);</pre>
<p>
Rotates the stack elements between the valid index <code>idx</code>
@@ -5598,7 +5620,7 @@
<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
+<pre class="api">void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
<p>
Changes the allocator function of a given state to <code>f</code>
@@ -5610,7 +5632,7 @@
<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
<span class="apii">[-1, +0, <em>e</em>]</span>
-<pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
+<pre class="api">void lua_setfield (lua_State *L, int index, const char *k);</pre>
<p>
Does the equivalent to <code>t[k] = v</code>,
@@ -5629,7 +5651,7 @@
<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
<span class="apii">[-1, +0, <em>e</em>]</span>
-<pre>void lua_setglobal (lua_State *L, const char *name);</pre>
+<pre class="api">void lua_setglobal (lua_State *L, const char *name);</pre>
<p>
Pops a value from the stack and
@@ -5641,7 +5663,7 @@
<hr><h3><a name="lua_seti"><code>lua_seti</code></a></h3><p>
<span class="apii">[-1, +0, <em>e</em>]</span>
-<pre>void lua_seti (lua_State *L, int index, lua_Integer n);</pre>
+<pre class="api">void lua_seti (lua_State *L, int index, lua_Integer n);</pre>
<p>
Does the equivalent to <code>t[n] = v</code>,
@@ -5660,7 +5682,7 @@
<hr><h3><a name="lua_setiuservalue"><code>lua_setiuservalue</code></a></h3><p>
<span class="apii">[-1, +0, –]</span>
-<pre>int lua_setiuservalue (lua_State *L, int index, int n);</pre>
+<pre class="api">int lua_setiuservalue (lua_State *L, int index, int n);</pre>
<p>
Pops a value from the stack and sets it as
@@ -5674,7 +5696,7 @@
<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
<span class="apii">[-1, +0, –]</span>
-<pre>int lua_setmetatable (lua_State *L, int index);</pre>
+<pre class="api">int lua_setmetatable (lua_State *L, int index);</pre>
<p>
Pops a table or <b>nil</b> from the stack and
@@ -5692,7 +5714,7 @@
<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
<span class="apii">[-2, +0, <em>e</em>]</span>
-<pre>void lua_settable (lua_State *L, int index);</pre>
+<pre class="api">void lua_settable (lua_State *L, int index);</pre>
<p>
Does the equivalent to <code>t[k] = v</code>,
@@ -5712,7 +5734,7 @@
<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
<span class="apii">[-?, +?, <em>e</em>]</span>
-<pre>void lua_settop (lua_State *L, int index);</pre>
+<pre class="api">void lua_settop (lua_State *L, int index);</pre>
<p>
Receives any acceptable stack index, or 0,
@@ -5732,7 +5754,7 @@
<hr><h3><a name="lua_setwarnf"><code>lua_setwarnf</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);</pre>
+<pre class="api">void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);</pre>
<p>
Sets the warning function to be used by Lua to emit warnings
@@ -5745,7 +5767,7 @@
<hr><h3><a name="lua_State"><code>lua_State</code></a></h3>
-<pre>typedef struct lua_State lua_State;</pre>
+<pre class="api">typedef struct lua_State lua_State;</pre>
<p>
An opaque structure that points to a thread and indirectly
@@ -5766,7 +5788,7 @@
<hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_status (lua_State *L);</pre>
+<pre class="api">int lua_status (lua_State *L);</pre>
<p>
Returns the status of the thread <code>L</code>.
@@ -5790,8 +5812,8 @@
<hr><h3><a name="lua_stringtonumber"><code>lua_stringtonumber</code></a></h3><p>
-<span class="apii">[-0, +1, –]</span>
-<pre>size_t lua_stringtonumber (lua_State *L, const char *s);</pre>
+<span class="apii">[-0, +(0|1), –]</span>
+<pre class="api">size_t lua_stringtonumber (lua_State *L, const char *s);</pre>
<p>
Converts the zero-terminated string <code>s</code> to a number,
@@ -5812,7 +5834,7 @@
<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_toboolean (lua_State *L, int index);</pre>
+<pre class="api">int lua_toboolean (lua_State *L, int index);</pre>
<p>
Converts the Lua value at the given index to a C boolean
@@ -5830,7 +5852,7 @@
<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
+<pre class="api">lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
<p>
Converts a value at the given index to a C function.
@@ -5843,7 +5865,7 @@
<hr><h3><a name="lua_toclose"><code>lua_toclose</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void lua_toclose (lua_State *L, int index);</pre>
+<pre class="api">void lua_toclose (lua_State *L, int index);</pre>
<p>
Marks the given index in the stack as a
@@ -5885,7 +5907,7 @@
<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
+<pre class="api">lua_Integer lua_tointeger (lua_State *L, int index);</pre>
<p>
Equivalent to <a href="#lua_tointegerx"><code>lua_tointegerx</code></a> with <code>isnum</code> equal to <code>NULL</code>.
@@ -5896,7 +5918,7 @@
<hr><h3><a name="lua_tointegerx"><code>lua_tointegerx</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);</pre>
+<pre class="api">lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);</pre>
<p>
Converts the Lua value at the given index
@@ -5917,7 +5939,7 @@
<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
<span class="apii">[-0, +0, <em>m</em>]</span>
-<pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
+<pre class="api">const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
<p>
Converts the Lua value at the given index to a C string.
@@ -5955,7 +5977,7 @@
<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
+<pre class="api">lua_Number lua_tonumber (lua_State *L, int index);</pre>
<p>
Equivalent to <a href="#lua_tonumberx"><code>lua_tonumberx</code></a> with <code>isnum</code> equal to <code>NULL</code>.
@@ -5966,7 +5988,7 @@
<hr><h3><a name="lua_tonumberx"><code>lua_tonumberx</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);</pre>
+<pre class="api">lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);</pre>
<p>
Converts the Lua value at the given index
@@ -5987,7 +6009,7 @@
<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>const void *lua_topointer (lua_State *L, int index);</pre>
+<pre class="api">const void *lua_topointer (lua_State *L, int index);</pre>
<p>
Converts the value at the given index to a generic
@@ -6007,7 +6029,7 @@
<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
<span class="apii">[-0, +0, <em>m</em>]</span>
-<pre>const char *lua_tostring (lua_State *L, int index);</pre>
+<pre class="api">const char *lua_tostring (lua_State *L, int index);</pre>
<p>
Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to <code>NULL</code>.
@@ -6018,7 +6040,7 @@
<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
+<pre class="api">lua_State *lua_tothread (lua_State *L, int index);</pre>
<p>
Converts the value at the given index to a Lua thread
@@ -6032,7 +6054,7 @@
<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void *lua_touserdata (lua_State *L, int index);</pre>
+<pre class="api">void *lua_touserdata (lua_State *L, int index);</pre>
<p>
If the value at the given index is a full userdata,
@@ -6047,7 +6069,7 @@
<hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_type (lua_State *L, int index);</pre>
+<pre class="api">int lua_type (lua_State *L, int index);</pre>
<p>
Returns the type of the value in the given valid index,
@@ -6071,7 +6093,7 @@
<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>const char *lua_typename (lua_State *L, int tp);</pre>
+<pre class="api">const char *lua_typename (lua_State *L, int tp);</pre>
<p>
Returns the name of the type encoded by the value <code>tp</code>,
@@ -6082,7 +6104,7 @@
<hr><h3><a name="lua_Unsigned"><code>lua_Unsigned</code></a></h3>
-<pre>typedef ... lua_Unsigned;</pre>
+<pre class="api">typedef ... lua_Unsigned;</pre>
<p>
The unsigned version of <a href="#lua_Integer"><code>lua_Integer</code></a>.
@@ -6093,7 +6115,7 @@
<hr><h3><a name="lua_upvalueindex"><code>lua_upvalueindex</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_upvalueindex (int i);</pre>
+<pre class="api">int lua_upvalueindex (int i);</pre>
<p>
Returns the pseudo-index that represents the <code>i</code>-th upvalue of
@@ -6106,7 +6128,7 @@
<hr><h3><a name="lua_version"><code>lua_version</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Number lua_version (lua_State *L);</pre>
+<pre class="api">lua_Number lua_version (lua_State *L);</pre>
<p>
Returns the version number of this core.
@@ -6116,7 +6138,7 @@
<hr><h3><a name="lua_WarnFunction"><code>lua_WarnFunction</code></a></h3>
-<pre>typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);</pre>
+<pre class="api">typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);</pre>
<p>
The type of warning functions, called by Lua to emit warnings.
@@ -6137,7 +6159,7 @@
<hr><h3><a name="lua_warning"><code>lua_warning</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_warning (lua_State *L, const char *msg, int tocont);</pre>
+<pre class="api">void lua_warning (lua_State *L, const char *msg, int tocont);</pre>
<p>
Emits a warning with the given message.
@@ -6153,7 +6175,7 @@
<hr><h3><a name="lua_Writer"><code>lua_Writer</code></a></h3>
-<pre>typedef int (*lua_Writer) (lua_State *L,
+<pre class="api">typedef int (*lua_Writer) (lua_State *L,
const void* p,
size_t sz,
void* ud);</pre>
@@ -6185,7 +6207,7 @@
<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
<span class="apii">[-?, +?, –]</span>
-<pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
+<pre class="api">void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
<p>
Exchange values between different threads of the same state.
@@ -6201,7 +6223,7 @@
<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
<span class="apii">[-?, +?, <em>v</em>]</span>
-<pre>int lua_yield (lua_State *L, int nresults);</pre>
+<pre class="api">int lua_yield (lua_State *L, int nresults);</pre>
<p>
This function is equivalent to <a href="#lua_yieldk"><code>lua_yieldk</code></a>,
@@ -6218,7 +6240,7 @@
<hr><h3><a name="lua_yieldk"><code>lua_yieldk</code></a></h3><p>
<span class="apii">[-?, +?, <em>v</em>]</span>
-<pre>int lua_yieldk (lua_State *L,
+<pre class="api">int lua_yieldk (lua_State *L,
int nresults,
lua_KContext ctx,
lua_KFunction k);</pre>
@@ -6241,7 +6263,7 @@
the execution of the C function that yielded (see <a href="#4.5">§4.5</a>).
This continuation function receives the same stack
from the previous function,
-with the <code>n</code> results removed and
+with all the results (<code>nresults</code>) removed and
replaced by the arguments passed to <a href="#lua_resume"><code>lua_resume</code></a>.
Moreover,
the continuation function receives the value <code>ctx</code>
@@ -6342,7 +6364,7 @@
</li>
<li><b><code>srclen</code></b>:
-The length of the string <code>source</code>.
+the length of the string <code>source</code>.
</li>
<li><b><code>short_src</code></b>:
@@ -6442,7 +6464,7 @@
<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_Hook lua_gethook (lua_State *L);</pre>
+<pre class="api">lua_Hook lua_gethook (lua_State *L);</pre>
<p>
Returns the current hook function.
@@ -6453,7 +6475,7 @@
<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_gethookcount (lua_State *L);</pre>
+<pre class="api">int lua_gethookcount (lua_State *L);</pre>
<p>
Returns the current hook count.
@@ -6464,7 +6486,7 @@
<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_gethookmask (lua_State *L);</pre>
+<pre class="api">int lua_gethookmask (lua_State *L);</pre>
<p>
Returns the current hook mask.
@@ -6475,7 +6497,7 @@
<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
<span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
-<pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
+<pre class="api">int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
<p>
Gets information about a specific function or function invocation.
@@ -6528,7 +6550,7 @@
</li>
<li><b>'<code>S</code>'</b>:
-fills in the fields <code>source</code>, <code>short_src</code>,
+fills in the fields <code>source</code>, <code>srclen</code>, <code>short_src</code>,
<code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;
</li>
@@ -6561,7 +6583,7 @@
<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
<span class="apii">[-0, +(0|1), –]</span>
-<pre>const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
+<pre class="api">const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
<p>
Gets information about a local variable or a temporary value
@@ -6602,7 +6624,7 @@
<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
+<pre class="api">int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
<p>
Gets information about the interpreter runtime stack.
@@ -6625,7 +6647,7 @@
<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
<span class="apii">[-0, +(0|1), –]</span>
-<pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
+<pre class="api">const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
<p>
Gets information about the <code>n</code>-th upvalue
@@ -6644,7 +6666,7 @@
<hr><h3><a name="lua_Hook"><code>lua_Hook</code></a></h3>
-<pre>typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);</pre>
+<pre class="api">typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);</pre>
<p>
Type for debugging hook functions.
@@ -6693,7 +6715,7 @@
<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
+<pre class="api">void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
<p>
Sets the debugging hook function.
@@ -6743,7 +6765,7 @@
<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
<span class="apii">[-(0|1), +0, –]</span>
-<pre>const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
+<pre class="api">const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
<p>
Sets the value of a local variable of a given activation record.
@@ -6759,7 +6781,9 @@
<p>
-Parameters <code>ar</code> and <code>n</code> are as in the function <a href="#lua_getlocal"><code>lua_getlocal</code></a>.
+Parameters <code>ar</code> and <code>n</code> are as in the function <a href="#lua_getlocal"><code>lua_getlocal</code></a>,
+except that <code>ar</code> cannot be <code>NULL</code>,
+as <code>lua_setlocal</code> only operates on activation records.
@@ -6767,7 +6791,7 @@
<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
<span class="apii">[-(0|1), +0, –]</span>
-<pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
+<pre class="api">const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
<p>
Sets the value of a closure's upvalue.
@@ -6791,7 +6815,7 @@
<hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
+<pre class="api">void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
<p>
Returns a unique identifier for the upvalue numbered <code>n</code>
@@ -6817,7 +6841,7 @@
<hr><h3><a name="lua_upvaluejoin"><code>lua_upvaluejoin</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
+<pre class="api">void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
int funcindex2, int n2);</pre>
<p>
@@ -6892,7 +6916,7 @@
<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
+<pre class="api">void luaL_addchar (luaL_Buffer *B, char c);</pre>
<p>
Adds the byte <code>c</code> to the buffer <code>B</code>
@@ -6904,7 +6928,7 @@
<hr><h3><a name="luaL_addgsub"><code>luaL_addgsub</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>const void luaL_addgsub (luaL_Buffer *B, const char *s,
+<pre class="api">const void luaL_addgsub (luaL_Buffer *B, const char *s,
const char *p, const char *r);</pre>
<p>
@@ -6918,7 +6942,7 @@
<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
+<pre class="api">void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
<p>
Adds the string pointed to by <code>s</code> with length <code>l</code> to
@@ -6932,7 +6956,7 @@
<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
<span class="apii">[-?, +?, –]</span>
-<pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
+<pre class="api">void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
<p>
Adds to the buffer <code>B</code>
@@ -6945,7 +6969,7 @@
<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
+<pre class="api">void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
<p>
Adds the zero-terminated string pointed to by <code>s</code>
@@ -6958,7 +6982,7 @@
<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>void luaL_addvalue (luaL_Buffer *B);</pre>
+<pre class="api">void luaL_addvalue (luaL_Buffer *B);</pre>
<p>
Adds the value on the top of the stack
@@ -6978,7 +7002,7 @@
<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_argcheck (lua_State *L,
+<pre class="api">void luaL_argcheck (lua_State *L,
int cond,
int arg,
const char *extramsg);</pre>
@@ -6993,7 +7017,7 @@
<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>int luaL_argerror (lua_State *L, int arg, const char *extramsg);</pre>
+<pre class="api">int luaL_argerror (lua_State *L, int arg, const char *extramsg);</pre>
<p>
Raises an error reporting a problem with argument <code>arg</code>
@@ -7012,7 +7036,7 @@
<hr><h3><a name="luaL_argexpected"><code>luaL_argexpected</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_argexpected (lua_State *L,
+<pre class="api">void luaL_argexpected (lua_State *L,
int cond,
int arg,
const char *tname);</pre>
@@ -7027,7 +7051,7 @@
<hr><h3><a name="luaL_Buffer"><code>luaL_Buffer</code></a></h3>
-<pre>typedef struct luaL_Buffer luaL_Buffer;</pre>
+<pre class="api">typedef struct luaL_Buffer luaL_Buffer;</pre>
<p>
Type for a <em>string buffer</em>.
@@ -7099,7 +7123,7 @@
<hr><h3><a name="luaL_buffaddr"><code>luaL_buffaddr</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>char *luaL_buffaddr (luaL_Buffer *B);</pre>
+<pre class="api">char *luaL_buffaddr (luaL_Buffer *B);</pre>
<p>
Returns the address of the current content of buffer <code>B</code>
@@ -7112,7 +7136,7 @@
<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
<span class="apii">[-0, +?, –]</span>
-<pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
+<pre class="api">void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
<p>
Initializes a buffer <code>B</code>
@@ -7126,7 +7150,7 @@
<hr><h3><a name="luaL_bufflen"><code>luaL_bufflen</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>size_t luaL_bufflen (luaL_Buffer *B);</pre>
+<pre class="api">size_t luaL_bufflen (luaL_Buffer *B);</pre>
<p>
Returns the length of the current content of buffer <code>B</code>
@@ -7138,7 +7162,7 @@
<hr><h3><a name="luaL_buffinitsize"><code>luaL_buffinitsize</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
+<pre class="api">char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
<p>
Equivalent to the sequence
@@ -7150,7 +7174,7 @@
<hr><h3><a name="luaL_buffsub"><code>luaL_buffsub</code></a></h3><p>
<span class="apii">[-?, +?, –]</span>
-<pre>void luaL_buffsub (luaL_Buffer *B, int n);</pre>
+<pre class="api">void luaL_buffsub (luaL_Buffer *B, int n);</pre>
<p>
Removes <code>n</code> bytes from the buffer <code>B</code>
@@ -7163,7 +7187,7 @@
<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
<span class="apii">[-0, +(0|1), <em>e</em>]</span>
-<pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
+<pre class="api">int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
<p>
Calls a metamethod.
@@ -7184,7 +7208,7 @@
<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_checkany (lua_State *L, int arg);</pre>
+<pre class="api">void luaL_checkany (lua_State *L, int arg);</pre>
<p>
Checks whether the function has an argument
@@ -7196,7 +7220,7 @@
<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>lua_Integer luaL_checkinteger (lua_State *L, int arg);</pre>
+<pre class="api">lua_Integer luaL_checkinteger (lua_State *L, int arg);</pre>
<p>
Checks whether the function argument <code>arg</code> is an integer
@@ -7209,7 +7233,7 @@
<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>const char *luaL_checklstring (lua_State *L, int arg, size_t *l);</pre>
+<pre class="api">const char *luaL_checklstring (lua_State *L, int arg, size_t *l);</pre>
<p>
Checks whether the function argument <code>arg</code> is a string
@@ -7228,7 +7252,7 @@
<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>lua_Number luaL_checknumber (lua_State *L, int arg);</pre>
+<pre class="api">lua_Number luaL_checknumber (lua_State *L, int arg);</pre>
<p>
Checks whether the function argument <code>arg</code> is a number
@@ -7240,7 +7264,7 @@
<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>int luaL_checkoption (lua_State *L,
+<pre class="api">int luaL_checkoption (lua_State *L,
int arg,
const char *def,
const char *const lst[]);</pre>
@@ -7271,7 +7295,7 @@
<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
+<pre class="api">void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
<p>
Grows the stack size to <code>top + sz</code> elements,
@@ -7285,7 +7309,7 @@
<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>const char *luaL_checkstring (lua_State *L, int arg);</pre>
+<pre class="api">const char *luaL_checkstring (lua_State *L, int arg);</pre>
<p>
Checks whether the function argument <code>arg</code> is a string
@@ -7302,7 +7326,7 @@
<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_checktype (lua_State *L, int arg, int t);</pre>
+<pre class="api">void luaL_checktype (lua_State *L, int arg, int t);</pre>
<p>
Checks whether the function argument <code>arg</code> has type <code>t</code>.
@@ -7314,7 +7338,7 @@
<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void *luaL_checkudata (lua_State *L, int arg, const char *tname);</pre>
+<pre class="api">void *luaL_checkudata (lua_State *L, int arg, const char *tname);</pre>
<p>
Checks whether the function argument <code>arg</code> is a userdata
@@ -7327,7 +7351,7 @@
<hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>void luaL_checkversion (lua_State *L);</pre>
+<pre class="api">void luaL_checkversion (lua_State *L);</pre>
<p>
Checks whether the code making the call and the Lua library being called
@@ -7339,7 +7363,7 @@
<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
<span class="apii">[-0, +?, <em>m</em>]</span>
-<pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
+<pre class="api">int luaL_dofile (lua_State *L, const char *filename);</pre>
<p>
Loads and runs the given file.
@@ -7358,7 +7382,7 @@
<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
<span class="apii">[-0, +?, –]</span>
-<pre>int luaL_dostring (lua_State *L, const char *str);</pre>
+<pre class="api">int luaL_dostring (lua_State *L, const char *str);</pre>
<p>
Loads and runs the given string.
@@ -7376,7 +7400,7 @@
<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
+<pre class="api">int luaL_error (lua_State *L, const char *fmt, ...);</pre>
<p>
Raises an error.
@@ -7399,7 +7423,7 @@
<hr><h3><a name="luaL_execresult"><code>luaL_execresult</code></a></h3><p>
<span class="apii">[-0, +3, <em>m</em>]</span>
-<pre>int luaL_execresult (lua_State *L, int stat);</pre>
+<pre class="api">int luaL_execresult (lua_State *L, int stat);</pre>
<p>
This function produces the return values for
@@ -7412,7 +7436,7 @@
<hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>
<span class="apii">[-0, +(1|3), <em>m</em>]</span>
-<pre>int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre>
+<pre class="api">int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre>
<p>
This function produces the return values for
@@ -7425,7 +7449,7 @@
<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
<span class="apii">[-0, +(0|1), <em>m</em>]</span>
-<pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
+<pre class="api">int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
<p>
Pushes onto the stack the field <code>e</code> from the metatable
@@ -7440,7 +7464,7 @@
<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>int luaL_getmetatable (lua_State *L, const char *tname);</pre>
+<pre class="api">int luaL_getmetatable (lua_State *L, const char *tname);</pre>
<p>
Pushes onto the stack the metatable associated with the name <code>tname</code>
@@ -7454,7 +7478,7 @@
<hr><h3><a name="luaL_getsubtable"><code>luaL_getsubtable</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>int luaL_getsubtable (lua_State *L, int idx, const char *fname);</pre>
+<pre class="api">int luaL_getsubtable (lua_State *L, int idx, const char *fname);</pre>
<p>
Ensures that the value <code>t[fname]</code>,
@@ -7470,7 +7494,7 @@
<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>const char *luaL_gsub (lua_State *L,
+<pre class="api">const char *luaL_gsub (lua_State *L,
const char *s,
const char *p,
const char *r);</pre>
@@ -7487,7 +7511,7 @@
<hr><h3><a name="luaL_len"><code>luaL_len</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>lua_Integer luaL_len (lua_State *L, int index);</pre>
+<pre class="api">lua_Integer luaL_len (lua_State *L, int index);</pre>
<p>
Returns the "length" of the value at the given index
@@ -7502,7 +7526,7 @@
<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int luaL_loadbuffer (lua_State *L,
+<pre class="api">int luaL_loadbuffer (lua_State *L,
const char *buff,
size_t sz,
const char *name);</pre>
@@ -7516,7 +7540,7 @@
<hr><h3><a name="luaL_loadbufferx"><code>luaL_loadbufferx</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int luaL_loadbufferx (lua_State *L,
+<pre class="api">int luaL_loadbufferx (lua_State *L,
const char *buff,
size_t sz,
const char *name,
@@ -7542,7 +7566,7 @@
<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
+<pre class="api">int luaL_loadfile (lua_State *L, const char *filename);</pre>
<p>
Equivalent to <a href="#luaL_loadfilex"><code>luaL_loadfilex</code></a> with <code>mode</code> equal to <code>NULL</code>.
@@ -7553,7 +7577,7 @@
<hr><h3><a name="luaL_loadfilex"><code>luaL_loadfilex</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>int luaL_loadfilex (lua_State *L, const char *filename,
+<pre class="api">int luaL_loadfilex (lua_State *L, const char *filename,
const char *mode);</pre>
<p>
@@ -7584,7 +7608,7 @@
<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
+<pre class="api">int luaL_loadstring (lua_State *L, const char *s);</pre>
<p>
Loads a string as a Lua chunk.
@@ -7606,7 +7630,7 @@
<hr><h3><a name="luaL_makeseed"><code>luaL_makeseed</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>unsigned int luaL_makeseed (lua_State *L);</pre>
+<pre class="api">unsigned int luaL_makeseed (lua_State *L);</pre>
<p>
Returns a value with a weak attempt for randomness.
@@ -7619,7 +7643,7 @@
<hr><h3><a name="luaL_newlib"><code>luaL_newlib</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void luaL_newlib (lua_State *L, const luaL_Reg l[]);</pre>
+<pre class="api">void luaL_newlib (lua_State *L, const luaL_Reg l[]);</pre>
<p>
Creates a new table and registers there
@@ -7641,7 +7665,7 @@
<hr><h3><a name="luaL_newlibtable"><code>luaL_newlibtable</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);</pre>
+<pre class="api">void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);</pre>
<p>
Creates a new table with a size optimized
@@ -7662,7 +7686,7 @@
<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
+<pre class="api">int luaL_newmetatable (lua_State *L, const char *tname);</pre>
<p>
If the registry already has the key <code>tname</code>,
@@ -7680,12 +7704,22 @@
with <code>tname</code> in the registry.
+<p>
+Usage note: Beware the use of the return value of this function to
+conditionally initializes the new metatable
+(e.g., by adding metamethods to it).
+If the initialization raises an error,
+the metatable will not be properly initialized,
+but a subsequent execution of that code will detect that the
+metatable already exists and then skip the initialization.
+
+
<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>lua_State *luaL_newstate (void);</pre>
+<pre class="api">lua_State *luaL_newstate (void);</pre>
<p>
Creates a new Lua state.
@@ -7706,7 +7740,7 @@
<hr><h3><a name="luaL_opt"><code>luaL_opt</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>T luaL_opt (L, func, arg, dflt);</pre>
+<pre class="api">T luaL_opt (L, func, arg, dflt);</pre>
<p>
This macro is defined as follows:
@@ -7727,7 +7761,7 @@
<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>lua_Integer luaL_optinteger (lua_State *L,
+<pre class="api">lua_Integer luaL_optinteger (lua_State *L,
int arg,
lua_Integer d);</pre>
@@ -7745,7 +7779,7 @@
<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>const char *luaL_optlstring (lua_State *L,
+<pre class="api">const char *luaL_optlstring (lua_State *L,
int arg,
const char *d,
size_t *l);</pre>
@@ -7776,7 +7810,7 @@
<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);</pre>
+<pre class="api">lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);</pre>
<p>
If the function argument <code>arg</code> is a number,
@@ -7791,7 +7825,7 @@
<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>const char *luaL_optstring (lua_State *L,
+<pre class="api">const char *luaL_optstring (lua_State *L,
int arg,
const char *d);</pre>
@@ -7808,7 +7842,7 @@
<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
+<pre class="api">char *luaL_prepbuffer (luaL_Buffer *B);</pre>
<p>
Equivalent to <a href="#luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a>
@@ -7820,7 +7854,7 @@
<hr><h3><a name="luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a></h3><p>
<span class="apii">[-?, +?, <em>m</em>]</span>
-<pre>char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
+<pre class="api">char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
<p>
Returns an address to a space of size <code>sz</code>
@@ -7836,7 +7870,7 @@
<hr><h3><a name="luaL_pushfail"><code>luaL_pushfail</code></a></h3><p>
<span class="apii">[-0, +1, –]</span>
-<pre>void luaL_pushfail (lua_State *L);</pre>
+<pre class="api">void luaL_pushfail (lua_State *L);</pre>
<p>
Pushes the <b>fail</b> value onto the stack (see <a href="#6">§6</a>).
@@ -7847,7 +7881,7 @@
<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
<span class="apii">[-?, +1, <em>m</em>]</span>
-<pre>void luaL_pushresult (luaL_Buffer *B);</pre>
+<pre class="api">void luaL_pushresult (luaL_Buffer *B);</pre>
<p>
Finishes the use of buffer <code>B</code> leaving the final string on
@@ -7859,7 +7893,7 @@
<hr><h3><a name="luaL_pushresultsize"><code>luaL_pushresultsize</code></a></h3><p>
<span class="apii">[-?, +1, <em>m</em>]</span>
-<pre>void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
+<pre class="api">void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
<p>
Equivalent to the sequence <a href="#luaL_addsize"><code>luaL_addsize</code></a>, <a href="#luaL_pushresult"><code>luaL_pushresult</code></a>.
@@ -7870,7 +7904,7 @@
<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
<span class="apii">[-1, +0, <em>m</em>]</span>
-<pre>int luaL_ref (lua_State *L, int t);</pre>
+<pre class="api">int luaL_ref (lua_State *L, int t);</pre>
<p>
Creates and returns a <em>reference</em>,
@@ -7910,7 +7944,7 @@
<hr><h3><a name="luaL_Reg"><code>luaL_Reg</code></a></h3>
-<pre>typedef struct luaL_Reg {
+<pre class="api">typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;</pre>
@@ -7929,7 +7963,7 @@
<hr><h3><a name="luaL_requiref"><code>luaL_requiref</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>void luaL_requiref (lua_State *L, const char *modname,
+<pre class="api">void luaL_requiref (lua_State *L, const char *modname,
lua_CFunction openf, int glb);</pre>
<p>
@@ -7953,7 +7987,7 @@
<hr><h3><a name="luaL_setfuncs"><code>luaL_setfuncs</code></a></h3><p>
<span class="apii">[-nup, +0, <em>m</em>]</span>
-<pre>void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
+<pre class="api">void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
<p>
Registers all functions in the array <code>l</code>
@@ -7980,7 +8014,7 @@
<hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>
+<pre class="api">void luaL_setmetatable (lua_State *L, const char *tname);</pre>
<p>
Sets the metatable of the object on the top of the stack
@@ -7992,7 +8026,7 @@
<hr><h3><a name="luaL_alloc"><code>luaL_alloc</code></a></h3>
-<pre>void *luaL_alloc (void *ud, void *ptr, size_t osize, size_t nsize);</pre>
+<pre class="api">void *luaL_alloc (void *ud, void *ptr, size_t osize, size_t nsize);</pre>
<p>
A standard allocator function for Lua (see <a href="#lua_Alloc"><code>lua_Alloc</code></a>),
@@ -8003,7 +8037,7 @@
<hr><h3><a name="luaL_Stream"><code>luaL_Stream</code></a></h3>
-<pre>typedef struct luaL_Stream {
+<pre class="api">typedef struct luaL_Stream {
FILE *f;
lua_CFunction closef;
} luaL_Stream;</pre>
@@ -8042,7 +8076,7 @@
<hr><h3><a name="luaL_testudata"><code>luaL_testudata</code></a></h3><p>
<span class="apii">[-0, +0, <em>m</em>]</span>
-<pre>void *luaL_testudata (lua_State *L, int arg, const char *tname);</pre>
+<pre class="api">void *luaL_testudata (lua_State *L, int arg, const char *tname);</pre>
<p>
This function works like <a href="#luaL_checkudata"><code>luaL_checkudata</code></a>,
@@ -8055,7 +8089,7 @@
<hr><h3><a name="luaL_tolstring"><code>luaL_tolstring</code></a></h3><p>
<span class="apii">[-0, +1, <em>e</em>]</span>
-<pre>const char *luaL_tolstring (lua_State *L, int idx, size_t *len);</pre>
+<pre class="api">const char *luaL_tolstring (lua_State *L, int idx, size_t *len);</pre>
<p>
Converts any Lua value at the given index to a C string
@@ -8078,7 +8112,7 @@
<hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
+<pre class="api">void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
int level);</pre>
<p>
@@ -8094,7 +8128,7 @@
<hr><h3><a name="luaL_typeerror"><code>luaL_typeerror</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
-<pre>int luaL_typeerror (lua_State *L, int arg, const char *tname);</pre>
+<pre class="api">int luaL_typeerror (lua_State *L, int arg, const char *tname);</pre>
<p>
Raises a type error for the argument <code>arg</code>
@@ -8109,7 +8143,7 @@
<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>const char *luaL_typename (lua_State *L, int index);</pre>
+<pre class="api">const char *luaL_typename (lua_State *L, int index);</pre>
<p>
Returns the name of the type of the value at the given index.
@@ -8120,7 +8154,7 @@
<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
<span class="apii">[-0, +0, –]</span>
-<pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
+<pre class="api">void luaL_unref (lua_State *L, int t, int ref);</pre>
<p>
Releases a reference (see <a href="#luaL_ref"><code>luaL_ref</code></a>).
@@ -8140,7 +8174,7 @@
<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>void luaL_where (lua_State *L, int lvl);</pre>
+<pre class="api">void luaL_where (lua_State *L, int lvl);</pre>
<p>
Pushes onto the stack a string identifying the current position
@@ -8255,7 +8289,7 @@
<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>void luaL_openlibs (lua_State *L);</pre>
+<pre class="api">void luaL_openlibs (lua_State *L);</pre>
<p>
Opens all standard Lua libraries into the given state.
@@ -8266,7 +8300,7 @@
<hr><h3><a name="luaL_openselectedlibs"><code>luaL_openselectedlibs</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
-<pre>void luaL_openselectedlibs (lua_State *L, int load, int preload);</pre>
+<pre class="api">void luaL_openselectedlibs (lua_State *L, int load, int preload);</pre>
<p>
Opens (loads) and preloads selected standard libraries into the state <code>L</code>.
@@ -8654,8 +8688,7 @@
<p>
-See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
-the table during its traversal.
+See function <a href="#pdf-next"><code>next</code></a> for more details about the traversal.
@@ -11681,6 +11714,9 @@
<p>
This library provides
the functionality of the debug interface (<a href="#4.7">§4.7</a>) to Lua programs.
+
+
+<p>
You should exert care when using this library.
Several of its functions
violate basic assumptions about Lua code
@@ -11690,6 +11726,8 @@
that Lua programs do not crash)
and therefore can compromise otherwise secure code.
Moreover, some functions in this library may be slow.
+It is good practice to always require this library explicitly
+before using it.
<p>
@@ -12306,6 +12344,11 @@
<li>
The word <b>global</b> is a reserved word.
Do not use it as a regular name.
+
+
+<p>
+The compilation option <code>LUA_COMPAT_GLOBAL</code> (see <code>luaconf.h</code>)
+makes <code>global</code> a regular word.
</li>
<li>
@@ -12435,7 +12478,7 @@
<b>local</b> <b>function</b> Name funcbody |
<b>global</b> <b>function</b> Name funcbody |
<b>local</b> attnamelist [‘<b>=</b>’ explist] |
- <b>global</b> attnamelist |
+ <b>global</b> attnamelist [‘<b>=</b>’ explist] |
<b>global</b> [attrib] ‘<b>*</b>’
attnamelist ::= [attrib] Name [attrib] {‘<b>,</b>’ Name [attrib]}
@@ -12499,10 +12542,10 @@
<P CLASS="footer">
Last update:
-Mon Dec 15 21:02:05 UTC 2025
+Fri Jul 24 14:07:32 UTC 2026
</P>
<!--
-Last change: revised for Lua 5.5.0
+Last change: revised for Lua 5.5.1
-->
</body></html>
doc/readme.html
@@ -109,7 +109,7 @@
<OL>
<LI>
Open a terminal window and move to
-the top-level directory, which is named <TT>lua-5.5.0</TT>.
+the top-level directory, which is named <TT>lua-5.5.1</TT>.
The <TT>Makefile</TT> there controls both the build process and the installation process.
<P>
<LI>
@@ -263,6 +263,7 @@
<H3>Main changes</H3>
<UL>
<LI> declarations for global variables
+<LI> named vararg tables
<LI> for-loop variables are read only
<LI> floats are printed in decimal with enough digits to be read back correctly.
<LI> more levels for constructors
@@ -296,7 +297,7 @@
<A HREF="https://www.lua.org/license.html">license page</A>.
<BLOCKQUOTE STYLE="padding-bottom: 0em">
-Copyright © 1994–2025 Lua.org, PUC-Rio.
+Copyright © 1994–2026 Lua.org, PUC-Rio.
<P>
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -323,10 +324,10 @@
<P CLASS="footer">
Last update:
-Wed Dec 10 11:37:23 UTC 2025
+Mon Jul 13 21:20:24 UTC 2026
</P>
<!--
-Last change: revised for Lua 5.5.0
+Last change: revised for Lua 5.5.1
-->
</BODY>
src/Makefile
@@ -30,7 +30,7 @@
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
-PLATS= guess aix bsd c89 freebsd generic ios linux macosx mingw posix solaris
+PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
LUA_A= liblua.a
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
@@ -123,8 +123,11 @@
Linux linux:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl"
+linux-readline:
+ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline"
+
Darwin macos macosx:
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline"
+ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline"
mingw:
$(MAKE) "LUA_A=lua55.dll" "LUA_T=lua.exe" \
src/lapi.c
@@ -187,7 +187,7 @@
api_check(L, idx <= ci->top.p - (func + 1), "new top too large");
diff = ((func + 1) + idx) - L->top.p;
for (; diff > 0; diff--)
- setnilvalue(s2v(L->top.p++)); /* clear new slots */
+ setnilvalue2s(L->top.p++); /* clear new slots */
}
else {
api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top");
@@ -210,7 +210,7 @@
api_check(L, (L->ci->callstatus & CIST_TBC) && (L->tbclist.p == level),
"no variable to close at given level");
level = luaF_close(L, level, CLOSEKTOP, 0);
- setnilvalue(s2v(level));
+ setnilvalue2s(level);
lua_unlock(L);
}
@@ -366,7 +366,7 @@
}
-LUA_API unsigned (lua_numbertocstring) (lua_State *L, int idx, char *buff) {
+LUA_API unsigned lua_numbertocstring (lua_State *L, int idx, char *buff) {
const TValue *o = index2value(L, idx);
if (ttisnumber(o)) {
unsigned len = luaO_tostringbuff(o, buff);
@@ -513,7 +513,7 @@
LUA_API void lua_pushnil (lua_State *L) {
lua_lock(L);
- setnilvalue(s2v(L->top.p));
+ setnilvalue2s(L->top.p);
api_incr_top(L);
lua_unlock(L);
}
@@ -570,7 +570,7 @@
LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
lua_lock(L);
if (s == NULL)
- setnilvalue(s2v(L->top.p));
+ setnilvalue2s(L->top.p);
else {
TString *ts;
ts = luaS_new(L, s);
@@ -743,7 +743,7 @@
static int finishrawget (lua_State *L, lu_byte tag) {
if (tagisempty(tag)) /* avoid copying empty items to the stack */
- setnilvalue(s2v(L->top.p));
+ setnilvalue2s(L->top.p);
api_incr_top(L);
lua_unlock(L);
return novariant(tag);
@@ -836,7 +836,7 @@
o = index2value(L, idx);
api_check(L, ttisfulluserdata(o), "full userdata expected");
if (n <= 0 || n > uvalue(o)->nuvalue) {
- setnilvalue(s2v(L->top.p));
+ setnilvalue2s(L->top.p);
t = LUA_TNONE;
}
else {
@@ -1122,6 +1122,7 @@
ZIO z;
TStatus status;
lua_lock(L);
+ luaC_checkGC(L);
if (!chunkname) chunkname = "?";
luaZ_init(L, &z, reader, data);
status = luaD_protectedparser(L, &z, chunkname, mode);
@@ -1201,11 +1202,16 @@
case LUA_GCSTEP: {
lu_byte oldstp = g->gcstp;
l_mem n = cast(l_mem, va_arg(argp, size_t));
+ l_mem newdebt;
int work = 0; /* true if GC did some work */
g->gcstp = 0; /* allow GC to run (other bits must be zero here) */
if (n <= 0)
- n = g->GCdebt; /* force to run one basic step */
- luaE_setdebt(g, g->GCdebt - n);
+ newdebt = 0; /* force to run one basic step */
+ else if (g->GCdebt >= n - MAX_LMEM) /* no overflow? */
+ newdebt = g->GCdebt - n;
+ else /* overflow */
+ newdebt = -MAX_LMEM; /* set debt to mininum value */
+ luaE_setdebt(g, newdebt);
luaC_condGC(L, (void)0, work = 1);
if (work && g->gcstate == GCSpause) /* end of cycle? */
res = 1; /* signal it */
@@ -1293,8 +1299,8 @@
LUA_API void lua_concat (lua_State *L, int n) {
lua_lock(L);
- api_checknelems(L, n);
if (n > 0) {
+ api_checkpop(L, n);
luaV_concat(L, n);
luaC_checkGC(L);
}
@@ -1412,7 +1418,7 @@
TValue *fi;
lua_lock(L);
fi = index2value(L, funcindex);
- api_checknelems(L, 1);
+ api_checkpop(L, 1);
name = aux_upvalue(fi, n, &val, &owner);
if (name) {
L->top.p--;
src/lauxlib.c
@@ -513,12 +513,25 @@
};
+/*
+** Get/create metatable (MT) for boxes
+*/
+static void getBoxMT (lua_State *L) {
+ const char *BOXMT = "_UBOX*"; /* key for the metatable */
+ if (luaL_getmetatable(L, BOXMT) == LUA_TNIL) { /* MT not created yet? */
+ luaL_newlibtable(L, boxmt); /* create it */
+ luaL_setfuncs(L, boxmt, 0); /* initialize it */
+ lua_copy(L, -1, -2); /* change stack from nil,MT to MT,MT */
+ lua_setfield(L, LUA_REGISTRYINDEX, BOXMT); /* store MT in the registry */
+ }
+}
+
+
static void newbox (lua_State *L) {
UBox *box = (UBox *)lua_newuserdatauv(L, sizeof(UBox), 0);
box->box = NULL;
box->bsize = 0;
- if (luaL_newmetatable(L, "_UBOX*")) /* creating metatable? */
- luaL_setfuncs(L, boxmt, 0); /* set its metamethods */
+ getBoxMT(L);
lua_setmetatable(L, -2);
}
@@ -874,7 +887,7 @@
LUALIB_API int luaL_loadstring (lua_State *L, const char *s) {
- return luaL_loadbuffer(L, s, strlen(s), s);
+ return luaL_loadbufferx(L, s, strlen(s), s, "t");
}
/* }====================================================== */
src/lauxlib.h
@@ -81,8 +81,8 @@
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
-LUALIB_API void *luaL_alloc (void *ud, void *ptr, size_t osize,
- size_t nsize);
+LUALIB_API void *(luaL_alloc) (void *ud, void *ptr, size_t osize,
+ size_t nsize);
/* predefined references */
@@ -103,7 +103,7 @@
LUALIB_API lua_State *(luaL_newstate) (void);
-LUALIB_API unsigned luaL_makeseed (lua_State *L);
+LUALIB_API unsigned (luaL_makeseed) (lua_State *L);
LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
src/lbaselib.c
@@ -340,9 +340,11 @@
static const char *getMode (lua_State *L, int idx) {
- const char *mode = luaL_optstring(L, idx, "bt");
- if (strchr(mode, 'B') != NULL) /* Lua code cannot use fixed buffers */
+ const char *mode = luaL_optstring(L, idx, NULL);
+ if (mode != NULL && strchr(mode, 'B') != NULL) {
+ /* Lua code cannot use fixed buffers */
luaL_argerror(L, idx, "invalid mode");
+ }
return mode;
}
@@ -364,33 +366,24 @@
/*
-** reserved slot, above all arguments, to hold a copy of the returned
-** string to avoid it being collected while parsed. 'load' has four
-** optional arguments (chunk, source name, mode, and environment).
-*/
-#define RESERVEDSLOT 5
-
-
-/*
-** Reader for generic 'load' function: 'lua_load' uses the
-** stack for internal stuff, so the reader cannot change the
-** stack top. Instead, it keeps its resulting string in a
-** reserved slot inside the stack.
+** Reader for generic 'load' function.
*/
static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
- (void)(ud); /* not used */
+ int *firstcall = cast(int *, ud);
luaL_checkstack(L, 2, "too many nested functions");
+ if (*firstcall)
+ *firstcall = 0;
+ else
+ lua_pop(L, 1); /* remove previous result */
lua_pushvalue(L, 1); /* get function */
lua_call(L, 0, 1); /* call it */
if (lua_isnil(L, -1)) {
- lua_pop(L, 1); /* pop result */
*size = 0;
return NULL;
}
else if (l_unlikely(!lua_isstring(L, -1)))
luaL_error(L, "reader function must return a string");
- lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
- return lua_tolstring(L, RESERVEDSLOT, size);
+ return lua_tolstring(L, -1, size);
}
@@ -405,10 +398,10 @@
status = luaL_loadbufferx(L, s, l, chunkname, mode);
}
else { /* loading from a reader function */
+ int firstcall = 1; /* userdata for generic_reader */
const char *chunkname = luaL_optstring(L, 2, "=(load)");
luaL_checktype(L, 1, LUA_TFUNCTION);
- lua_settop(L, RESERVEDSLOT); /* create reserved slot */
- status = lua_load(L, generic_reader, NULL, chunkname, mode);
+ status = lua_load(L, generic_reader, &firstcall, chunkname, mode);
}
return load_aux(L, status, env);
}
@@ -425,7 +418,7 @@
static int luaB_dofile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL);
lua_settop(L, 1);
- if (l_unlikely(luaL_loadfile(L, fname) != LUA_OK))
+ if (l_unlikely(luaL_loadfilex(L, fname, "bt") != LUA_OK))
return lua_error(L);
lua_callk(L, 0, LUA_MULTRET, 0, dofilecont);
return dofilecont(L, 0, 0);
src/lcode.c
@@ -663,11 +663,11 @@
** Add nil to list of constants and return its index.
*/
static int nilK (FuncState *fs) {
- TValue k, v;
- setnilvalue(&v);
+ lua_State *L = fs->ls->L;
+ TValue k;
/* cannot use nil as key; instead use table itself */
- sethvalue(fs->ls->L, &k, fs->kcache);
- return k2proto(fs, &k, &v);
+ sethvalue(L, &k, fs->kcache);
+ return k2proto(fs, &k, &G(L)->nilvalue);
}
@@ -827,7 +827,7 @@
} /* FALLTHROUGH */
case VLOCAL: { /* already in a register */
int temp = e->u.var.ridx;
- e->u.info = temp; /* (can't do a direct assignment; values overlap) */
+ e->u.info = temp; /* (avoid a direct assignment; values overlap) */
e->k = VNONRELOC; /* becomes a non-relocatable value */
break;
}
@@ -1365,7 +1365,7 @@
luaK_exp2anyreg(fs, t); /* put it in a register */
if (t->k == VUPVAL) {
lu_byte temp = cast_byte(t->u.info); /* upvalue index */
- t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
+ t->u.ind.t = temp; /* (avoid a direct assignment; values overlap) */
lua_assert(isKstr(fs, k));
fillidxk(t, k->u.info, VINDEXUP); /* literal short string */
}
@@ -1373,12 +1373,13 @@
int kreg = luaK_exp2anyreg(fs, k); /* put key in some register */
lu_byte vreg = cast_byte(t->u.var.ridx); /* register with vararg param. */
lua_assert(vreg == fs->f->numparams);
- t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap) */
+ t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap?) */
fillidxk(t, kreg, VVARGIND); /* 't' represents 'vararg[k]' */
}
else {
/* register index of the table */
- t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
+ lu_byte temp = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
+ t->u.ind.t = temp; /* (avoid a direct assignment; values may overlap?) */
if (isKstr(fs, k))
fillidxk(t, k->u.info, VINDEXSTR); /* literal short string */
else if (isCint(k)) /* int. constant in proper range? */
@@ -1933,8 +1934,6 @@
p->flag &= cast_byte(~PF_VAHID); /* then it will not use hidden args. */
for (i = 0; i < fs->pc; i++) {
Instruction *pc = &p->code[i];
- /* avoid "not used" warnings when assert is off (for 'onelua.c') */
- (void)luaP_isOT; (void)luaP_isIT;
lua_assert(i == 0 || luaP_isOT(*(pc - 1)) == luaP_isIT(*pc));
switch (GET_OPCODE(*pc)) {
case OP_RETURN0: case OP_RETURN1: {
src/ldblib.c
@@ -427,7 +427,7 @@
if (fgets(buffer, sizeof(buffer), stdin) == NULL ||
strcmp(buffer, "cont\n") == 0)
return 0;
- if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
+ if (luaL_loadbufferx(L, buffer, strlen(buffer), "=(debug command)", "t") ||
lua_pcall(L, 0, 0, 0))
lua_writestringerror("%s\n", luaL_tolstring(L, -1, NULL));
lua_settop(L, 0); /* remove eventual returns */
src/ldebug.c
@@ -291,7 +291,7 @@
static void collectvalidlines (lua_State *L, Closure *f) {
if (!LuaClosure(f)) {
- setnilvalue(s2v(L->top.p));
+ setnilvalue2s(L->top.p);
api_incr_top(L);
}
else {
@@ -580,7 +580,7 @@
kname(p, k, name);
return isEnv(p, lastpc, i, 1);
}
- case OP_GETTABLE: {
+ case OP_GETTABLE: case OP_GETVARG: {
int k = GETARG_C(i); /* key index */
rname(p, lastpc, k, name);
return isEnv(p, lastpc, i, 0);
src/ldo.c
@@ -221,13 +221,21 @@
/*
-** Check whether stack has enough space to run a simple function (such
-** as a finalizer): At least BASIC_STACK_SIZE in the Lua stack and
-** 2 slots in the C stack.
+** Check whether stacks have enough space to run a simple function (such
+** as a finalizer): At least BASIC_STACK_SIZE in the Lua stack, two
+** available CallInfos, and two "slots" in the C stack.
*/
int luaD_checkminstack (lua_State *L) {
- return ((stacksize(L) < MAXSTACK - BASIC_STACK_SIZE) &&
- (getCcalls(L) < LUAI_MAXCCALLS - 2));
+ if (getCcalls(L) >= LUAI_MAXCCALLS - 2)
+ return 0; /* not enough C-stack slots */
+ if (L->ci->next == NULL && luaE_extendCI(L, 0) == NULL)
+ return 0; /* unable to allocate first ci */
+ if (L->ci->next->next == NULL && luaE_extendCI(L, 0) == NULL)
+ return 0; /* unable to allocate second ci */
+ if (L->stack_last.p - L->top.p >= BASIC_STACK_SIZE)
+ return 1; /* enough (BASIC_STACK_SIZE) free slots in the Lua stack */
+ else /* try to grow stack to a size with enough free slots */
+ return luaD_growstack(L, BASIC_STACK_SIZE, 0);
}
@@ -341,7 +349,7 @@
correctstack(L, oldstack); /* change offsets back to pointers */
L->stack_last.p = L->stack.p + newsize;
for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++)
- setnilvalue(s2v(newstack + i)); /* erase new segment */
+ setnilvalue2s(newstack + i); /* erase new segment */
return 1;
}
@@ -422,12 +430,6 @@
luaE_shrinkCI(L); /* shrink CI list */
}
-
-void luaD_inctop (lua_State *L) {
- L->top.p++;
- luaD_checkstack(L, 1);
-}
-
/* }================================================================== */
@@ -546,7 +548,7 @@
for (i = 0; i < nres; i++) /* move all results to correct place */
setobjs2s(L, res + i, firstresult + i);
for (; i < wanted; i++) /* complete wanted number of results */
- setnilvalue(s2v(res + i));
+ setnilvalue2s(res + i);
L->top.p = res + wanted; /* top points after the last result */
}
@@ -566,7 +568,7 @@
return;
case 1 + 1: /* one value needed */
if (nres == 0) /* no results? */
- setnilvalue(s2v(res)); /* adjust with nil */
+ setnilvalue2s(res); /* adjust with nil */
else /* at least one result */
setobjs2s(L, res, L->top.p - nres); /* move it to proper place */
L->top.p = res + 1;
@@ -616,7 +618,7 @@
-#define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L))
+#define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L, 1))
/*
@@ -686,7 +688,7 @@
setobjs2s(L, ci->func.p + i, func + i);
func = ci->func.p; /* moved-down function */
for (; narg1 <= nfixparams; narg1++)
- setnilvalue(s2v(func + narg1)); /* complete missing arguments */
+ setnilvalue2s(func + narg1); /* complete missing arguments */
ci->top.p = func + 1 + fsize; /* top for new function */
lua_assert(ci->top.p <= L->stack_last.p);
ci->u.l.savedpc = p->code; /* starting point */
@@ -733,7 +735,7 @@
L->ci = ci = prepCallInfo(L, func, status, func + 1 + fsize);
ci->u.l.savedpc = p->code; /* starting point */
for (; narg < nfixparams; narg++)
- setnilvalue(s2v(L->top.p++)); /* complete missing arguments */
+ setnilvalue2s(L->top.p++); /* complete missing arguments */
lua_assert(ci->top.p <= L->stack_last.p);
return ci;
}
@@ -1120,28 +1122,54 @@
}
+/*
+** Before the first call to the reader function, Lua reserves a slot
+** with a table for anchoring stuff.
+*/
static void f_parser (lua_State *L, void *ud) {
LClosure *cl;
struct SParser *p = cast(struct SParser *, ud);
const char *mode = p->mode ? p->mode : "bt";
- int c = zgetc(p->z); /* read first character */
+ int c;
+ Table *anchor;
+ ptrdiff_t otop = savestack(L, L->top.p); /* original top */
+ luaD_checkstack(L, 2);
+ anchor = luaH_new(L); /* create the anchor table */
+ sethvalue2s(L, L->top.p++, anchor); /* anchor the anchor table */
+ c = zgetc(p->z); /* read first character */
if (c == LUA_SIGNATURE[0]) {
int fixed = 0;
if (strchr(mode, 'B') != NULL)
fixed = 1;
else
checkmode(L, mode, "binary");
- cl = luaU_undump(L, p->z, p->name, fixed);
+ cl = luaU_undump(L, p->z, anchor, p->name, fixed);
}
else {
checkmode(L, mode, "text");
- cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
+ cl = luaY_parser(L, p->z, anchor, &p->buff, &p->dyd, p->name, c);
}
+ L->top.p = restorestack(L, otop); /* restore stack */
+ setclLvalue2s(L, L->top.p++, cl); /* push closure */
lua_assert(cl->nupvalues == cl->p->sizeupvalues);
luaF_initupvals(L, cl);
}
+/*
+** Anchor an object in a table in the stack. First, anchor the object
+** temporarily in the stack, as luaH_set may call an emergency GC.
+** Then, add it in the table with itself as its key.
+*/
+void luaD_anchorobj (lua_State *L, Table *anchor, GCObject *obj) {
+ setgcovalue(L, s2v(L->top.p++), obj); /* temporary anchor in the stack */
+ luaH_set(L, anchor, s2v(L->top.p - 1), s2v(L->top.p - 1));
+ /* Because this is a new key, luaH_set will call the GC barrier, so
+ we don't need to call the barrier again here */
+ L->top.p--;
+}
+
+
TStatus luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
const char *mode) {
struct SParser p;
src/ldo.h
@@ -88,8 +88,8 @@
LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
LUAI_FUNC void luaD_shrinkstack (lua_State *L);
-LUAI_FUNC void luaD_inctop (lua_State *L);
LUAI_FUNC int luaD_checkminstack (lua_State *L);
+LUAI_FUNC void luaD_anchorobj (lua_State *L, Table *anchor, GCObject *obj);
LUAI_FUNC l_noret luaD_throw (lua_State *L, TStatus errcode);
LUAI_FUNC l_noret luaD_throwbaselevel (lua_State *L, TStatus errcode);
src/lgc.c
@@ -709,7 +709,7 @@
if (!g->gcemergency)
luaD_shrinkstack(th); /* do not change stack in emergency cycle */
for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
- setnilvalue(s2v(o)); /* clear dead stack slice */
+ setnilvalue2s(o); /* clear dead stack slice */
/* 'remarkupvals' may have removed thread from 'twups' list */
if (!isintwups(th) && th->openupval != NULL) {
th->twups = g->twups; /* link it back to the list */
@@ -1293,7 +1293,7 @@
correctgraylists(g);
checkSizes(L, g);
g->gcstate = GCSpropagate; /* skip restart */
- if (!g->gcemergency && luaD_checkminstack(L))
+ if (g->tobefnz != NULL && !g->gcemergency && luaD_checkminstack(L))
callallpendingfinalizers(L);
}
@@ -1672,7 +1672,7 @@
GCTM(L); /* call one finalizer */
stepresult = CWUFIN;
}
- else { /* no more finalizers or emergency mode or no enough stack
+ else { /* no more finalizers or emergency mode or not enough stack
to run finalizers */
g->gcstate = GCSpause; /* finish collection */
stepresult = step2pause;
src/llex.c
@@ -188,7 +188,7 @@
so they cannot be collected */
ls->envn = luaS_newliteral(L, LUA_ENV); /* get env string */
ls->brkn = luaS_newliteral(L, "break"); /* get "break" string */
-#if defined(LUA_COMPAT_GLOBAL)
+#if LUA_COMPAT_GLOBAL
/* compatibility mode: "global" is not a reserved word */
ls->glbn = luaS_newliteral(L, "global"); /* get "global" string */
ls->glbn->extra = 0; /* mark it as not reserved */
src/llimits.h
@@ -234,12 +234,12 @@
/* floor division (defined as 'floor(a/b)') */
#if !defined(luai_numidiv)
-#define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b)))
+#define luai_numidiv(L,a,b) l_floor(luai_numdiv(L,a,b))
#endif
/* float division */
#if !defined(luai_numdiv)
-#define luai_numdiv(L,a,b) ((a)/(b))
+#define luai_numdiv(L,a,b) ((void)L, (a)/(b))
#endif
/*
@@ -267,10 +267,10 @@
/* the others are quite standard operations */
#if !defined(luai_numadd)
-#define luai_numadd(L,a,b) ((a)+(b))
-#define luai_numsub(L,a,b) ((a)-(b))
-#define luai_nummul(L,a,b) ((a)*(b))
-#define luai_numunm(L,a) (-(a))
+#define luai_numadd(L,a,b) ((void)L, (a)+(b))
+#define luai_numsub(L,a,b) ((void)L, (a)-(b))
+#define luai_nummul(L,a,b) ((void)L, (a)*(b))
+#define luai_numunm(L,a) ((void)L, -(a))
#define luai_numeq(a,b) ((a)==(b))
#define luai_numlt(a,b) ((a)<(b))
#define luai_numle(a,b) ((a)<=(b))
src/loadlib.c
@@ -541,7 +541,7 @@
const char *name = luaL_checkstring(L, 1);
filename = findfile(L, name, "path", LUA_LSUBSEP);
if (filename == NULL) return 1; /* module not found in this path */
- return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename);
+ return checkload(L, (luaL_loadfilex(L, filename, "bt") == LUA_OK), filename);
}
src/lobject.h
@@ -208,7 +208,8 @@
#define ttisstrictnil(o) checktag((o), LUA_VNIL)
-#define setnilvalue(obj) settt_(obj, LUA_VNIL)
+#define setnilvalue(obj) settt_(obj, LUA_VNIL)
+#define setnilvalue2s(stk) setnilvalue(s2v(stk))
#define isabstkey(v) checktag((v), LUA_VABSTKEY)
src/lopcodes.c
@@ -104,35 +104,26 @@
,opmode(0, 1, 0, 0, 1, iABC) /* OP_VARARG */
,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETVARG */
,opmode(0, 0, 0, 0, 0, iABx) /* OP_ERRNNIL */
- ,opmode(0, 0, 1, 0, 1, iABC) /* OP_VARARGPREP */
+ ,opmode(0, 0, 0, 0, 0, iABC) /* OP_VARARGPREP */
,opmode(0, 0, 0, 0, 0, iAx) /* OP_EXTRAARG */
};
-
-/*
-** Check whether instruction sets top for next instruction, that is,
-** it results in multiple values.
-*/
-int luaP_isOT (Instruction i) {
- OpCode op = GET_OPCODE(i);
- switch (op) {
- case OP_TAILCALL: return 1;
- default:
- return testOTMode(op) && GETARG_C(i) == 0;
- }
-}
+#define testITMode(m) (luaP_opmodes[m] & (1 << 5))
/*
-** Check whether instruction uses top from previous instruction, that is,
-** it accepts multiple results.
+** Check whether instruction uses top. That happens for OP_VARARGPREP
+** and for instructions that use multiple values set by the previous
+** instruction.
*/
int luaP_isIT (Instruction i) {
OpCode op = GET_OPCODE(i);
switch (op) {
case OP_SETLIST:
- return testITMode(GET_OPCODE(i)) && GETARG_vB(i) == 0;
+ return GETARG_vB(i) == 0;
+ case OP_VARARGPREP:
+ return 1;
default:
return testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0;
}
src/lopcodes.h
@@ -417,8 +417,8 @@
** bits 0-2: op mode
** bit 3: instruction set register A
** bit 4: operator is a test (next instruction must be a jump)
-** bit 5: instruction uses 'L->top' set by previous instruction (when B == 0)
-** bit 6: instruction sets 'L->top' for next instruction (when C == 0)
+** bit 5: used by 'luaP_isIT'
+** bit 6: used by 'luaP_isOT'
** bit 7: instruction is an MM instruction (call a metamethod)
*/
@@ -427,12 +427,17 @@
#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 7))
#define testAMode(m) (luaP_opmodes[m] & (1 << 3))
#define testTMode(m) (luaP_opmodes[m] & (1 << 4))
-#define testITMode(m) (luaP_opmodes[m] & (1 << 5))
-#define testOTMode(m) (luaP_opmodes[m] & (1 << 6))
#define testMMMode(m) (luaP_opmodes[m] & (1 << 7))
-LUAI_FUNC int luaP_isOT (Instruction i);
+/* Check whether instruction sets top for next instruction, that is,
+** it results in multiple values. Used only for tests.
+*/
+#define luaP_isOT(i) \
+ (GET_OPCODE(i) == OP_TAILCALL || \
+ ((luaP_opmodes[GET_OPCODE(i)] & (1 << 6)) && GETARG_C(i) == 0))
+
+
LUAI_FUNC int luaP_isIT (Instruction i);
src/lparser.c
@@ -821,8 +821,7 @@
luaC_objbarrier(L, f, f->source);
f->maxstacksize = 2; /* registers 0/1 are always valid */
fs->kcache = luaH_new(L); /* create table for function */
- sethvalue2s(L, L->top.p, fs->kcache); /* anchor it */
- luaD_inctop(L);
+ luaD_anchorobj(L, ls->h, obj2gco(fs->kcache)); /* anchor it */
enterblock(fs, bl, 0);
}
@@ -831,6 +830,7 @@
lua_State *L = ls->L;
FuncState *fs = ls->fs;
Proto *f = fs->f;
+ TValue temp;
luaK_ret(fs, luaY_nvarstack(fs), 0); /* final return */
leaveblock(fs);
lua_assert(fs->bl == NULL);
@@ -843,8 +843,10 @@
luaM_shrinkvector(L, f->p, f->sizep, fs->np, Proto *);
luaM_shrinkvector(L, f->locvars, f->sizelocvars, fs->ndebugvars, LocVar);
luaM_shrinkvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc);
+ /* remove kcache table from scanner table ("weigh" its anchor) */
+ sethvalue(L, &temp, fs->kcache); /* key to be set to nil */
+ luaH_set(L, ls->h, &temp, &G(L)->nilvalue);
ls->fs = fs->prev;
- L->top.p--; /* pop kcache table */
luaC_checkGC(L);
}
@@ -1164,6 +1166,7 @@
}
default: {
luaX_syntaxerror(ls, "function arguments expected");
+ return; /* to avoid warnings */
}
}
lua_assert(f->k == VNONRELOC);
@@ -1611,7 +1614,6 @@
statlist(ls);
check_match(ls, TK_UNTIL, TK_REPEAT, line);
condexit = cond(ls); /* read condition (inside scope block) */
- leaveblock(fs); /* finish scope */
if (bl2.upval) { /* upvalues? */
int exit = luaK_jump(fs); /* normal exit must jump over fix */
luaK_patchtohere(fs, condexit); /* repetition must close upvalues */
@@ -1620,6 +1622,7 @@
luaK_patchtohere(fs, exit); /* normal exit comes to here */
}
luaK_patchlist(fs, condexit, repeat_init); /* close the loop */
+ leaveblock(fs); /* finish scope */
leaveblock(fs); /* finish loop */
}
@@ -2111,7 +2114,7 @@
gotostat(ls, line);
break;
}
-#if defined(LUA_COMPAT_GLOBAL)
+#if LUA_COMPAT_GLOBAL
case TK_NAME: {
/* compatibility code to parse global keyword when "global"
is not reserved */
@@ -2165,16 +2168,14 @@
}
-LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
+LClosure *luaY_parser (lua_State *L, ZIO *z, Table *anchor, Mbuffer *buff,
Dyndata *dyd, const char *name, int firstchar) {
LexState lexstate;
FuncState funcstate;
- LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */
- setclLvalue2s(L, L->top.p, cl); /* anchor it (to avoid being collected) */
- luaD_inctop(L);
- lexstate.h = luaH_new(L); /* create table for scanner */
- sethvalue2s(L, L->top.p, lexstate.h); /* anchor it */
- luaD_inctop(L);
+ LClosure *cl;
+ lexstate.h = anchor; /* table for scanner */
+ cl = luaF_newLclosure(L, 1); /* create main closure */
+ luaD_anchorobj(L, anchor, obj2gco(cl)); /* anchor it in scanner table */
funcstate.f = cl->p = luaF_newproto(L);
luaC_objbarrier(L, cl, cl->p);
funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
@@ -2187,7 +2188,6 @@
lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
/* all scopes should be correctly finished */
lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);
- L->top.p--; /* remove scanner's table */
- return cl; /* closure is on the stack, too */
+ return cl;
}
src/lparser.h
@@ -189,8 +189,9 @@
LUAI_FUNC lu_byte luaY_nvarstack (FuncState *fs);
LUAI_FUNC void luaY_checklimit (FuncState *fs, int v, int l,
const char *what);
-LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
- Dyndata *dyd, const char *name, int firstchar);
+LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Table *anchor,
+ Mbuffer *buff, Dyndata *dyd,
+ const char *name, int firstchar);
#endif
src/lstate.c
@@ -68,14 +68,19 @@
}
-CallInfo *luaE_extendCI (lua_State *L) {
+CallInfo *luaE_extendCI (lua_State *L, int err) {
CallInfo *ci;
- lua_assert(L->ci->next == NULL);
- ci = luaM_new(L, CallInfo);
- lua_assert(L->ci->next == NULL);
- L->ci->next = ci;
+ ci = luaM_reallocvector(L, NULL, 0, 1, CallInfo);
+ if (l_unlikely(ci == NULL)) { /* allocation failed? */
+ if (err)
+ luaM_error(L); /* raise the error */
+ return NULL; /* else only report it */
+ }
+ ci->next = L->ci->next;
ci->previous = L->ci;
- ci->next = NULL;
+ L->ci->next = ci;
+ if (ci->next)
+ ci->next->previous = ci;
ci->u.l.trap = 0;
L->nci++;
return ci;
@@ -146,7 +151,7 @@
static void resetCI (lua_State *L) {
CallInfo *ci = L->ci = &L->base_ci;
ci->func.p = L->stack.p;
- setnilvalue(s2v(ci->func.p)); /* 'function' entry for basic 'ci' */
+ setnilvalue2s(ci->func.p); /* 'function' entry for basic 'ci' */
ci->top.p = ci->func.p + 1 + LUA_MINSTACK; /* +1 for 'function' entry */
ci->u.c.k = NULL;
ci->callstatus = CIST_C;
@@ -161,7 +166,7 @@
L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue);
L1->tbclist.p = L1->stack.p;
for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)
- setnilvalue(s2v(L1->stack.p + i)); /* erase new stack */
+ setnilvalue2s(L1->stack.p + i); /* erase new stack */
L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE;
/* initialize first ci */
resetCI(L1);
src/lstate.h
@@ -383,7 +383,7 @@
/*
-** Union of all collectable objects (only for conversions)
+** Union of all collectable objects
** ISO C99, 6.5.2.3 p.5:
** "if a union contains several structures that share a common initial
** sequence [...], and if the union object currently contains one
@@ -403,32 +403,32 @@
};
-/*
-** ISO C99, 6.7.2.1 p.14:
-** "A pointer to a union object, suitably converted, points to each of
-** its members [...], and vice versa."
+/* macros to convert a GCObject into a specific value
+** ISO C99, 6.3.2.2 p.7:
+** "A pointer to an object or incomplete type may be converted to a
+** pointer to a different object or incomplete type. If the resulting
+** pointer is not correctly aligned for the pointed-to type, the
+** behavior is undefined. Otherwise, when converted back again, the
+** result shall compare equal to the original pointer."
*/
-#define cast_u(o) cast(union GCUnion *, (o))
-
-/* macros to convert a GCObject into a specific value */
-#define gco2ts(o) \
- check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
-#define gco2u(o) check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u))
-#define gco2lcl(o) check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l))
-#define gco2ccl(o) check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c))
-#define gco2cl(o) \
- check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
-#define gco2t(o) check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h))
-#define gco2p(o) check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p))
-#define gco2th(o) check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th))
-#define gco2upv(o) check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv))
+#define gco2(v,T,o) check_exp((o)->tt == v, cast(T*, o))
+#define gco2nv(t,T,o) check_exp(novariant((o)->tt) == t, cast(T*, o))
+#define gco2ts(o) gco2nv(LUA_TSTRING, TString, o)
+#define gco2u(o) gco2(LUA_VUSERDATA, Udata, o)
+#define gco2lcl(o) (&gco2(LUA_VLCL, Closure, o)->l)
+#define gco2ccl(o) (&gco2(LUA_VCCL, Closure, o)->c)
+#define gco2cl(o) gco2nv(LUA_TFUNCTION, Closure, o)
+#define gco2t(o) gco2(LUA_VTABLE, Table, o)
+#define gco2p(o) gco2(LUA_VPROTO, Proto, o)
+#define gco2th(o) gco2(LUA_VTHREAD, lua_State, o)
+#define gco2upv(o) gco2(LUA_VUPVAL, UpVal, o)
/*
** macro to convert a Lua object into a GCObject
*/
#define obj2gco(v) \
- check_exp(novariant((v)->tt) >= LUA_TSTRING, &(cast_u(v)->gc))
+ check_exp(novariant((v)->tt) >= LUA_TSTRING, cast(GCObject*, v))
/* actual number of total memory allocated */
@@ -438,7 +438,7 @@
LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
LUAI_FUNC lu_mem luaE_threadsize (lua_State *L);
-LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L);
+LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L, int err);
LUAI_FUNC void luaE_shrinkCI (lua_State *L);
LUAI_FUNC void luaE_checkcstack (lua_State *L);
LUAI_FUNC void luaE_incCstack (lua_State *L);
src/lstrlib.c
@@ -141,8 +141,8 @@
const char *s = luaL_checklstring(L, 1, &len);
lua_Integer n = luaL_checkinteger(L, 2);
const char *sep = luaL_optlstring(L, 3, "", &lsep);
- if (n <= 0)
- lua_pushliteral(L, "");
+ if (n <= 0 || (len | lsep) == 0)
+ lua_pushliteral(L, ""); /* no repetitions or both strings empty */
else if (l_unlikely(len > MAX_SIZE - lsep ||
cast_st2S(len + lsep) > cast_st2S(MAX_SIZE) / n))
return luaL_error(L, "resulting string too large");
@@ -757,19 +757,25 @@
}
+/*
+** Prepare state for matches. These fields are not affected by each match.
+*/
static void prepstate (MatchState *ms, lua_State *L,
const char *s, size_t ls, const char *p, size_t lp) {
ms->L = L;
- ms->matchdepth = MAXCCALLS;
ms->src_init = s;
ms->src_end = s + ls;
ms->p_end = p + lp;
}
+/*
+** (Re)prepare state for a match, setting fields that change during
+** each match.
+*/
static void reprepstate (MatchState *ms) {
+ ms->matchdepth = MAXCCALLS;
ms->level = 0;
- lua_assert(ms->matchdepth == MAXCCALLS);
}
@@ -968,7 +974,7 @@
reprepstate(&ms); /* (re)prepare state for new match */
if ((e = match(&ms, src, p)) != NULL && e != lastmatch) { /* match? */
n++;
- changed = add_value(&ms, &b, src, e, tr) | changed;
+ changed = add_value(&ms, &b, src, e, tr) || changed;
src = lastmatch = e;
}
else if (src < ms.src_end) /* otherwise, skip one character */
@@ -1726,7 +1732,7 @@
luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
"variable-length format");
size += ntoalign; /* total space used by option */
- luaL_argcheck(L, totalsize <= LUA_MAXINTEGER - size,
+ luaL_argcheck(L, totalsize <= MAX_SIZE - size,
1, "format result too large");
totalsize += size;
}
src/ltable.c
@@ -651,10 +651,9 @@
/*
-** Exchange the hash part of 't1' and 't2'. (In 'flags', only the
-** dummy bit must be exchanged: The 'isrealasize' is not related
-** to the hash part, and the metamethod bits do not change during
-** a resize, so the "real" table can keep their values.)
+** Exchange the hash part of 't1' and 't2'. (In 'flags', only the dummy
+** bit must be exchanged: The metamethod bits do not change during a
+** resize, so the "real" table can keep their values.)
*/
static void exchangehashpart (Table *t1, Table *t2) {
lu_byte lsizenode = t1->lsizenode;
@@ -1156,14 +1155,15 @@
lua_assert(hres != HOK);
if (hres == HNOTFOUND) {
TValue aux;
+ const TValue *actk = key; /* actual key to insert */
if (l_unlikely(ttisnil(key)))
luaG_runerror(L, "table index is nil");
else if (ttisfloat(key)) {
lua_Number f = fltvalue(key);
lua_Integer k;
- if (luaV_flttointeger(f, &k, F2Ieq)) {
- setivalue(&aux, k); /* key is equal to an integer */
- key = &aux; /* insert it as an integer */
+ if (luaV_flttointeger(f, &k, F2Ieq)) { /* is key equal to an integer? */
+ setivalue(&aux, k);
+ actk = &aux; /* use the integer as the key */
}
else if (l_unlikely(luai_numisnan(f)))
luaG_runerror(L, "table index is NaN");
@@ -1176,7 +1176,7 @@
L->top.p--;
return;
}
- luaH_newkey(L, t, key, value);
+ luaH_newkey(L, t, actk, value);
}
else if (hres > 0) { /* regular Node? */
setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value);
src/ltablib.c
@@ -42,15 +42,17 @@
/*
** Check that 'arg' either is a table or can behave like one (that is,
-** has a metatable with the required metamethods)
+** has a metatable with the required metamethods).
*/
static void checktab (lua_State *L, int arg, int what) {
- if (lua_type(L, arg) != LUA_TTABLE) { /* is it not a table? */
+ int tp = lua_type(L, arg);
+ if (tp != LUA_TTABLE) { /* is it not a table? */
int n = 1; /* number of elements to pop */
if (lua_getmetatable(L, arg) && /* must have metatable */
(!(what & TAB_R) || checkfield(L, "__index", ++n)) &&
(!(what & TAB_W) || checkfield(L, "__newindex", ++n)) &&
- (!(what & TAB_L) || checkfield(L, "__len", ++n))) {
+ (!(what & TAB_L) || /* strings don't need '__len' to have a length */
+ tp == LUA_TSTRING || checkfield(L, "__len", ++n))) {
lua_pop(L, n); /* pop metatable and tested metamethods */
}
else
@@ -204,8 +206,9 @@
static int tunpack (lua_State *L) {
lua_Unsigned n;
+ lua_Integer len = aux_getn(L, 1, TAB_R);
lua_Integer i = luaL_optinteger(L, 2, 1);
- lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1));
+ lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, len);
if (i > e) return 0; /* empty range */
n = l_castS2U(e) - l_castS2U(i); /* number of elements minus 1 */
if (l_unlikely(n >= (unsigned int)INT_MAX ||
src/ltm.c
@@ -262,7 +262,7 @@
/* move fixed parameters to after the copied function */
for (i = 1; i <= nfixparams; i++) {
setobjs2s(L, L->top.p++, ci->func.p + i);
- setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */
+ setnilvalue2s(ci->func.p + i); /* erase original parameter (for GC) */
}
ci->func.p += totalargs + 1; /* 'func' now lives after hidden arguments */
ci->top.p += totalargs + 1;
@@ -283,7 +283,7 @@
lua_assert(p->flag & PF_VAHID);
buildhiddenargs(L, ci, p, totalargs, nfixparams, nextra);
/* set vararg parameter to nil */
- setnilvalue(s2v(ci->func.p + nfixparams + 1));
+ setnilvalue2s(ci->func.p + nfixparams + 1);
lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p);
}
}
@@ -307,7 +307,7 @@
return;
}
}
- setnilvalue(s2v(ra)); /* else produce nil */
+ setnilvalue2s(ra); /* else produce nil */
}
@@ -355,10 +355,10 @@
for (i = 0; i < touse; i++) {
lu_byte tag = luaH_getint(h, i + 1, s2v(where + i));
if (tagisempty(tag))
- setnilvalue(s2v(where + i));
+ setnilvalue2s(where + i);
}
}
for (; i < wanted; i++) /* complete required results with nil */
- setnilvalue(s2v(where + i));
+ setnilvalue2s(where + i);
}
src/ltm.h
@@ -49,7 +49,7 @@
** Mask with 1 in all fast-access methods. A 1 in any of these bits
** in the flag of a (meta)table means the metatable does not have the
** corresponding metamethod field. (Bit 6 of the flag indicates that
-** the table is using the dummy node; bit 7 is used for 'isrealasize'.)
+** the table is using the dummy node.)
*/
#define maskflags cast_byte(~(~0u << (TM_EQ + 1)))
src/lua.c
@@ -30,6 +30,12 @@
#define LUA_INIT_VAR "LUA_INIT"
#endif
+/* Name of the environment variable with the name of the readline library */
+#if !defined(LUA_RLLIB_VAR)
+#define LUA_RLLIB_VAR "LUA_READLINELIB"
+#endif
+
+
#define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX
@@ -201,12 +207,12 @@
static int dofile (lua_State *L, const char *name) {
- return dochunk(L, luaL_loadfile(L, name));
+ return dochunk(L, luaL_loadfilex(L, name, "bt"));
}
static int dostring (lua_State *L, const char *s, const char *name) {
- return dochunk(L, luaL_loadbuffer(L, s, strlen(s), name));
+ return dochunk(L, luaL_loadbufferx(L, s, strlen(s), name, "t"));
}
@@ -260,7 +266,7 @@
const char *fname = argv[0];
if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0)
fname = NULL; /* stdin */
- status = luaL_loadfile(L, fname);
+ status = luaL_loadfilex(L, fname, "bt");
if (status == LUA_OK) {
int n = pushargs(L); /* push arguments to script */
status = docall(L, n, LUA_MULTRET);
@@ -374,12 +380,21 @@
}
+static char *(*l_getenv)(const char *name);
+
+/* Function to ignore environment variables, used by option -E */
+static char *no_getenv (const char *name) {
+ UNUSED(name);
+ return NULL;
+}
+
+
static int handle_luainit (lua_State *L) {
const char *name = "=" LUA_INITVARVERSION;
- const char *init = getenv(name + 1);
+ const char *init = l_getenv(name + 1);
if (init == NULL) {
name = "=" LUA_INIT_VAR;
- init = getenv(name + 1); /* try alternative name */
+ init = l_getenv(name + 1); /* try alternative name */
}
if (init == NULL) return LUA_OK;
else if (init[0] == '@')
@@ -498,18 +513,24 @@
#include <dlfcn.h>
static void lua_initreadline (lua_State *L) {
- void *lib = dlopen(LUA_READLINELIB, RTLD_NOW | RTLD_LOCAL);
- if (lib == NULL)
- lua_warning(L, "library '" LUA_READLINELIB "' not found", 0);
- else {
+ const char *rllib = l_getenv(LUA_RLLIB_VAR); /* name of readline library */
+ void *lib; /* library handle */
+ if (rllib == NULL) /* no environment variable? */
+ rllib = LUA_READLINELIB; /* use default name */
+ lib = dlopen(rllib, RTLD_NOW | RTLD_LOCAL);
+ if (lib != NULL) {
const char **name = cast(const char**, dlsym(lib, "rl_readline_name"));
if (name != NULL)
*name = "lua";
l_readline = cast(l_readlineT, cast_func(dlsym(lib, "readline")));
l_addhist = cast(l_addhistT, cast_func(dlsym(lib, "add_history")));
- if (l_readline == NULL)
- lua_warning(L, "unable to load 'readline'", 0);
- }
+ if (l_readline != NULL) /* could load readline function? */
+ return; /* everything ok */
+ /* else emit a warning */
+ }
+ lua_warning(L, "unable to load readline library '", 1);
+ lua_warning(L, rllib, 1);
+ lua_warning(L, "'", 0);
}
#else /* }{ */
@@ -588,11 +609,11 @@
static int addreturn (lua_State *L) {
const char *line = lua_tostring(L, -1); /* original line */
const char *retline = lua_pushfstring(L, "return %s;", line);
- int status = luaL_loadbuffer(L, retline, strlen(retline), "=stdin");
+ int status = luaL_loadbufferx(L, retline, strlen(retline), "=stdin", "t");
if (status == LUA_OK)
lua_remove(L, -2); /* remove modified line */
else
- lua_pop(L, 2); /* pop result from 'luaL_loadbuffer' and modified line */
+ lua_pop(L, 2); /* pop result from 'luaL_loadbufferx' and modified line */
return status;
}
@@ -619,7 +640,7 @@
const char *line = lua_tolstring(L, 1, &len); /* get first line */
checklocal(line);
for (;;) { /* repeat until gets a complete statement */
- int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */
+ int status = luaL_loadbufferx(L, line, len, "=stdin", "t"); /* try it */
if (!incomplete(L, status) || !pushline(L, 0))
return status; /* should not or cannot try to add continuation line */
lua_remove(L, -2); /* remove error message (from incomplete line) */
@@ -693,7 +714,13 @@
/* }================================================================== */
#if !defined(luai_openlibs)
-#define luai_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
+#if defined(LUA_NODEBUGLIB)
+/* With this option, code must require the debug library before using it */
+#define luai_openlibs(L) luaL_openselectedlibs(L, ~LUA_DBLIBK, LUA_DBLIBK)
+#else
+/* The default is to open all standard libraries */
+#define luai_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
+#endif
#endif
@@ -715,17 +742,18 @@
if (args & has_v) /* option '-v'? */
print_version();
if (args & has_E) { /* option '-E'? */
+ l_getenv = &no_getenv; /* program will ignore environment variables */
lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
+ else
+ l_getenv = &getenv;
luai_openlibs(L); /* open standard libraries */
createargtable(L, argv, argc, script); /* create table 'arg' */
lua_gc(L, LUA_GCRESTART); /* start GC... */
lua_gc(L, LUA_GCGEN); /* ...in generational mode */
- if (!(args & has_E)) { /* no option '-E'? */
- if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
- return 0; /* error running LUA_INIT */
- }
+ if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
+ return 0; /* error running LUA_INIT */
if (!runargs(L, argv, optlim)) /* execute arguments -e, -l, and -W */
return 0; /* something failed */
if (script > 0) { /* execute main script (if there is one) */
src/lua.h
@@ -13,13 +13,13 @@
#include <stddef.h>
-#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2025 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2026 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
#define LUA_VERSION_MAJOR_N 5
#define LUA_VERSION_MINOR_N 5
-#define LUA_VERSION_RELEASE_N 0
+#define LUA_VERSION_RELEASE_N 1
#define LUA_VERSION_NUM (LUA_VERSION_MAJOR_N * 100 + LUA_VERSION_MINOR_N)
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + LUA_VERSION_RELEASE_N)
@@ -521,7 +521,7 @@
/******************************************************************************
-* Copyright (C) 1994-2025 Lua.org, PUC-Rio.
+* Copyright (C) 1994-2026 Lua.org, PUC-Rio.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
src/luaconf.h
@@ -70,14 +70,16 @@
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+#if !defined(LUA_READLINELIB)
#define LUA_READLINELIB "libreadline.so"
#endif
+#endif
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* macOS does not need -ldl */
-#define LUA_READLINELIB "libedit.dylib"
+#define LUA_USE_READLINE /* needs an extra library: -lreadline */
#endif
@@ -224,17 +226,17 @@
#if !defined(LUA_PATH_DEFAULT)
#define LUA_PATH_DEFAULT \
- LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
- LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
- LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
+ LUA_LDIR "?.lua;" LUA_LDIR "?\\init.lua;" \
+ LUA_CDIR "?.lua;" LUA_CDIR "?\\init.lua;" \
+ LUA_SHRDIR "?.lua;" LUA_SHRDIR "?\\init.lua;" \
".\\?.lua;" ".\\?\\init.lua"
#endif
#if !defined(LUA_CPATH_DEFAULT)
#define LUA_CPATH_DEFAULT \
- LUA_CDIR"?.dll;" \
- LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
- LUA_CDIR"loadall.dll;" ".\\?.dll"
+ LUA_CDIR "?.dll;" \
+ LUA_CDIR "..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
+ LUA_CDIR "loadall.dll;" ".\\?.dll"
#endif
#else /* }{ */
@@ -245,14 +247,14 @@
#if !defined(LUA_PATH_DEFAULT)
#define LUA_PATH_DEFAULT \
- LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
+ LUA_LDIR "?.lua;" LUA_LDIR "?/init.lua;" \
+ LUA_CDIR "?.lua;" LUA_CDIR "?/init.lua;" \
"./?.lua;" "./?/init.lua"
#endif
#if !defined(LUA_CPATH_DEFAULT)
#define LUA_CPATH_DEFAULT \
- LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
+ LUA_CDIR "?.so;" LUA_CDIR "loadall.so;" "./?.so"
#endif
#endif /* } */
@@ -339,7 +341,9 @@
/*
@@ LUA_COMPAT_GLOBAL avoids 'global' being a reserved word
*/
-#define LUA_COMPAT_GLOBAL
+#if !defined(LUA_COMPAT_GLOBAL)
+#define LUA_COMPAT_GLOBAL 1
+#endif
/*
@@ -649,7 +653,7 @@
*/
#if !defined(luai_likely)
-#if defined(__GNUC__) && !defined(LUA_NOBUILTIN)
+#if !defined(LUA_NOBUILTIN) && defined(__GNUC__) && (__GNUC__ >= 3)
#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else
@@ -721,10 +725,17 @@
/*
-@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
-** maximum alignment for the other items in that union.
+@@ LUAI_MAXALIGN defines fields that ensure proper alignment for
+** memory areas offered by Lua (e.g., userdata memory).
+** Add fields to it if you need alignment for non-ISO objects.
*/
+#if defined(LLONG_MAX)
+/* use ISO C99 stuff */
+#define LUAI_MAXALIGN long double u; void *s; long long l
+#else
+/* use only C89 stuff */
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
+#endif
/* }================================================================== */
src/lundump.c
@@ -392,7 +392,8 @@
/*
** Load precompiled chunk.
*/
-LClosure *luaU_undump (lua_State *L, ZIO *Z, const char *name, int fixed) {
+LClosure *luaU_undump (lua_State *L, ZIO *Z, Table *anchor, const char *name,
+ int fixed) {
LoadState S;
LClosure *cl;
if (*name == '@' || *name == '=')
@@ -405,20 +406,16 @@
S.fixed = cast_byte(fixed);
S.offset = 1; /* fist byte was already read */
checkHeader(&S);
- cl = luaF_newLclosure(L, loadByte(&S));
- setclLvalue2s(L, L->top.p, cl);
- luaD_inctop(L);
- S.h = luaH_new(L); /* create list of saved strings */
+ S.h = anchor;
S.nstr = 0;
- sethvalue2s(L, L->top.p, S.h); /* anchor it */
- luaD_inctop(L);
+ cl = luaF_newLclosure(L, loadByte(&S));
+ luaD_anchorobj(L, anchor, obj2gco(cl));
cl->p = luaF_newproto(L);
luaC_objbarrier(L, cl, cl->p);
loadFunction(&S, cl->p);
if (cl->nupvalues != cl->p->sizeupvalues)
error(&S, "corrupted chunk");
luai_verifycode(L, cl->p);
- L->top.p--; /* pop table */
return cl;
}
src/lundump.h
@@ -30,8 +30,8 @@
/* load one chunk; from lundump.c */
-LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name,
- int fixed);
+LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Table *anchor,
+ const char* name, int fixed);
/* dump one chunk; from ldump.c */
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
src/lutf8lib.c
@@ -56,6 +56,8 @@
l_uint32 res = 0; /* final result */
if (c < 0x80) /* ASCII? */
res = c;
+ else if (c >= 0xfe) /* c >= 1111 1110b ? */
+ return NULL; /* would need six or more continuation bytes */
else {
int count = 0; /* to count number of continuation bytes */
for (; c & 0x40; c <<= 1) { /* while it needs continuation bytes... */
@@ -64,8 +66,9 @@
return NULL; /* invalid byte sequence */
res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */
}
+ lua_assert(count <= 5);
res |= ((l_uint32)(c & 0x7F) << (count * 5)); /* add first byte */
- if (count > 5 || res > MAXUTF || res < limits[count])
+ if (res > MAXUTF || res < limits[count])
return NULL; /* invalid byte sequence */
s += count; /* skip continuation bytes read */
}
@@ -146,7 +149,7 @@
static void pushutfchar (lua_State *L, int arg) {
lua_Unsigned code = (lua_Unsigned)luaL_checkinteger(L, arg);
luaL_argcheck(L, code <= MAXUTF, arg, "value out of range");
- lua_pushfstring(L, "%U", (long)code);
+ lua_pushfstring(L, "%U", cast(unsigned long, code));
}
src/lvm.c
@@ -268,9 +268,9 @@
/*
** Execute a step of a float numerical for loop, returning
** true iff the loop must continue. (The integer case is
-** written online with opcode OP_FORLOOP, for performance.)
+** written inline with opcode OP_FORLOOP, for performance.)
*/
-static int floatforloop (StkId ra) {
+static int floatforloop (lua_State *L, StkId ra) {
lua_Number step = fltvalue(s2v(ra + 1));
lua_Number limit = fltvalue(s2v(ra));
lua_Number idx = fltvalue(s2v(ra + 2)); /* control variable */
@@ -303,7 +303,7 @@
else { /* 't' is a table */
tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */
if (tm == NULL) { /* no metamethod? */
- setnilvalue(s2v(val)); /* result is nil */
+ setnilvalue2s(val); /* result is nil */
return LUA_VNIL;
}
/* else will try the metamethod */
@@ -360,13 +360,19 @@
luaT_callTM(L, tm, t, key, val);
return;
}
- t = tm; /* else repeat assignment over 'tm' */
- luaV_fastset(t, key, val, hres, luaH_pset);
- if (hres == HOK) {
- luaV_finishfastset(L, t, val);
- return; /* done */
+ t = tm; /* else must repeat assignment over 'tm' */
+ /* do the equivalent to 'luaV_fastset', but saving 'h' */
+ if (!ttistable(t))
+ hres = HNOTATABLE;
+ else {
+ Table *h = hvalue(t); /* next call can change the value at 't' */
+ hres = luaH_pset(h, key, val);
+ if (hres == HOK) {
+ luaC_barrierback(L, obj2gco(h), val); /* luaV_finishfastset */
+ return; /* done */
+ }
}
- /* else 'return luaV_finishset(L, t, key, val, slot)' (loop) */
+ /* else 'return luaV_finishset(L, t, key, val, hres)' (loop) */
}
luaG_runerror(L, "'__newindex' chain too long; possible loop");
}
@@ -919,7 +925,7 @@
** Macros for arithmetic/bitwise/comparison opcodes in 'luaV_execute'
**
** All these macros are to be used exclusively inside the main
-** iterpreter loop (function luaV_execute) and may access directly
+** interpreter loop (function luaV_execute) and may access directly
** the local variables of that function (L, i, pc, ci, etc.).
** ===================================================================
*/
@@ -1841,7 +1847,7 @@
pc -= GETARG_Bx(i); /* jump back */
}
}
- else if (floatforloop(ra)) /* float loop */
+ else if (floatforloop(L, ra)) /* float loop */
pc -= GETARG_Bx(i); /* jump back */
updatetrap(ci); /* allows a signal to break the loop */
vmbreak;