mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
LUA to 5.3.4 (nw)
This commit is contained in:
parent
8d1eb8e410
commit
e6838eb5c4
2
3rdparty/lua/Makefile
vendored
2
3rdparty/lua/Makefile
vendored
@ -46,7 +46,7 @@ TO_MAN= lua.1 luac.1
|
|||||||
|
|
||||||
# Lua version and release.
|
# Lua version and release.
|
||||||
V= 5.3
|
V= 5.3
|
||||||
R= $V.3
|
R= $V.4
|
||||||
|
|
||||||
# Targets start here.
|
# Targets start here.
|
||||||
all: $(PLAT)
|
all: $(PLAT)
|
||||||
|
2
3rdparty/lua/README
vendored
2
3rdparty/lua/README
vendored
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
This is Lua 5.3.3, released on 30 May 2016.
|
This is Lua 5.3.4, released on 12 Jan 2017.
|
||||||
|
|
||||||
For installation instructions, license details, and
|
For installation instructions, license details, and
|
||||||
further information about Lua, see doc/readme.html.
|
further information about Lua, see doc/readme.html.
|
||||||
|
7
3rdparty/lua/doc/contents.html
vendored
7
3rdparty/lua/doc/contents.html
vendored
@ -32,7 +32,7 @@ For a complete introduction to Lua programming, see the book
|
|||||||
|
|
||||||
<P>
|
<P>
|
||||||
<SMALL>
|
<SMALL>
|
||||||
Copyright © 2015–2016 Lua.org, PUC-Rio.
|
Copyright © 2015–2017 Lua.org, PUC-Rio.
|
||||||
Freely available under the terms of the
|
Freely available under the terms of the
|
||||||
<A HREF="http://www.lua.org/license.html">Lua license</A>.
|
<A HREF="http://www.lua.org/license.html">Lua license</A>.
|
||||||
</SMALL>
|
</SMALL>
|
||||||
@ -512,6 +512,7 @@ Freely available under the terms of the
|
|||||||
<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>
|
<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>
|
||||||
<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>
|
<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>
|
||||||
<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
|
<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
|
||||||
|
<A HREF="manual.html#luaL_opt">luaL_opt</A><BR>
|
||||||
<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
|
<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
|
||||||
<A HREF="manual.html#luaL_optlstring">luaL_optlstring</A><BR>
|
<A HREF="manual.html#luaL_optlstring">luaL_optlstring</A><BR>
|
||||||
<A HREF="manual.html#luaL_optnumber">luaL_optnumber</A><BR>
|
<A HREF="manual.html#luaL_optnumber">luaL_optnumber</A><BR>
|
||||||
@ -608,10 +609,10 @@ Freely available under the terms of the
|
|||||||
|
|
||||||
<P CLASS="footer">
|
<P CLASS="footer">
|
||||||
Last update:
|
Last update:
|
||||||
Thu Jan 14 10:14:28 BRST 2016
|
Thu Dec 22 18:29:39 BRST 2016
|
||||||
</P>
|
</P>
|
||||||
<!--
|
<!--
|
||||||
Last change: revised for Lua 5.3.3
|
Last change: revised for Lua 5.3.4
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</BODY>
|
</BODY>
|
||||||
|
BIN
3rdparty/lua/doc/logo.gif
vendored
BIN
3rdparty/lua/doc/logo.gif
vendored
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 9.7 KiB |
3
3rdparty/lua/doc/lua.1
vendored
3
3rdparty/lua/doc/lua.1
vendored
@ -1,4 +1,5 @@
|
|||||||
.TH LUA 1 "$Date: 2014/12/10 15:55:45 $"
|
.\" $Id: lua.man,v 1.14 2016/10/17 15:43:50 lhf Exp $
|
||||||
|
.TH LUA 1 "$Date: 2016/10/17 15:43:50 $"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
lua \- Lua interpreter
|
lua \- Lua interpreter
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
253
3rdparty/lua/doc/manual.html
vendored
253
3rdparty/lua/doc/manual.html
vendored
@ -19,7 +19,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
|
|||||||
|
|
||||||
<P>
|
<P>
|
||||||
<SMALL>
|
<SMALL>
|
||||||
Copyright © 2015–2016 Lua.org, PUC-Rio.
|
Copyright © 2015–2017 Lua.org, PUC-Rio.
|
||||||
Freely available under the terms of the
|
Freely available under the terms of the
|
||||||
<a href="http://www.lua.org/license.html">Lua license</a>.
|
<a href="http://www.lua.org/license.html">Lua license</a>.
|
||||||
</SMALL>
|
</SMALL>
|
||||||
@ -35,7 +35,7 @@ Freely available under the terms of the
|
|||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
<!-- $Id: manual.of,v 1.162 2016/05/30 15:57:03 roberto Exp $ -->
|
<!-- $Id: manual.of,v 1.167 2017/01/09 15:18:11 roberto Exp $ -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ an associated value <b>nil</b>.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Tables are the sole data-structuring mechanism in Lua;
|
Tables are the sole data-structuring mechanism in Lua;
|
||||||
they can be used to represent ordinary arrays, sequences,
|
they can be used to represent ordinary arrays, lists,
|
||||||
symbol tables, sets, records, graphs, trees, etc.
|
symbol tables, sets, records, graphs, trees, etc.
|
||||||
To represent records, Lua uses the field name as an index.
|
To represent records, Lua uses the field name as an index.
|
||||||
The language supports this representation by
|
The language supports this representation by
|
||||||
@ -225,13 +225,6 @@ There are several convenient ways to create tables in Lua
|
|||||||
(see <a href="#3.4.9">§3.4.9</a>).
|
(see <a href="#3.4.9">§3.4.9</a>).
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
We use the term <em>sequence</em> to denote a table where
|
|
||||||
the set of all positive numeric keys is equal to {1..<em>n</em>}
|
|
||||||
for some non-negative integer <em>n</em>,
|
|
||||||
which is called the length of the sequence (see <a href="#3.4.7">§3.4.7</a>).
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Like indices,
|
Like indices,
|
||||||
the values of table fields can be of any type.
|
the values of table fields can be of any type.
|
||||||
@ -378,6 +371,9 @@ so, an error inside the message handler
|
|||||||
will call the message handler again.
|
will call the message handler again.
|
||||||
If this loop goes on for too long,
|
If this loop goes on for too long,
|
||||||
Lua breaks it and returns an appropriate message.
|
Lua breaks it and returns an appropriate message.
|
||||||
|
(The message handler is called only for regular runtime errors.
|
||||||
|
It is not called for memory-allocation errors
|
||||||
|
nor for errors while running finalizers.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -873,7 +869,7 @@ before the change takes effect.
|
|||||||
<p>
|
<p>
|
||||||
Only objects that have an explicit construction
|
Only objects that have an explicit construction
|
||||||
are removed from weak tables.
|
are removed from weak tables.
|
||||||
Values, such as numbers and light C functions,
|
Values, such as numbers and light C functions,
|
||||||
are not subject to garbage collection,
|
are not subject to garbage collection,
|
||||||
and therefore are not removed from weak tables
|
and therefore are not removed from weak tables
|
||||||
(unless their associated values are collected).
|
(unless their associated values are collected).
|
||||||
@ -1101,7 +1097,7 @@ The following strings denote other tokens:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<em>Literal strings</em>
|
A <em>short literal string</em>
|
||||||
can be delimited by matching single or double quotes,
|
can be delimited by matching single or double quotes,
|
||||||
and can contain the following C-like escape sequences:
|
and can contain the following C-like escape sequences:
|
||||||
'<code>\a</code>' (bell),
|
'<code>\a</code>' (bell),
|
||||||
@ -1114,7 +1110,7 @@ and can contain the following C-like escape sequences:
|
|||||||
'<code>\\</code>' (backslash),
|
'<code>\\</code>' (backslash),
|
||||||
'<code>\"</code>' (quotation mark [double quote]),
|
'<code>\"</code>' (quotation mark [double quote]),
|
||||||
and '<code>\'</code>' (apostrophe [single quote]).
|
and '<code>\'</code>' (apostrophe [single quote]).
|
||||||
A backslash followed by a real newline
|
A backslash followed by a line break
|
||||||
results in a newline in the string.
|
results in a newline in the string.
|
||||||
The escape sequence '<code>\z</code>' skips the following span
|
The escape sequence '<code>\z</code>' skips the following span
|
||||||
of white-space characters,
|
of white-space characters,
|
||||||
@ -1122,13 +1118,13 @@ including line breaks;
|
|||||||
it is particularly useful to break and indent a long literal string
|
it is particularly useful to break and indent a long literal string
|
||||||
into multiple lines without adding the newlines and spaces
|
into multiple lines without adding the newlines and spaces
|
||||||
into the string contents.
|
into the string contents.
|
||||||
|
A short literal string cannot contain unescaped line breaks
|
||||||
|
nor escapes not forming a valid escape sequence.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Strings in Lua can contain any 8-bit value, including embedded zeros,
|
We can specify any byte in a short literal string by its numeric value
|
||||||
which can be specified as '<code>\0</code>'.
|
(including embedded zeros).
|
||||||
More generally,
|
|
||||||
we can specify any byte in a literal string by its numeric value.
|
|
||||||
This can be done
|
This can be done
|
||||||
with the escape sequence <code>\x<em>XX</em></code>,
|
with the escape sequence <code>\x<em>XX</em></code>,
|
||||||
where <em>XX</em> is a sequence of exactly two hexadecimal digits,
|
where <em>XX</em> is a sequence of exactly two hexadecimal digits,
|
||||||
@ -1171,17 +1167,6 @@ or newline followed by carriage return)
|
|||||||
is converted to a simple newline.
|
is converted to a simple newline.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Any byte in a literal string not
|
|
||||||
explicitly affected by the previous rules represents itself.
|
|
||||||
However, Lua opens files for parsing in text mode,
|
|
||||||
and the system file functions may have problems with
|
|
||||||
some control characters.
|
|
||||||
So, it is safer to represent
|
|
||||||
non-text data as a quoted literal with
|
|
||||||
explicit escape sequences for the non-text characters.
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
For convenience,
|
For convenience,
|
||||||
when the opening long bracket is immediately followed by a newline,
|
when the opening long bracket is immediately followed by a newline,
|
||||||
@ -1202,6 +1187,17 @@ the five literal strings below denote the same string:
|
|||||||
123"]==]
|
123"]==]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Any byte in a literal string not
|
||||||
|
explicitly affected by the previous rules represents itself.
|
||||||
|
However, Lua opens files for parsing in text mode,
|
||||||
|
and the system file functions may have problems with
|
||||||
|
some control characters.
|
||||||
|
So, it is safer to represent
|
||||||
|
non-text data as a quoted literal with
|
||||||
|
explicit escape sequences for the non-text characters.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A <em>numeric constant</em> (or <em>numeral</em>)
|
A <em>numeric constant</em> (or <em>numeral</em>)
|
||||||
can be written with an optional fractional part
|
can be written with an optional fractional part
|
||||||
@ -2140,37 +2136,66 @@ Otherwise, the <code>__concat</code> metamethod is called (see <a href="#2.4">&s
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
The length operator is denoted by the unary prefix operator <code>#</code>.
|
The length operator is denoted by the unary prefix operator <code>#</code>.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
The length of a string is its number of bytes
|
The length of a string is its number of bytes
|
||||||
(that is, the usual meaning of string length when each
|
(that is, the usual meaning of string length when each
|
||||||
character is one byte).
|
character is one byte).
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A program can modify the behavior of the length operator for
|
The length operator applied on a table
|
||||||
any value but strings through the <code>__len</code> metamethod (see <a href="#2.4">§2.4</a>).
|
returns a border in that table.
|
||||||
|
A <em>border</em> in a table <code>t</code> is any natural number
|
||||||
|
that satisfies the following condition:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
(border == 0 or t[border] ~= nil) and t[border + 1] == nil
|
||||||
|
</pre><p>
|
||||||
|
In words,
|
||||||
|
a border is any (natural) index in a table
|
||||||
|
where a non-nil value is followed by a nil value
|
||||||
|
(or zero, when index 1 is nil).
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Unless a <code>__len</code> metamethod is given,
|
A table with exactly one border is called a <em>sequence</em>.
|
||||||
the length of a table <code>t</code> is only defined if the
|
For instance, the table <code>{10, 20, 30, 40, 50}</code> is a sequence,
|
||||||
table is a <em>sequence</em>,
|
as it has only one border (5).
|
||||||
that is,
|
The table <code>{10, 20, 30, nil, 50}</code> has two borders (3 and 5),
|
||||||
the set of its positive numeric keys is equal to <em>{1..n}</em>
|
and therefore it is not a sequence.
|
||||||
for some non-negative integer <em>n</em>.
|
The table <code>{nil, 20, 30, nil, nil, 60, nil}</code>
|
||||||
In that case, <em>n</em> is its length.
|
has three borders (0, 3, and 6),
|
||||||
Note that a table like
|
so it is not a sequence, too.
|
||||||
|
The table <code>{}</code> is a sequence with border 0.
|
||||||
<pre>
|
Note that non-natural keys do not interfere
|
||||||
{10, 20, nil, 40}
|
|
||||||
</pre><p>
|
|
||||||
is not a sequence, because it has the key <code>4</code>
|
|
||||||
but does not have the key <code>3</code>.
|
|
||||||
(So, there is no <em>n</em> such that the set <em>{1..n}</em> is equal
|
|
||||||
to the set of positive numeric keys of that table.)
|
|
||||||
Note, however, that non-numeric keys do not interfere
|
|
||||||
with whether a table is a sequence.
|
with whether a table is a sequence.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When <code>t</code> is a sequence,
|
||||||
|
<code>#t</code> returns its only border,
|
||||||
|
which corresponds to the intuitive notion of the length of the sequence.
|
||||||
|
When <code>t</code> is not a sequence,
|
||||||
|
<code>#t</code> can return any of its borders.
|
||||||
|
(The exact one depends on details of
|
||||||
|
the internal representation of the table,
|
||||||
|
which in turn can depend on how the table was populated and
|
||||||
|
the memory addresses of its non-numeric keys.)
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The computation of the length of a table
|
||||||
|
has a guaranteed worst time of <em>O(log n)</em>,
|
||||||
|
where <em>n</em> is the largest natural key in the table.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
A program can modify the behavior of the length operator for
|
||||||
|
any value but strings through the <code>__len</code> metamethod (see <a href="#2.4">§2.4</a>).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2585,6 +2610,28 @@ However, you can change this behavior by compiling Lua
|
|||||||
with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a> defined.
|
with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a> defined.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The Lua library is fully reentrant:
|
||||||
|
it has no global variables.
|
||||||
|
It keeps all information it needs in a dynamic structure,
|
||||||
|
called the <em>Lua state</em>.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Each Lua state has one or more threads,
|
||||||
|
which correspond to independent, cooperative lines of execution.
|
||||||
|
The type <a href="#lua_State"><code>lua_State</code></a> (despite its name) refers to a thread.
|
||||||
|
(Indirectly, through the thread, it also refers to the
|
||||||
|
Lua state associated to the thread.)
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
A pointer to a thread must be passed as the first argument to
|
||||||
|
every function in the library, except to <a href="#lua_newstate"><code>lua_newstate</code></a>,
|
||||||
|
which creates a Lua state from scratch and returns a pointer
|
||||||
|
to the <em>main thread</em> in the new state.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>4.1 – <a name="4.1">The Stack</a></h2>
|
<h2>4.1 – <a name="4.1">The Stack</a></h2>
|
||||||
|
|
||||||
@ -2592,6 +2639,8 @@ with the macro <a name="pdf-LUA_USE_APICHECK"><code>LUA_USE_APICHECK</code></a>
|
|||||||
Lua uses a <em>virtual stack</em> to pass values to and from C.
|
Lua uses a <em>virtual stack</em> to pass values to and from C.
|
||||||
Each element in this stack represents a Lua value
|
Each element in this stack represents a Lua value
|
||||||
(<b>nil</b>, number, string, etc.).
|
(<b>nil</b>, number, string, etc.).
|
||||||
|
Functions in the API can access this stack through the
|
||||||
|
Lua state parameter that they receive.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2599,7 +2648,8 @@ Whenever Lua calls C, the called function gets a new stack,
|
|||||||
which is independent of previous stacks and of stacks of
|
which is independent of previous stacks and of stacks of
|
||||||
C functions that are still active.
|
C functions that are still active.
|
||||||
This stack initially contains any arguments to the C function
|
This stack initially contains any arguments to the C function
|
||||||
and it is where the C function pushes its results
|
and it is where the C function can store temporary
|
||||||
|
Lua values and must push its results
|
||||||
to be returned to the caller (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
|
to be returned to the caller (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
|
||||||
|
|
||||||
|
|
||||||
@ -2791,8 +2841,7 @@ Internally, Lua uses the C <code>longjmp</code> facility to handle errors.
|
|||||||
(Lua will use exceptions if you compile it as C++;
|
(Lua will use exceptions if you compile it as C++;
|
||||||
search for <code>LUAI_THROW</code> in the source code for details.)
|
search for <code>LUAI_THROW</code> in the source code for details.)
|
||||||
When Lua faces any error
|
When Lua faces any error
|
||||||
(such as a memory allocation error, type errors, syntax errors,
|
(such as a memory allocation error or a type error)
|
||||||
and runtime errors)
|
|
||||||
it <em>raises</em> an error;
|
it <em>raises</em> an error;
|
||||||
that is, it does a long jump.
|
that is, it does a long jump.
|
||||||
A <em>protected environment</em> uses <code>setjmp</code>
|
A <em>protected environment</em> uses <code>setjmp</code>
|
||||||
@ -2800,6 +2849,17 @@ to set a recovery point;
|
|||||||
any error jumps to the most recent active recovery point.
|
any error jumps to the most recent active recovery point.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Inside a C function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Most functions in the API can raise an error,
|
||||||
|
for instance due to a memory allocation error.
|
||||||
|
The documentation for each function indicates whether
|
||||||
|
it can raise errors.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If an error happens outside any protected environment,
|
If an error happens outside any protected environment,
|
||||||
Lua calls a <em>panic function</em> (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>)
|
Lua calls a <em>panic function</em> (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>)
|
||||||
@ -2810,6 +2870,23 @@ never returning
|
|||||||
(e.g., doing a long jump to your own recovery point outside Lua).
|
(e.g., doing a long jump to your own recovery point outside Lua).
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The panic function,
|
||||||
|
as its name implies,
|
||||||
|
is a mechanism of last resort.
|
||||||
|
Programs should avoid it.
|
||||||
|
As a general rule,
|
||||||
|
when a C function is called by Lua with a Lua state,
|
||||||
|
it can do whatever it wants on that Lua state,
|
||||||
|
as it should be already protected.
|
||||||
|
However,
|
||||||
|
when C code operates on other Lua states
|
||||||
|
(e.g., a Lua parameter to the function,
|
||||||
|
a Lua state stored in the registry, or
|
||||||
|
the result of <a href="#lua_newthread"><code>lua_newthread</code></a>),
|
||||||
|
it should use them only in API calls that cannot raise errors.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The panic function runs as if it were a message handler (see <a href="#2.3">§2.3</a>);
|
The panic function runs as if it were a message handler (see <a href="#2.3">§2.3</a>);
|
||||||
in particular, the error object is at the top of the stack.
|
in particular, the error object is at the top of the stack.
|
||||||
@ -2818,17 +2895,6 @@ To push anything on the stack,
|
|||||||
the panic function must first check the available space (see <a href="#4.2">§4.2</a>).
|
the panic function must first check the available space (see <a href="#4.2">§4.2</a>).
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Most functions in the API can raise an error,
|
|
||||||
for instance due to a memory allocation error.
|
|
||||||
The documentation for each function indicates whether
|
|
||||||
it can raise errors.
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Inside a C function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2836,7 +2902,7 @@ Inside a C function you can raise an error by calling <a href="#lua_error">
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Internally, Lua uses the C <code>longjmp</code> facility to yield a coroutine.
|
Internally, Lua uses the C <code>longjmp</code> facility to yield a coroutine.
|
||||||
Therefore, if a C function <code>foo</code> calls an API function
|
Therefore, if a C function <code>foo</code> calls an API function
|
||||||
and this API function yields
|
and this API function yields
|
||||||
(directly or indirectly by calling another function that yields),
|
(directly or indirectly by calling another function that yields),
|
||||||
Lua cannot return to <code>foo</code> any more,
|
Lua cannot return to <code>foo</code> any more,
|
||||||
@ -2854,7 +2920,7 @@ All those functions receive a <em>continuation function</em>
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
We need to set some terminology to explain continuations.
|
We need to set some terminology to explain continuations.
|
||||||
We have a C function called from Lua which we will call
|
We have a C function called from Lua which we will call
|
||||||
the <em>original function</em>.
|
the <em>original function</em>.
|
||||||
This original function then calls one of those three functions in the C API,
|
This original function then calls one of those three functions in the C API,
|
||||||
which we will call the <em>callee function</em>,
|
which we will call the <em>callee function</em>,
|
||||||
@ -3169,7 +3235,7 @@ when the function is called.
|
|||||||
The function results are pushed onto the stack when the function returns.
|
The function results are pushed onto the stack when the function returns.
|
||||||
The number of results is adjusted to <code>nresults</code>,
|
The number of results is adjusted to <code>nresults</code>,
|
||||||
unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
|
unless <code>nresults</code> is <a name="pdf-LUA_MULTRET"><code>LUA_MULTRET</code></a>.
|
||||||
In this case, all results from the function are pushed.
|
In this case, all results from the function are pushed;
|
||||||
Lua takes care that the returned values fit into the stack space,
|
Lua takes care that the returned values fit into the stack space,
|
||||||
but it does not ensure any extra space in the stack.
|
but it does not ensure any extra space in the stack.
|
||||||
The function results are pushed onto the stack in direct order
|
The function results are pushed onto the stack in direct order
|
||||||
@ -3655,7 +3721,7 @@ in particular, 0 means an empty stack.
|
|||||||
<pre>int lua_getuservalue (lua_State *L, int index);</pre>
|
<pre>int lua_getuservalue (lua_State *L, int index);</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Pushes onto the stack the Lua value associated with the userdata
|
Pushes onto the stack the Lua value associated with the full userdata
|
||||||
at the given index.
|
at the given index.
|
||||||
|
|
||||||
|
|
||||||
@ -3998,7 +4064,8 @@ Creates a new thread running in a new, independent state.
|
|||||||
Returns <code>NULL</code> if it cannot create the thread or the state
|
Returns <code>NULL</code> if it cannot create the thread or the state
|
||||||
(due to lack of memory).
|
(due to lack of memory).
|
||||||
The argument <code>f</code> is the allocator function;
|
The argument <code>f</code> is the allocator function;
|
||||||
Lua does all memory allocation for this state through this function.
|
Lua does all memory allocation for this state
|
||||||
|
through this function (see <a href="#lua_Alloc"><code>lua_Alloc</code></a>).
|
||||||
The second argument, <code>ud</code>, is an opaque pointer that Lua
|
The second argument, <code>ud</code>, is an opaque pointer that Lua
|
||||||
passes to the allocator in every call.
|
passes to the allocator in every call.
|
||||||
|
|
||||||
@ -4202,7 +4269,9 @@ error while running the message handler.
|
|||||||
|
|
||||||
<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
|
<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
|
||||||
error while running a <code>__gc</code> metamethod.
|
error while running a <code>__gc</code> metamethod.
|
||||||
(This error typically has no relation with the function being called.)
|
For such errors, Lua does not call the message handler
|
||||||
|
(as this kind of error typically has no relation
|
||||||
|
with the function being called).
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
@ -4278,7 +4347,7 @@ The maximum value for <code>n</code> is 255.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
When <code>n</code> is zero,
|
When <code>n</code> is zero,
|
||||||
this function creates a <em>light C function</em>,
|
this function creates a <em>light C function</em>,
|
||||||
which is just a pointer to the C function.
|
which is just a pointer to the C function.
|
||||||
In that case, it never raises a memory error.
|
In that case, it never raises a memory error.
|
||||||
|
|
||||||
@ -4292,7 +4361,7 @@ In that case, it never raises a memory error.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Pushes a C function onto the stack.
|
Pushes a C function onto the stack.
|
||||||
This function receives a pointer to a C function
|
This function receives a pointer to a C function
|
||||||
and pushes onto the stack a Lua value of type <code>function</code> that,
|
and pushes onto the stack a Lua value of type <code>function</code> that,
|
||||||
when called, invokes the corresponding C function.
|
when called, invokes the corresponding C function.
|
||||||
|
|
||||||
@ -4667,7 +4736,7 @@ The reader function may return pieces of any size greater than zero.
|
|||||||
<pre>void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
|
<pre>void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Sets the C function <code>f</code> as the new value of global <code>name</code>.
|
Sets the C function <code>f</code> as the new value of global <code>name</code>.
|
||||||
It is defined as a macro:
|
It is defined as a macro:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -4888,7 +4957,7 @@ If <code>index</code> is 0, then all stack elements are removed.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Pops a value from the stack and sets it as
|
Pops a value from the stack and sets it as
|
||||||
the new value associated to the userdata at the given index.
|
the new value associated to the full userdata at the given index.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -5302,7 +5371,7 @@ that will be passed as results to <a href="#lua_resume"><code>lua_resume</code><
|
|||||||
<p>
|
<p>
|
||||||
When the coroutine is resumed again,
|
When the coroutine is resumed again,
|
||||||
Lua calls the given continuation function <code>k</code> to continue
|
Lua calls the given continuation function <code>k</code> to continue
|
||||||
the execution of the C function that yielded (see <a href="#4.7">§4.7</a>).
|
the execution of the C function that yielded (see <a href="#4.7">§4.7</a>).
|
||||||
This continuation function receives the same stack
|
This continuation function receives the same stack
|
||||||
from the previous function,
|
from the previous function,
|
||||||
with the <code>n</code> results removed and
|
with the <code>n</code> results removed and
|
||||||
@ -6013,7 +6082,7 @@ If it is not, raises an error with a standard message (see <a href="#luaL_argerr
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Raises an error reporting a problem with argument <code>arg</code>
|
Raises an error reporting a problem with argument <code>arg</code>
|
||||||
of the C function that called it,
|
of the C function that called it,
|
||||||
using a standard message
|
using a standard message
|
||||||
that includes <code>extramsg</code> as a comment:
|
that includes <code>extramsg</code> as a comment:
|
||||||
|
|
||||||
@ -6534,7 +6603,8 @@ The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_
|
|||||||
<p>
|
<p>
|
||||||
This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>,
|
This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>,
|
||||||
but it has an extra error code <a name="pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a>
|
but it has an extra error code <a name="pdf-LUA_ERRFILE"><code>LUA_ERRFILE</code></a>
|
||||||
if it cannot open/read the file or the file has a wrong mode.
|
for file-related errors
|
||||||
|
(e.g., it cannot open or read the file).
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -6727,6 +6797,11 @@ If the result is <code>NULL</code>
|
|||||||
its length is considered zero.
|
its length is considered zero.
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
|
||||||
|
so all conversions and caveats of that function apply here.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -7674,7 +7749,7 @@ Returns true when the running coroutine can yield.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
A running coroutine is yieldable if it is not the main thread and
|
A running coroutine is yieldable if it is not the main thread and
|
||||||
it is not inside a non-yieldable C function.
|
it is not inside a non-yieldable C function.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -7876,8 +7951,8 @@ The path used by <a href="#pdf-require"><code>require</code></a> to search for a
|
|||||||
<p>
|
<p>
|
||||||
Lua initializes the C path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
|
Lua initializes the C path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
|
||||||
it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
|
it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
|
||||||
using the environment variable <a name="pdf-LUA_CPATH_5_3"><code>LUA_CPATH_5_3</code></a>
|
using the environment variable <a name="pdf-LUA_CPATH_5_3"><code>LUA_CPATH_5_3</code></a>,
|
||||||
or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
|
or the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>,
|
||||||
or a default path defined in <code>luaconf.h</code>.
|
or a default path defined in <code>luaconf.h</code>.
|
||||||
|
|
||||||
|
|
||||||
@ -8485,7 +8560,8 @@ If <code>j</code> is absent, then it is assumed to be equal to -1
|
|||||||
In particular,
|
In particular,
|
||||||
the call <code>string.sub(s,1,j)</code> returns a prefix of <code>s</code>
|
the call <code>string.sub(s,1,j)</code> returns a prefix of <code>s</code>
|
||||||
with length <code>j</code>,
|
with length <code>j</code>,
|
||||||
and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>
|
and <code>string.sub(s, -i)</code> (for a positive <code>i</code>)
|
||||||
|
returns a suffix of <code>s</code>
|
||||||
with length <code>i</code>.
|
with length <code>i</code>.
|
||||||
|
|
||||||
|
|
||||||
@ -8946,8 +9022,7 @@ It provides all its functions inside the table <a name="pdf-table"><code>table</
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Remember that, whenever an operation needs the length of a table,
|
Remember that, whenever an operation needs the length of a table,
|
||||||
the table must be a proper sequence
|
all caveats about the length operator apply (see <a href="#3.4.7">§3.4.7</a>).
|
||||||
or have a <code>__len</code> metamethod (see <a href="#3.4.7">§3.4.7</a>).
|
|
||||||
All functions ignore non-numeric keys
|
All functions ignore non-numeric keys
|
||||||
in the tables given as arguments.
|
in the tables given as arguments.
|
||||||
|
|
||||||
@ -9063,9 +9138,8 @@ Otherwise, no valid sort may be possible.
|
|||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The sort algorithm is not stable;
|
The sort algorithm is not stable:
|
||||||
that is, elements not comparable by the given order
|
elements considered equal by the given order
|
||||||
(e.g., equal elements)
|
|
||||||
may have their relative positions changed by the sort.
|
may have their relative positions changed by the sort.
|
||||||
|
|
||||||
|
|
||||||
@ -9401,7 +9475,7 @@ or <b>nil</b> if <code>x</code> is not a number.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Returns a boolean,
|
Returns a boolean,
|
||||||
true if integer <code>m</code> is below integer <code>n</code> when
|
true if and only if integer <code>m</code> is below integer <code>n</code> when
|
||||||
they are compared as unsigned integers.
|
they are compared as unsigned integers.
|
||||||
|
|
||||||
|
|
||||||
@ -9987,6 +10061,7 @@ Deletes the file (or empty directory, on POSIX systems)
|
|||||||
with the given name.
|
with the given name.
|
||||||
If this function fails, it returns <b>nil</b>,
|
If this function fails, it returns <b>nil</b>,
|
||||||
plus a string describing the error and the error code.
|
plus a string describing the error and the error code.
|
||||||
|
Otherwise, it returns true.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -9996,9 +10071,10 @@ plus a string describing the error and the error code.
|
|||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Renames file or directory named <code>oldname</code> to <code>newname</code>.
|
Renames the file or directory named <code>oldname</code> to <code>newname</code>.
|
||||||
If this function fails, it returns <b>nil</b>,
|
If this function fails, it returns <b>nil</b>,
|
||||||
plus a string describing the error and the error code.
|
plus a string describing the error and the error code.
|
||||||
|
Otherwise, it returns true.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -10291,7 +10367,7 @@ represent variables with no known names
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Returns the Lua value associated to <code>u</code>.
|
Returns the Lua value associated to <code>u</code>.
|
||||||
If <code>u</code> is not a userdata,
|
If <code>u</code> is not a full userdata,
|
||||||
returns <b>nil</b>.
|
returns <b>nil</b>.
|
||||||
|
|
||||||
|
|
||||||
@ -10897,13 +10973,12 @@ and LiteralString, see <a href="#3.1">§3.1</a>.)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<P CLASS="footer">
|
<P CLASS="footer">
|
||||||
Last update:
|
Last update:
|
||||||
Mon May 30 13:11:08 BRT 2016
|
Mon Jan 9 13:30:53 BRST 2017
|
||||||
</P>
|
</P>
|
||||||
<!--
|
<!--
|
||||||
Last change: revised for Lua 5.3.3
|
Last change: revised for Lua 5.3.4
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
6
3rdparty/lua/doc/readme.html
vendored
6
3rdparty/lua/doc/readme.html
vendored
@ -328,7 +328,7 @@ For details, see
|
|||||||
<A HREF="http://www.lua.org/license.html">this</A>.
|
<A HREF="http://www.lua.org/license.html">this</A>.
|
||||||
|
|
||||||
<BLOCKQUOTE STYLE="padding-bottom: 0em">
|
<BLOCKQUOTE STYLE="padding-bottom: 0em">
|
||||||
Copyright © 1994–2016 Lua.org, PUC-Rio.
|
Copyright © 1994–2017 Lua.org, PUC-Rio.
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -355,10 +355,10 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
<P CLASS="footer">
|
<P CLASS="footer">
|
||||||
Last update:
|
Last update:
|
||||||
Tue Feb 2 22:25:27 BRST 2016
|
Thu Dec 22 18:22:57 BRST 2016
|
||||||
</P>
|
</P>
|
||||||
<!--
|
<!--
|
||||||
Last change: revised for Lua 5.3.3
|
Last change: revised for Lua 5.3.4
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</BODY>
|
</BODY>
|
||||||
|
6
3rdparty/lua/src/Makefile
vendored
6
3rdparty/lua/src/Makefile
vendored
@ -6,8 +6,8 @@
|
|||||||
# Your platform. See PLATS for possible values.
|
# Your platform. See PLATS for possible values.
|
||||||
PLAT= none
|
PLAT= none
|
||||||
|
|
||||||
CC= g++ -std=gnu99
|
CC= gcc -std=gnu99
|
||||||
CFLAGS= -console -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
|
CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
|
||||||
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
|
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
|
||||||
LIBS= -lm $(SYSLIBS) $(MYLIBS)
|
LIBS= -lm $(SYSLIBS) $(MYLIBS)
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ macosx:
|
|||||||
|
|
||||||
mingw:
|
mingw:
|
||||||
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
|
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
|
||||||
"AR=$(CC) -lstdc++ -o" "RANLIB=strip --strip-unneeded" \
|
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
|
||||||
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
|
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
|
||||||
$(MAKE) "LUAC_T=luac.exe" luac.exe
|
$(MAKE) "LUAC_T=luac.exe" luac.exe
|
||||||
|
|
||||||
|
46
3rdparty/lua/src/lauxlib.c
vendored
46
3rdparty/lua/src/lauxlib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.286 2016/01/08 15:33:09 roberto Exp $
|
** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -69,12 +69,11 @@ static int findfield (lua_State *L, int objidx, int level) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Search for a name for a function in all loaded modules
|
** Search for a name for a function in all loaded modules
|
||||||
** (registry._LOADED).
|
|
||||||
*/
|
*/
|
||||||
static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
|
static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
lua_getinfo(L, "f", ar); /* push function */
|
lua_getinfo(L, "f", ar); /* push function */
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
|
||||||
if (findfield(L, top + 1, 2)) {
|
if (findfield(L, top + 1, 2)) {
|
||||||
const char *name = lua_tostring(L, -1);
|
const char *name = lua_tostring(L, -1);
|
||||||
if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */
|
if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */
|
||||||
@ -809,13 +808,17 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
||||||
if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
|
if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */
|
||||||
|
if (!lua_isstring(L, -1))
|
||||||
|
luaL_error(L, "'__tostring' must return a string");
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch (lua_type(L, idx)) {
|
switch (lua_type(L, idx)) {
|
||||||
case LUA_TNUMBER: {
|
case LUA_TNUMBER: {
|
||||||
if (lua_isinteger(L, idx))
|
if (lua_isinteger(L, idx))
|
||||||
lua_pushfstring(L, "%I", lua_tointeger(L, idx));
|
lua_pushfstring(L, "%I", (LUAI_UACINT)lua_tointeger(L, idx));
|
||||||
else
|
else
|
||||||
lua_pushfstring(L, "%f", lua_tonumber(L, idx));
|
lua_pushfstring(L, "%f", (LUAI_UACNUMBER)lua_tonumber(L, idx));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
@ -827,10 +830,15 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
|||||||
case LUA_TNIL:
|
case LUA_TNIL:
|
||||||
lua_pushliteral(L, "nil");
|
lua_pushliteral(L, "nil");
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
|
int tt = luaL_getmetafield(L, idx, "__name"); /* try name */
|
||||||
lua_topointer(L, idx));
|
const char *kind = (tt == LUA_TSTRING) ? lua_tostring(L, -1) :
|
||||||
|
luaL_typename(L, idx);
|
||||||
|
lua_pushfstring(L, "%s: %p", kind, lua_topointer(L, idx));
|
||||||
|
if (tt != LUA_TNIL)
|
||||||
|
lua_remove(L, -2); /* remove '__name' */
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lua_tolstring(L, -1, len);
|
return lua_tolstring(L, -1, len);
|
||||||
@ -882,23 +890,23 @@ static int libsize (const luaL_Reg *l) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Find or create a module table with a given name. The function
|
** Find or create a module table with a given name. The function
|
||||||
** first looks at the _LOADED table and, if that fails, try a
|
** first looks at the LOADED table and, if that fails, try a
|
||||||
** global variable with that name. In any case, leaves on the stack
|
** global variable with that name. In any case, leaves on the stack
|
||||||
** the module table.
|
** the module table.
|
||||||
*/
|
*/
|
||||||
LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
|
LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
|
||||||
int sizehint) {
|
int sizehint) {
|
||||||
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */
|
luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1);
|
||||||
if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no _LOADED[modname]? */
|
if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */
|
||||||
lua_pop(L, 1); /* remove previous result */
|
lua_pop(L, 1); /* remove previous result */
|
||||||
/* try global variable (and create one if it does not exist) */
|
/* try global variable (and create one if it does not exist) */
|
||||||
lua_pushglobaltable(L);
|
lua_pushglobaltable(L);
|
||||||
if (luaL_findtable(L, 0, modname, sizehint) != NULL)
|
if (luaL_findtable(L, 0, modname, sizehint) != NULL)
|
||||||
luaL_error(L, "name conflict for module '%s'", modname);
|
luaL_error(L, "name conflict for module '%s'", modname);
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
|
lua_setfield(L, -3, modname); /* LOADED[modname] = new table */
|
||||||
}
|
}
|
||||||
lua_remove(L, -2); /* remove _LOADED table */
|
lua_remove(L, -2); /* remove LOADED table */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -962,17 +970,17 @@ LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) {
|
|||||||
*/
|
*/
|
||||||
LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
|
LUALIB_API void luaL_requiref (lua_State *L, const char *modname,
|
||||||
lua_CFunction openf, int glb) {
|
lua_CFunction openf, int glb) {
|
||||||
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
|
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
|
||||||
lua_getfield(L, -1, modname); /* _LOADED[modname] */
|
lua_getfield(L, -1, modname); /* LOADED[modname] */
|
||||||
if (!lua_toboolean(L, -1)) { /* package not already loaded? */
|
if (!lua_toboolean(L, -1)) { /* package not already loaded? */
|
||||||
lua_pop(L, 1); /* remove field */
|
lua_pop(L, 1); /* remove field */
|
||||||
lua_pushcfunction(L, openf);
|
lua_pushcfunction(L, openf);
|
||||||
lua_pushstring(L, modname); /* argument to open function */
|
lua_pushstring(L, modname); /* argument to open function */
|
||||||
lua_call(L, 1, 1); /* call 'openf' to open module */
|
lua_call(L, 1, 1); /* call 'openf' to open module */
|
||||||
lua_pushvalue(L, -1); /* make copy of module (call result) */
|
lua_pushvalue(L, -1); /* make copy of module (call result) */
|
||||||
lua_setfield(L, -3, modname); /* _LOADED[modname] = module */
|
lua_setfield(L, -3, modname); /* LOADED[modname] = module */
|
||||||
}
|
}
|
||||||
lua_remove(L, -2); /* remove _LOADED table */
|
lua_remove(L, -2); /* remove LOADED table */
|
||||||
if (glb) {
|
if (glb) {
|
||||||
lua_pushvalue(L, -1); /* copy of module */
|
lua_pushvalue(L, -1); /* copy of module */
|
||||||
lua_setglobal(L, modname); /* _G[modname] = module */
|
lua_setglobal(L, modname); /* _G[modname] = module */
|
||||||
@ -1030,6 +1038,6 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) {
|
|||||||
luaL_error(L, "multiple Lua VMs detected");
|
luaL_error(L, "multiple Lua VMs detected");
|
||||||
else if (*v != ver)
|
else if (*v != ver)
|
||||||
luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
|
luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
|
||||||
ver, *v);
|
(LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
3rdparty/lua/src/lauxlib.h
vendored
12
3rdparty/lua/src/lauxlib.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.129 2015/11/23 11:29:43 roberto Exp $
|
** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -16,10 +16,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* extra error code for 'luaL_load' */
|
/* extra error code for 'luaL_loadfilex' */
|
||||||
#define LUA_ERRFILE (LUA_ERRERR+1)
|
#define LUA_ERRFILE (LUA_ERRERR+1)
|
||||||
|
|
||||||
|
|
||||||
|
/* key, in the registry, for table of loaded modules */
|
||||||
|
#define LUA_LOADED_TABLE "_LOADED"
|
||||||
|
|
||||||
|
|
||||||
|
/* key, in the registry, for table of preloaded loaders */
|
||||||
|
#define LUA_PRELOAD_TABLE "_PRELOAD"
|
||||||
|
|
||||||
|
|
||||||
typedef struct luaL_Reg {
|
typedef struct luaL_Reg {
|
||||||
const char *name;
|
const char *name;
|
||||||
lua_CFunction func;
|
lua_CFunction func;
|
||||||
|
4
3rdparty/lua/src/lbaselib.c
vendored
4
3rdparty/lua/src/lbaselib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.313 2016/04/11 19:18:40 roberto Exp $
|
** $Id: lbaselib.c,v 1.314 2016/09/05 19:06:34 roberto Exp $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -208,8 +208,8 @@ static int luaB_type (lua_State *L) {
|
|||||||
|
|
||||||
static int pairsmeta (lua_State *L, const char *method, int iszero,
|
static int pairsmeta (lua_State *L, const char *method, int iszero,
|
||||||
lua_CFunction iter) {
|
lua_CFunction iter) {
|
||||||
|
luaL_checkany(L, 1);
|
||||||
if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */
|
if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */
|
||||||
luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
|
|
||||||
lua_pushcfunction(L, iter); /* will return generator, */
|
lua_pushcfunction(L, iter); /* will return generator, */
|
||||||
lua_pushvalue(L, 1); /* state, */
|
lua_pushvalue(L, 1); /* state, */
|
||||||
if (iszero) lua_pushinteger(L, 0); /* and initial value */
|
if (iszero) lua_pushinteger(L, 0); /* and initial value */
|
||||||
|
18
3rdparty/lua/src/lcode.c
vendored
18
3rdparty/lua/src/lcode.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lcode.c,v 2.109 2016/05/13 19:09:21 roberto Exp $
|
** $Id: lcode.c,v 2.112 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@
|
|||||||
** If expression is a numeric constant, fills 'v' with its value
|
** If expression is a numeric constant, fills 'v' with its value
|
||||||
** and returns 1. Otherwise, returns 0.
|
** and returns 1. Otherwise, returns 0.
|
||||||
*/
|
*/
|
||||||
static int tonumeral(expdesc *e, TValue *v) {
|
static int tonumeral(const expdesc *e, TValue *v) {
|
||||||
if (hasjumps(e))
|
if (hasjumps(e))
|
||||||
return 0; /* not a numeral */
|
return 0; /* not a numeral */
|
||||||
switch (e->k) {
|
switch (e->k) {
|
||||||
@ -975,7 +975,8 @@ static int validop (int op, TValue *v1, TValue *v2) {
|
|||||||
** Try to "constant-fold" an operation; return 1 iff successful.
|
** Try to "constant-fold" an operation; return 1 iff successful.
|
||||||
** (In this case, 'e1' has the final result.)
|
** (In this case, 'e1' has the final result.)
|
||||||
*/
|
*/
|
||||||
static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) {
|
static int constfolding (FuncState *fs, int op, expdesc *e1,
|
||||||
|
const expdesc *e2) {
|
||||||
TValue v1, v2, res;
|
TValue v1, v2, res;
|
||||||
if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
|
if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
|
||||||
return 0; /* non-numeric operands or not safe to fold */
|
return 0; /* non-numeric operands or not safe to fold */
|
||||||
@ -1014,11 +1015,14 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) {
|
|||||||
** (everything but logical operators 'and'/'or' and comparison
|
** (everything but logical operators 'and'/'or' and comparison
|
||||||
** operators).
|
** operators).
|
||||||
** Expression to produce final result will be encoded in 'e1'.
|
** Expression to produce final result will be encoded in 'e1'.
|
||||||
|
** Because 'luaK_exp2RK' can free registers, its calls must be
|
||||||
|
** in "stack order" (that is, first on 'e2', which may have more
|
||||||
|
** recent registers to be released).
|
||||||
*/
|
*/
|
||||||
static void codebinexpval (FuncState *fs, OpCode op,
|
static void codebinexpval (FuncState *fs, OpCode op,
|
||||||
expdesc *e1, expdesc *e2, int line) {
|
expdesc *e1, expdesc *e2, int line) {
|
||||||
int rk1 = luaK_exp2RK(fs, e1); /* both operands are "RK" */
|
int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
|
||||||
int rk2 = luaK_exp2RK(fs, e2);
|
int rk1 = luaK_exp2RK(fs, e1);
|
||||||
freeexps(fs, e1, e2);
|
freeexps(fs, e1, e2);
|
||||||
e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */
|
e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */
|
||||||
e1->k = VRELOCABLE; /* all those operations are relocatable */
|
e1->k = VRELOCABLE; /* all those operations are relocatable */
|
||||||
@ -1060,9 +1064,9 @@ static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
|
|||||||
** Aplly prefix operation 'op' to expression 'e'.
|
** Aplly prefix operation 'op' to expression 'e'.
|
||||||
*/
|
*/
|
||||||
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) {
|
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) {
|
||||||
static expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; /* fake 2nd operand */
|
static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP};
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OPR_MINUS: case OPR_BNOT:
|
case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */
|
||||||
if (constfolding(fs, op + LUA_OPUNM, e, &ef))
|
if (constfolding(fs, op + LUA_OPUNM, e, &ef))
|
||||||
break;
|
break;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
45
3rdparty/lua/src/ldebug.c
vendored
45
3rdparty/lua/src/ldebug.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldebug.c,v 2.120 2016/03/31 19:01:21 roberto Exp $
|
** $Id: ldebug.c,v 2.121 2016/10/19 12:32:10 roberto Exp $
|
||||||
** Debug Interface
|
** Debug Interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -38,7 +38,8 @@
|
|||||||
#define ci_func(ci) (clLvalue((ci)->func))
|
#define ci_func(ci) (clLvalue((ci)->func))
|
||||||
|
|
||||||
|
|
||||||
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
|
static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
|
||||||
|
const char **name);
|
||||||
|
|
||||||
|
|
||||||
static int currentpc (CallInfo *ci) {
|
static int currentpc (CallInfo *ci) {
|
||||||
@ -244,6 +245,20 @@ static void collectvalidlines (lua_State *L, Closure *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
||||||
|
if (ci == NULL) /* no 'ci'? */
|
||||||
|
return NULL; /* no info */
|
||||||
|
else if (ci->callstatus & CIST_FIN) { /* is this a finalizer? */
|
||||||
|
*name = "__gc";
|
||||||
|
return "metamethod"; /* report it as such */
|
||||||
|
}
|
||||||
|
/* calling function is a known Lua function? */
|
||||||
|
else if (!(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
|
||||||
|
return funcnamefromcode(L, ci->previous, name);
|
||||||
|
else return NULL; /* no way to find a name */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
|
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
|
||||||
Closure *f, CallInfo *ci) {
|
Closure *f, CallInfo *ci) {
|
||||||
int status = 1;
|
int status = 1;
|
||||||
@ -274,11 +289,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'n': {
|
case 'n': {
|
||||||
/* calling function is a known Lua function? */
|
ar->namewhat = getfuncname(L, ci, &ar->name);
|
||||||
if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
|
|
||||||
ar->namewhat = getfuncname(L, ci->previous, &ar->name);
|
|
||||||
else
|
|
||||||
ar->namewhat = NULL;
|
|
||||||
if (ar->namewhat == NULL) {
|
if (ar->namewhat == NULL) {
|
||||||
ar->namewhat = ""; /* not found */
|
ar->namewhat = ""; /* not found */
|
||||||
ar->name = NULL;
|
ar->name = NULL;
|
||||||
@ -471,8 +482,15 @@ static const char *getobjname (Proto *p, int lastpc, int reg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
/*
|
||||||
TMS tm = (TMS)0; /* to avoid warnings */
|
** Try to find a name for a function based on the code that called it.
|
||||||
|
** (Only works when function was called by a Lua function.)
|
||||||
|
** Returns what the name is (e.g., "for iterator", "method",
|
||||||
|
** "metamethod") and sets '*name' to point to the name.
|
||||||
|
*/
|
||||||
|
static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
|
||||||
|
const char **name) {
|
||||||
|
TMS tm = (TMS)0; /* (initial value avoids warnings) */
|
||||||
Proto *p = ci_func(ci)->p; /* calling function */
|
Proto *p = ci_func(ci)->p; /* calling function */
|
||||||
int pc = currentpc(ci); /* calling instruction index */
|
int pc = currentpc(ci); /* calling instruction index */
|
||||||
Instruction i = p->code[pc]; /* calling instruction */
|
Instruction i = p->code[pc]; /* calling instruction */
|
||||||
@ -482,13 +500,13 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
|||||||
}
|
}
|
||||||
switch (GET_OPCODE(i)) {
|
switch (GET_OPCODE(i)) {
|
||||||
case OP_CALL:
|
case OP_CALL:
|
||||||
case OP_TAILCALL: /* get function name */
|
case OP_TAILCALL:
|
||||||
return getobjname(p, pc, GETARG_A(i), name);
|
return getobjname(p, pc, GETARG_A(i), name); /* get function name */
|
||||||
case OP_TFORCALL: { /* for iterator */
|
case OP_TFORCALL: { /* for iterator */
|
||||||
*name = "for iterator";
|
*name = "for iterator";
|
||||||
return "for iterator";
|
return "for iterator";
|
||||||
}
|
}
|
||||||
/* all other instructions can call only through metamethods */
|
/* other instructions can do calls through metamethods */
|
||||||
case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
|
case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
|
||||||
tm = TM_INDEX;
|
tm = TM_INDEX;
|
||||||
break;
|
break;
|
||||||
@ -509,7 +527,8 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
|||||||
case OP_EQ: tm = TM_EQ; break;
|
case OP_EQ: tm = TM_EQ; break;
|
||||||
case OP_LT: tm = TM_LT; break;
|
case OP_LT: tm = TM_LT; break;
|
||||||
case OP_LE: tm = TM_LE; break;
|
case OP_LE: tm = TM_LE; break;
|
||||||
default: lua_assert(0); /* other instructions cannot call a function */
|
default:
|
||||||
|
return NULL; /* cannot find a reasonable name */
|
||||||
}
|
}
|
||||||
*name = getstr(G(L)->tmname[tm]);
|
*name = getstr(G(L)->tmname[tm]);
|
||||||
return "metamethod";
|
return "metamethod";
|
||||||
|
226
3rdparty/lua/src/ldo.c
vendored
226
3rdparty/lua/src/ldo.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 2.151 2015/12/16 16:40:07 roberto Exp $
|
** $Id: ldo.c,v 2.157 2016/12/13 15:52:21 roberto Exp $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -211,9 +211,9 @@ static int stackinuse (lua_State *L) {
|
|||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
StkId lim = L->top;
|
StkId lim = L->top;
|
||||||
for (ci = L->ci; ci != NULL; ci = ci->previous) {
|
for (ci = L->ci; ci != NULL; ci = ci->previous) {
|
||||||
lua_assert(ci->top <= L->stack_last);
|
|
||||||
if (lim < ci->top) lim = ci->top;
|
if (lim < ci->top) lim = ci->top;
|
||||||
}
|
}
|
||||||
|
lua_assert(lim <= L->stack_last);
|
||||||
return cast_int(lim - L->stack) + 1; /* part of stack in use */
|
return cast_int(lim - L->stack) + 1; /* part of stack in use */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,16 +221,19 @@ static int stackinuse (lua_State *L) {
|
|||||||
void luaD_shrinkstack (lua_State *L) {
|
void luaD_shrinkstack (lua_State *L) {
|
||||||
int inuse = stackinuse(L);
|
int inuse = stackinuse(L);
|
||||||
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
|
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
|
||||||
if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK;
|
if (goodsize > LUAI_MAXSTACK)
|
||||||
if (L->stacksize > LUAI_MAXSTACK) /* was handling stack overflow? */
|
goodsize = LUAI_MAXSTACK; /* respect stack limit */
|
||||||
|
if (L->stacksize > LUAI_MAXSTACK) /* had been handling stack overflow? */
|
||||||
luaE_freeCI(L); /* free all CIs (list grew because of an error) */
|
luaE_freeCI(L); /* free all CIs (list grew because of an error) */
|
||||||
else
|
else
|
||||||
luaE_shrinkCI(L); /* shrink list */
|
luaE_shrinkCI(L); /* shrink list */
|
||||||
if (inuse <= LUAI_MAXSTACK && /* not handling stack overflow? */
|
/* if thread is currently not handling a stack overflow and its
|
||||||
goodsize < L->stacksize) /* trying to shrink? */
|
good size is smaller than current size, shrink its stack */
|
||||||
luaD_reallocstack(L, goodsize); /* shrink it */
|
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
|
||||||
else
|
goodsize < L->stacksize)
|
||||||
condmovestack(L,,); /* don't change stack (change only for debugging) */
|
luaD_reallocstack(L, goodsize);
|
||||||
|
else /* don't change stack */
|
||||||
|
condmovestack(L,{},{}); /* (change only for debugging) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,86 +325,6 @@ static void tryfuncTM (lua_State *L, StkId func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L)))
|
|
||||||
|
|
||||||
|
|
||||||
/* macro to check stack size, preserving 'p' */
|
|
||||||
#define checkstackp(L,n,p) \
|
|
||||||
luaD_checkstackaux(L, n, \
|
|
||||||
ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
|
|
||||||
luaC_checkGC(L), /* stack grow uses memory */ \
|
|
||||||
p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Prepares a function call: checks the stack, creates a new CallInfo
|
|
||||||
** entry, fills in the relevant information, calls hook if needed.
|
|
||||||
** If function is a C function, does the call, too. (Otherwise, leave
|
|
||||||
** the execution ('luaV_execute') to the caller, to allow stackless
|
|
||||||
** calls.) Returns true iff function has been executed (C function).
|
|
||||||
*/
|
|
||||||
int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|
||||||
lua_CFunction f;
|
|
||||||
CallInfo *ci;
|
|
||||||
switch (ttype(func)) {
|
|
||||||
case LUA_TCCL: /* C closure */
|
|
||||||
f = clCvalue(func)->f;
|
|
||||||
goto Cfunc;
|
|
||||||
case LUA_TLCF: /* light C function */
|
|
||||||
f = fvalue(func);
|
|
||||||
Cfunc: {
|
|
||||||
int n; /* number of returns */
|
|
||||||
checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
|
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
|
||||||
ci->nresults = nresults;
|
|
||||||
ci->func = func;
|
|
||||||
ci->top = L->top + LUA_MINSTACK;
|
|
||||||
lua_assert(ci->top <= L->stack_last);
|
|
||||||
ci->callstatus = 0;
|
|
||||||
if (L->hookmask & LUA_MASKCALL)
|
|
||||||
luaD_hook(L, LUA_HOOKCALL, -1);
|
|
||||||
lua_unlock(L);
|
|
||||||
n = (*f)(L); /* do the actual call */
|
|
||||||
lua_lock(L);
|
|
||||||
api_checknelems(L, n);
|
|
||||||
luaD_poscall(L, ci, L->top - n, n);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
case LUA_TLCL: { /* Lua function: prepare its call */
|
|
||||||
StkId base;
|
|
||||||
Proto *p = clLvalue(func)->p;
|
|
||||||
int n = cast_int(L->top - func) - 1; /* number of real arguments */
|
|
||||||
int fsize = p->maxstacksize; /* frame size */
|
|
||||||
checkstackp(L, fsize, func);
|
|
||||||
if (p->is_vararg != 1) { /* do not use vararg? */
|
|
||||||
for (; n < p->numparams; n++)
|
|
||||||
setnilvalue(L->top++); /* complete missing arguments */
|
|
||||||
base = func + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
base = adjust_varargs(L, p, n);
|
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
|
||||||
ci->nresults = nresults;
|
|
||||||
ci->func = func;
|
|
||||||
ci->u.l.base = base;
|
|
||||||
L->top = ci->top = base + fsize;
|
|
||||||
lua_assert(ci->top <= L->stack_last);
|
|
||||||
ci->u.l.savedpc = p->code; /* starting point */
|
|
||||||
ci->callstatus = CIST_LUA;
|
|
||||||
if (L->hookmask & LUA_MASKCALL)
|
|
||||||
callhook(L, ci);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
default: { /* not a function */
|
|
||||||
checkstackp(L, 1, func); /* ensure space for metamethod */
|
|
||||||
tryfuncTM(L, func); /* try to get '__call' metamethod */
|
|
||||||
return luaD_precall(L, func, nresults); /* now it must be a function */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'.
|
** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'.
|
||||||
** Handle most typical cases (zero results for commands, one result for
|
** Handle most typical cases (zero results for commands, one result for
|
||||||
@ -468,6 +391,86 @@ int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L)))
|
||||||
|
|
||||||
|
|
||||||
|
/* macro to check stack size, preserving 'p' */
|
||||||
|
#define checkstackp(L,n,p) \
|
||||||
|
luaD_checkstackaux(L, n, \
|
||||||
|
ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
|
||||||
|
luaC_checkGC(L), /* stack grow uses memory */ \
|
||||||
|
p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Prepares a function call: checks the stack, creates a new CallInfo
|
||||||
|
** entry, fills in the relevant information, calls hook if needed.
|
||||||
|
** If function is a C function, does the call, too. (Otherwise, leave
|
||||||
|
** the execution ('luaV_execute') to the caller, to allow stackless
|
||||||
|
** calls.) Returns true iff function has been executed (C function).
|
||||||
|
*/
|
||||||
|
int luaD_precall (lua_State *L, StkId func, int nresults) {
|
||||||
|
lua_CFunction f;
|
||||||
|
CallInfo *ci;
|
||||||
|
switch (ttype(func)) {
|
||||||
|
case LUA_TCCL: /* C closure */
|
||||||
|
f = clCvalue(func)->f;
|
||||||
|
goto Cfunc;
|
||||||
|
case LUA_TLCF: /* light C function */
|
||||||
|
f = fvalue(func);
|
||||||
|
Cfunc: {
|
||||||
|
int n; /* number of returns */
|
||||||
|
checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
|
||||||
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
|
ci->nresults = nresults;
|
||||||
|
ci->func = func;
|
||||||
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
|
lua_assert(ci->top <= L->stack_last);
|
||||||
|
ci->callstatus = 0;
|
||||||
|
if (L->hookmask & LUA_MASKCALL)
|
||||||
|
luaD_hook(L, LUA_HOOKCALL, -1);
|
||||||
|
lua_unlock(L);
|
||||||
|
n = (*f)(L); /* do the actual call */
|
||||||
|
lua_lock(L);
|
||||||
|
api_checknelems(L, n);
|
||||||
|
luaD_poscall(L, ci, L->top - n, n);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case LUA_TLCL: { /* Lua function: prepare its call */
|
||||||
|
StkId base;
|
||||||
|
Proto *p = clLvalue(func)->p;
|
||||||
|
int n = cast_int(L->top - func) - 1; /* number of real arguments */
|
||||||
|
int fsize = p->maxstacksize; /* frame size */
|
||||||
|
checkstackp(L, fsize, func);
|
||||||
|
if (p->is_vararg)
|
||||||
|
base = adjust_varargs(L, p, n);
|
||||||
|
else { /* non vararg function */
|
||||||
|
for (; n < p->numparams; n++)
|
||||||
|
setnilvalue(L->top++); /* complete missing arguments */
|
||||||
|
base = func + 1;
|
||||||
|
}
|
||||||
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
|
ci->nresults = nresults;
|
||||||
|
ci->func = func;
|
||||||
|
ci->u.l.base = base;
|
||||||
|
L->top = ci->top = base + fsize;
|
||||||
|
lua_assert(ci->top <= L->stack_last);
|
||||||
|
ci->u.l.savedpc = p->code; /* starting point */
|
||||||
|
ci->callstatus = CIST_LUA;
|
||||||
|
if (L->hookmask & LUA_MASKCALL)
|
||||||
|
callhook(L, ci);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
default: { /* not a function */
|
||||||
|
checkstackp(L, 1, func); /* ensure space for metamethod */
|
||||||
|
tryfuncTM(L, func); /* try to get '__call' metamethod */
|
||||||
|
return luaD_precall(L, func, nresults); /* now it must be a function */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Check appropriate error for stack overflow ("regular" overflow or
|
** Check appropriate error for stack overflow ("regular" overflow or
|
||||||
** overflow while handling stack overflow). If 'nCalls' is larger than
|
** overflow while handling stack overflow). If 'nCalls' is larger than
|
||||||
@ -520,19 +523,17 @@ static void finishCcall (lua_State *L, int status) {
|
|||||||
/* error status can only happen in a protected call */
|
/* error status can only happen in a protected call */
|
||||||
lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD);
|
lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD);
|
||||||
if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */
|
if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */
|
||||||
ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */
|
ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */
|
||||||
L->errfunc = ci->u.c.old_errfunc;
|
L->errfunc = ci->u.c.old_errfunc; /* with the same error function */
|
||||||
}
|
}
|
||||||
/* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already
|
/* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already
|
||||||
handled */
|
handled */
|
||||||
adjustresults(L, ci->nresults);
|
adjustresults(L, ci->nresults);
|
||||||
/* call continuation function */
|
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
n = (*ci->u.c.k)(L, status, ci->u.c.ctx);
|
n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, n);
|
api_checknelems(L, n);
|
||||||
/* finish 'luaD_precall' */
|
luaD_poscall(L, ci, L->top - n, n); /* finish 'luaD_precall' */
|
||||||
luaD_poscall(L, ci, L->top - n, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -595,15 +596,16 @@ static int recover (lua_State *L, int status) {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** signal an error in the call to 'resume', not in the execution of the
|
** Signal an error in the call to 'lua_resume', not in the execution
|
||||||
** coroutine itself. (Such errors should not be handled by any coroutine
|
** of the coroutine itself. (Such errors should not be handled by any
|
||||||
** error handler and should not kill the coroutine.)
|
** coroutine error handler and should not kill the coroutine.)
|
||||||
*/
|
*/
|
||||||
static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) {
|
static int resume_error (lua_State *L, const char *msg, int narg) {
|
||||||
L->top = firstArg; /* remove args from the stack */
|
L->top -= narg; /* remove args from the stack */
|
||||||
setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */
|
setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
luaD_throw(L, -1); /* jump back to 'lua_resume' */
|
lua_unlock(L);
|
||||||
|
return LUA_ERRRUN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -615,22 +617,15 @@ static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) {
|
|||||||
** coroutine.
|
** coroutine.
|
||||||
*/
|
*/
|
||||||
static void resume (lua_State *L, void *ud) {
|
static void resume (lua_State *L, void *ud) {
|
||||||
int nCcalls = L->nCcalls;
|
|
||||||
int n = *(cast(int*, ud)); /* number of arguments */
|
int n = *(cast(int*, ud)); /* number of arguments */
|
||||||
StkId firstArg = L->top - n; /* first argument */
|
StkId firstArg = L->top - n; /* first argument */
|
||||||
CallInfo *ci = L->ci;
|
CallInfo *ci = L->ci;
|
||||||
if (nCcalls >= LUAI_MAXCCALLS)
|
if (L->status == LUA_OK) { /* starting a coroutine? */
|
||||||
resume_error(L, "C stack overflow", firstArg);
|
|
||||||
if (L->status == LUA_OK) { /* may be starting a coroutine */
|
|
||||||
if (ci != &L->base_ci) /* not in base level? */
|
|
||||||
resume_error(L, "cannot resume non-suspended coroutine", firstArg);
|
|
||||||
/* coroutine is in base level; start running it */
|
|
||||||
if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */
|
if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */
|
||||||
luaV_execute(L); /* call it */
|
luaV_execute(L); /* call it */
|
||||||
}
|
}
|
||||||
else if (L->status != LUA_YIELD)
|
|
||||||
resume_error(L, "cannot resume dead coroutine", firstArg);
|
|
||||||
else { /* resuming from previous yield */
|
else { /* resuming from previous yield */
|
||||||
|
lua_assert(L->status == LUA_YIELD);
|
||||||
L->status = LUA_OK; /* mark that it is running (again) */
|
L->status = LUA_OK; /* mark that it is running (again) */
|
||||||
ci->func = restorestack(L, ci->extra);
|
ci->func = restorestack(L, ci->extra);
|
||||||
if (isLua(ci)) /* yielded inside a hook? */
|
if (isLua(ci)) /* yielded inside a hook? */
|
||||||
@ -647,7 +642,6 @@ static void resume (lua_State *L, void *ud) {
|
|||||||
}
|
}
|
||||||
unroll(L, NULL); /* run continuation */
|
unroll(L, NULL); /* run continuation */
|
||||||
}
|
}
|
||||||
lua_assert(nCcalls == L->nCcalls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -655,8 +649,16 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) {
|
|||||||
int status;
|
int status;
|
||||||
unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */
|
unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luai_userstateresume(L, nargs);
|
if (L->status == LUA_OK) { /* may be starting a coroutine */
|
||||||
|
if (L->ci != &L->base_ci) /* not in base level? */
|
||||||
|
return resume_error(L, "cannot resume non-suspended coroutine", nargs);
|
||||||
|
}
|
||||||
|
else if (L->status != LUA_YIELD)
|
||||||
|
return resume_error(L, "cannot resume dead coroutine", nargs);
|
||||||
L->nCcalls = (from) ? from->nCcalls + 1 : 1;
|
L->nCcalls = (from) ? from->nCcalls + 1 : 1;
|
||||||
|
if (L->nCcalls >= LUAI_MAXCCALLS)
|
||||||
|
return resume_error(L, "C stack overflow", nargs);
|
||||||
|
luai_userstateresume(L, nargs);
|
||||||
L->nny = 0; /* allow yields */
|
L->nny = 0; /* allow yields */
|
||||||
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
|
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
|
||||||
status = luaD_rawrunprotected(L, resume, &nargs);
|
status = luaD_rawrunprotected(L, resume, &nargs);
|
||||||
|
6
3rdparty/lua/src/lgc.c
vendored
6
3rdparty/lua/src/lgc.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 2.212 2016/03/31 19:02:03 roberto Exp $
|
** $Id: lgc.c,v 2.215 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -467,7 +467,7 @@ static lu_mem traversetable (global_State *g, Table *h) {
|
|||||||
else /* not weak */
|
else /* not weak */
|
||||||
traversestrongtable(g, h);
|
traversestrongtable(g, h);
|
||||||
return sizeof(Table) + sizeof(TValue) * h->sizearray +
|
return sizeof(Table) + sizeof(TValue) * h->sizearray +
|
||||||
sizeof(Node) * cast(size_t, sizenode(h));
|
sizeof(Node) * cast(size_t, allocsizenode(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -818,7 +818,9 @@ static void GCTM (lua_State *L, int propagateerrors) {
|
|||||||
setobj2s(L, L->top, tm); /* push finalizer... */
|
setobj2s(L, L->top, tm); /* push finalizer... */
|
||||||
setobj2s(L, L->top + 1, &v); /* ... and its argument */
|
setobj2s(L, L->top + 1, &v); /* ... and its argument */
|
||||||
L->top += 2; /* and (next line) call the finalizer */
|
L->top += 2; /* and (next line) call the finalizer */
|
||||||
|
L->ci->callstatus |= CIST_FIN; /* will run a finalizer */
|
||||||
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
|
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
|
||||||
|
L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */
|
||||||
L->allowhook = oldah; /* restore hooks */
|
L->allowhook = oldah; /* restore hooks */
|
||||||
g->gcrunning = running; /* restore state */
|
g->gcrunning = running; /* restore state */
|
||||||
if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
|
if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
|
||||||
|
6
3rdparty/lua/src/linit.c
vendored
6
3rdparty/lua/src/linit.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $
|
** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $
|
||||||
** Initialization of libraries for lua.c and other clients
|
** Initialization of libraries for lua.c and other clients
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -18,10 +18,10 @@
|
|||||||
** open the library, which is already linked to the application.
|
** open the library, which is already linked to the application.
|
||||||
** For that, do the following code:
|
** For that, do the following code:
|
||||||
**
|
**
|
||||||
** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
|
** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
|
||||||
** lua_pushcfunction(L, luaopen_modname);
|
** lua_pushcfunction(L, luaopen_modname);
|
||||||
** lua_setfield(L, -2, modname);
|
** lua_setfield(L, -2, modname);
|
||||||
** lua_pop(L, 1); // remove _PRELOAD table
|
** lua_pop(L, 1); // remove PRELOAD table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lprefix.h"
|
#include "lprefix.h"
|
||||||
|
17
3rdparty/lua/src/liolib.c
vendored
17
3rdparty/lua/src/liolib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 2.149 2016/05/02 14:03:19 roberto Exp $
|
** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -37,10 +37,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */
|
/* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */
|
||||||
#define l_checkmode(mode) \
|
static int l_checkmode (const char *mode) {
|
||||||
(*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \
|
return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL &&
|
||||||
(*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ \
|
(*mode != '+' || (++mode, 1)) && /* skip if char is '+' */
|
||||||
(strspn(mode, L_MODEEXT) == strlen(mode)))
|
(strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -618,8 +619,10 @@ static int g_write (lua_State *L, FILE *f, int arg) {
|
|||||||
if (lua_type(L, arg) == LUA_TNUMBER) {
|
if (lua_type(L, arg) == LUA_TNUMBER) {
|
||||||
/* optimization: could be done exactly as for strings */
|
/* optimization: could be done exactly as for strings */
|
||||||
int len = lua_isinteger(L, arg)
|
int len = lua_isinteger(L, arg)
|
||||||
? fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg))
|
? fprintf(f, LUA_INTEGER_FMT,
|
||||||
: fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg));
|
(LUAI_UACINT)lua_tointeger(L, arg))
|
||||||
|
: fprintf(f, LUA_NUMBER_FMT,
|
||||||
|
(LUAI_UACNUMBER)lua_tonumber(L, arg));
|
||||||
status = status && (len > 0);
|
status = status && (len > 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
11
3rdparty/lua/src/lmathlib.c
vendored
11
3rdparty/lua/src/lmathlib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.117 2015/10/02 15:39:23 roberto Exp $
|
** $Id: lmathlib.c,v 1.119 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -184,10 +184,13 @@ static int math_log (lua_State *L) {
|
|||||||
else {
|
else {
|
||||||
lua_Number base = luaL_checknumber(L, 2);
|
lua_Number base = luaL_checknumber(L, 2);
|
||||||
#if !defined(LUA_USE_C89)
|
#if !defined(LUA_USE_C89)
|
||||||
if (base == 2.0) res = l_mathop(log2)(x); else
|
if (base == l_mathop(2.0))
|
||||||
|
res = l_mathop(log2)(x); else
|
||||||
#endif
|
#endif
|
||||||
if (base == 10.0) res = l_mathop(log10)(x);
|
if (base == l_mathop(10.0))
|
||||||
else res = l_mathop(log)(x)/l_mathop(log)(base);
|
res = l_mathop(log10)(x);
|
||||||
|
else
|
||||||
|
res = l_mathop(log)(x)/l_mathop(log)(base);
|
||||||
}
|
}
|
||||||
lua_pushnumber(L, res);
|
lua_pushnumber(L, res);
|
||||||
return 1;
|
return 1;
|
||||||
|
169
3rdparty/lua/src/loadlib.c
vendored
169
3rdparty/lua/src/loadlib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loadlib.c,v 1.127 2015/11/23 11:30:45 roberto Exp $
|
** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 roberto Exp $
|
||||||
** Dynamic library loader for Lua
|
** Dynamic library loader for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
**
|
**
|
||||||
@ -25,40 +25,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment
|
|
||||||
** variables that Lua check to set its paths.
|
|
||||||
*/
|
|
||||||
#if !defined(LUA_PATH_VAR)
|
|
||||||
#define LUA_PATH_VAR "LUA_PATH"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(LUA_CPATH_VAR)
|
|
||||||
#define LUA_CPATH_VAR "LUA_CPATH"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
|
|
||||||
|
|
||||||
#define LUA_PATHVARVERSION LUA_PATH_VAR LUA_PATHSUFFIX
|
|
||||||
#define LUA_CPATHVARVERSION LUA_CPATH_VAR LUA_PATHSUFFIX
|
|
||||||
|
|
||||||
/*
|
|
||||||
** LUA_PATH_SEP is the character that separates templates in a path.
|
|
||||||
** LUA_PATH_MARK is the string that marks the substitution points in a
|
|
||||||
** template.
|
|
||||||
** LUA_EXEC_DIR in a Windows path is replaced by the executable's
|
|
||||||
** directory.
|
|
||||||
** LUA_IGMARK is a mark to ignore all before it when building the
|
** LUA_IGMARK is a mark to ignore all before it when building the
|
||||||
** luaopen_ function name.
|
** luaopen_ function name.
|
||||||
*/
|
*/
|
||||||
#if !defined (LUA_PATH_SEP)
|
|
||||||
#define LUA_PATH_SEP ";"
|
|
||||||
#endif
|
|
||||||
#if !defined (LUA_PATH_MARK)
|
|
||||||
#define LUA_PATH_MARK "?"
|
|
||||||
#endif
|
|
||||||
#if !defined (LUA_EXEC_DIR)
|
|
||||||
#define LUA_EXEC_DIR "!"
|
|
||||||
#endif
|
|
||||||
#if !defined (LUA_IGMARK)
|
#if !defined (LUA_IGMARK)
|
||||||
#define LUA_IGMARK "-"
|
#define LUA_IGMARK "-"
|
||||||
#endif
|
#endif
|
||||||
@ -94,7 +63,8 @@ static const int CLIBS = 0;
|
|||||||
|
|
||||||
#define LIB_FAIL "open"
|
#define LIB_FAIL "open"
|
||||||
|
|
||||||
#define setprogdir(L) ((void)0)
|
|
||||||
|
#define setprogdir(L) ((void)0)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -179,7 +149,6 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#undef setprogdir
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** optional flags for LoadLibraryEx
|
** optional flags for LoadLibraryEx
|
||||||
@ -189,21 +158,30 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#undef setprogdir
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Replace in the path (on the top of the stack) any occurrence
|
||||||
|
** of LUA_EXEC_DIR with the executable's path.
|
||||||
|
*/
|
||||||
static void setprogdir (lua_State *L) {
|
static void setprogdir (lua_State *L) {
|
||||||
char buff[MAX_PATH + 1];
|
char buff[MAX_PATH + 1];
|
||||||
char *lb;
|
char *lb;
|
||||||
DWORD nsize = sizeof(buff)/sizeof(char);
|
DWORD nsize = sizeof(buff)/sizeof(char);
|
||||||
DWORD n = GetModuleFileNameA(NULL, buff, nsize);
|
DWORD n = GetModuleFileNameA(NULL, buff, nsize); /* get exec. name */
|
||||||
if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
|
if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
|
||||||
luaL_error(L, "unable to get ModuleFileName");
|
luaL_error(L, "unable to get ModuleFileName");
|
||||||
else {
|
else {
|
||||||
*lb = '\0';
|
*lb = '\0'; /* cut name on the last '\\' to get the path */
|
||||||
luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
|
luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
|
||||||
lua_remove(L, -2); /* remove original string */
|
lua_remove(L, -2); /* remove original string */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void pusherror (lua_State *L) {
|
static void pusherror (lua_State *L) {
|
||||||
int error = GetLastError();
|
int error = GetLastError();
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
@ -272,6 +250,67 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
|
|||||||
#endif /* } */
|
#endif /* } */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** {==================================================================
|
||||||
|
** Set Paths
|
||||||
|
** ===================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment
|
||||||
|
** variables that Lua check to set its paths.
|
||||||
|
*/
|
||||||
|
#if !defined(LUA_PATH_VAR)
|
||||||
|
#define LUA_PATH_VAR "LUA_PATH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LUA_CPATH_VAR)
|
||||||
|
#define LUA_CPATH_VAR "LUA_CPATH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define AUXMARK "\1" /* auxiliary mark */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** return registry.LUA_NOENV as a boolean
|
||||||
|
*/
|
||||||
|
static int noenv (lua_State *L) {
|
||||||
|
int b;
|
||||||
|
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
|
||||||
|
b = lua_toboolean(L, -1);
|
||||||
|
lua_pop(L, 1); /* remove value */
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Set a path
|
||||||
|
*/
|
||||||
|
static void setpath (lua_State *L, const char *fieldname,
|
||||||
|
const char *envname,
|
||||||
|
const char *dft) {
|
||||||
|
const char *nver = lua_pushfstring(L, "%s%s", envname, LUA_VERSUFFIX);
|
||||||
|
const char *path = getenv(nver); /* use versioned name */
|
||||||
|
if (path == NULL) /* no environment variable? */
|
||||||
|
path = getenv(envname); /* try unversioned name */
|
||||||
|
if (path == NULL || noenv(L)) /* no environment variable? */
|
||||||
|
lua_pushstring(L, dft); /* use default */
|
||||||
|
else {
|
||||||
|
/* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
|
||||||
|
path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
|
||||||
|
LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
|
||||||
|
luaL_gsub(L, path, AUXMARK, dft);
|
||||||
|
lua_remove(L, -2); /* remove result from 1st 'gsub' */
|
||||||
|
}
|
||||||
|
setprogdir(L);
|
||||||
|
lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */
|
||||||
|
lua_pop(L, 1); /* pop versioned variable name */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* }================================================================== */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** return registry.CLIBS[path]
|
** return registry.CLIBS[path]
|
||||||
*/
|
*/
|
||||||
@ -520,7 +559,7 @@ static int searcher_Croot (lua_State *L) {
|
|||||||
|
|
||||||
static int searcher_preload (lua_State *L) {
|
static int searcher_preload (lua_State *L) {
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD");
|
lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
|
||||||
if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */
|
if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */
|
||||||
lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
|
lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
|
||||||
return 1;
|
return 1;
|
||||||
@ -557,9 +596,9 @@ static void findloader (lua_State *L, const char *name) {
|
|||||||
|
|
||||||
static int ll_require (lua_State *L) {
|
static int ll_require (lua_State *L) {
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
lua_settop(L, 1); /* _LOADED table will be at index 2 */
|
lua_settop(L, 1); /* LOADED table will be at index 2 */
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
|
||||||
lua_getfield(L, 2, name); /* _LOADED[name] */
|
lua_getfield(L, 2, name); /* LOADED[name] */
|
||||||
if (lua_toboolean(L, -1)) /* is it there? */
|
if (lua_toboolean(L, -1)) /* is it there? */
|
||||||
return 1; /* package is already loaded */
|
return 1; /* package is already loaded */
|
||||||
/* else must load package */
|
/* else must load package */
|
||||||
@ -569,11 +608,11 @@ static int ll_require (lua_State *L) {
|
|||||||
lua_insert(L, -2); /* name is 1st argument (before search data) */
|
lua_insert(L, -2); /* name is 1st argument (before search data) */
|
||||||
lua_call(L, 2, 1); /* run loader to load module */
|
lua_call(L, 2, 1); /* run loader to load module */
|
||||||
if (!lua_isnil(L, -1)) /* non-nil return? */
|
if (!lua_isnil(L, -1)) /* non-nil return? */
|
||||||
lua_setfield(L, 2, name); /* _LOADED[name] = returned value */
|
lua_setfield(L, 2, name); /* LOADED[name] = returned value */
|
||||||
if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */
|
if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */
|
||||||
lua_pushboolean(L, 1); /* use true as result */
|
lua_pushboolean(L, 1); /* use true as result */
|
||||||
lua_pushvalue(L, -1); /* extra copy to be returned */
|
lua_pushvalue(L, -1); /* extra copy to be returned */
|
||||||
lua_setfield(L, 2, name); /* _LOADED[name] = true */
|
lua_setfield(L, 2, name); /* LOADED[name] = true */
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -666,41 +705,6 @@ static int ll_seeall (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* auxiliary mark (for internal use) */
|
|
||||||
#define AUXMARK "\1"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** return registry.LUA_NOENV as a boolean
|
|
||||||
*/
|
|
||||||
static int noenv (lua_State *L) {
|
|
||||||
int b;
|
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
|
|
||||||
b = lua_toboolean(L, -1);
|
|
||||||
lua_pop(L, 1); /* remove value */
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void setpath (lua_State *L, const char *fieldname, const char *envname1,
|
|
||||||
const char *envname2, const char *def) {
|
|
||||||
const char *path = getenv(envname1);
|
|
||||||
if (path == NULL) /* no environment variable? */
|
|
||||||
path = getenv(envname2); /* try alternative name */
|
|
||||||
if (path == NULL || noenv(L)) /* no environment variable? */
|
|
||||||
lua_pushstring(L, def); /* use default */
|
|
||||||
else {
|
|
||||||
/* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
|
|
||||||
path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
|
|
||||||
LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
|
|
||||||
luaL_gsub(L, path, AUXMARK, def);
|
|
||||||
lua_remove(L, -2);
|
|
||||||
}
|
|
||||||
setprogdir(L);
|
|
||||||
lua_setfield(L, -2, fieldname);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const luaL_Reg pk_funcs[] = {
|
static const luaL_Reg pk_funcs[] = {
|
||||||
{"loadlib", ll_loadlib},
|
{"loadlib", ll_loadlib},
|
||||||
{"searchpath", ll_searchpath},
|
{"searchpath", ll_searchpath},
|
||||||
@ -764,19 +768,18 @@ LUAMOD_API int luaopen_package (lua_State *L) {
|
|||||||
createclibstable(L);
|
createclibstable(L);
|
||||||
luaL_newlib(L, pk_funcs); /* create 'package' table */
|
luaL_newlib(L, pk_funcs); /* create 'package' table */
|
||||||
createsearcherstable(L);
|
createsearcherstable(L);
|
||||||
/* set field 'path' */
|
/* set paths */
|
||||||
setpath(L, "path", LUA_PATHVARVERSION, LUA_PATH_VAR, LUA_PATH_DEFAULT);
|
setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
|
||||||
/* set field 'cpath' */
|
setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
|
||||||
setpath(L, "cpath", LUA_CPATHVARVERSION, LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
|
|
||||||
/* store config information */
|
/* store config information */
|
||||||
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
|
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
|
||||||
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
|
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
|
||||||
lua_setfield(L, -2, "config");
|
lua_setfield(L, -2, "config");
|
||||||
/* set field 'loaded' */
|
/* set field 'loaded' */
|
||||||
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
|
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
|
||||||
lua_setfield(L, -2, "loaded");
|
lua_setfield(L, -2, "loaded");
|
||||||
/* set field 'preload' */
|
/* set field 'preload' */
|
||||||
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
|
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
|
||||||
lua_setfield(L, -2, "preload");
|
lua_setfield(L, -2, "preload");
|
||||||
lua_pushglobaltable(L);
|
lua_pushglobaltable(L);
|
||||||
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
|
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
|
||||||
|
4
3rdparty/lua/src/lobject.c
vendored
4
3rdparty/lua/src/lobject.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 2.111 2016/05/20 14:07:48 roberto Exp $
|
** $Id: lobject.c,v 2.113 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Some generic functions over Lua objects
|
** Some generic functions over Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -280,7 +280,7 @@ static const char *l_str2d (const char *s, lua_Number *result) {
|
|||||||
endptr = l_str2dloc(s, result, mode); /* try to convert */
|
endptr = l_str2dloc(s, result, mode); /* try to convert */
|
||||||
if (endptr == NULL) { /* failed? may be a different locale */
|
if (endptr == NULL) { /* failed? may be a different locale */
|
||||||
char buff[L_MAXLENNUM + 1];
|
char buff[L_MAXLENNUM + 1];
|
||||||
char *pdot = strchr(s, '.');
|
const char *pdot = strchr(s, '.');
|
||||||
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
|
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
|
||||||
return NULL; /* string too long or no dot; fail */
|
return NULL; /* string too long or no dot; fail */
|
||||||
strcpy(buff, s); /* copy string to buffer */
|
strcpy(buff, s); /* copy string to buffer */
|
||||||
|
4
3rdparty/lua/src/lobject.h
vendored
4
3rdparty/lua/src/lobject.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 2.116 2015/11/03 18:33:10 roberto Exp $
|
** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -407,7 +407,7 @@ typedef struct LocVar {
|
|||||||
typedef struct Proto {
|
typedef struct Proto {
|
||||||
CommonHeader;
|
CommonHeader;
|
||||||
lu_byte numparams; /* number of fixed parameters */
|
lu_byte numparams; /* number of fixed parameters */
|
||||||
lu_byte is_vararg; /* 2: declared vararg; 1: uses vararg */
|
lu_byte is_vararg;
|
||||||
lu_byte maxstacksize; /* number of registers needed by this function */
|
lu_byte maxstacksize; /* number of registers needed by this function */
|
||||||
int sizeupvalues; /* size of 'upvalues' */
|
int sizeupvalues; /* size of 'upvalues' */
|
||||||
int sizek; /* size of 'k' */
|
int sizek; /* size of 'k' */
|
||||||
|
4
3rdparty/lua/src/lopcodes.h
vendored
4
3rdparty/lua/src/lopcodes.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.148 2014/10/25 11:50:46 roberto Exp $
|
** $Id: lopcodes.h,v 1.149 2016/07/19 17:12:21 roberto Exp $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -139,7 +139,9 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
|
|||||||
/* gets the index of the constant */
|
/* gets the index of the constant */
|
||||||
#define INDEXK(r) ((int)(r) & ~BITRK)
|
#define INDEXK(r) ((int)(r) & ~BITRK)
|
||||||
|
|
||||||
|
#if !defined(MAXINDEXRK) /* (for debugging only) */
|
||||||
#define MAXINDEXRK (BITRK - 1)
|
#define MAXINDEXRK (BITRK - 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* code a constant index as a RK value */
|
/* code a constant index as a RK value */
|
||||||
#define RKASK(x) ((x) | BITRK)
|
#define RKASK(x) ((x) | BITRK)
|
||||||
|
28
3rdparty/lua/src/loslib.c
vendored
28
3rdparty/lua/src/loslib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loslib.c,v 1.64 2016/04/18 13:06:55 roberto Exp $
|
** $Id: loslib.c,v 1.65 2016/07/18 17:58:58 roberto Exp $
|
||||||
** Standard Operating System library
|
** Standard Operating System library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -30,16 +30,16 @@
|
|||||||
*/
|
*/
|
||||||
#if !defined(LUA_STRFTIMEOPTIONS) /* { */
|
#if !defined(LUA_STRFTIMEOPTIONS) /* { */
|
||||||
|
|
||||||
/* options for ANSI C 89 */
|
/* options for ANSI C 89 (only 1-char options) */
|
||||||
#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%"
|
#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%"
|
||||||
|
|
||||||
/* options for ISO C 99 and POSIX */
|
/* options for ISO C 99 and POSIX */
|
||||||
#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \
|
#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \
|
||||||
"||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy"
|
"||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */
|
||||||
|
|
||||||
/* options for Windows */
|
/* options for Windows */
|
||||||
#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \
|
#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \
|
||||||
"||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y"
|
"||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */
|
||||||
|
|
||||||
#if defined(LUA_USE_WINDOWS)
|
#if defined(LUA_USE_WINDOWS)
|
||||||
#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN
|
#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN
|
||||||
@ -257,12 +257,13 @@ static int getfield (lua_State *L, const char *key, int d, int delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *checkoption (lua_State *L, const char *conv, char *buff) {
|
static const char *checkoption (lua_State *L, const char *conv,
|
||||||
const char *option;
|
ptrdiff_t convlen, char *buff) {
|
||||||
int oplen = 1;
|
const char *option = LUA_STRFTIMEOPTIONS;
|
||||||
for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) {
|
int oplen = 1; /* length of options being checked */
|
||||||
|
for (; *option != '\0' && oplen <= convlen; option += oplen) {
|
||||||
if (*option == '|') /* next block? */
|
if (*option == '|') /* next block? */
|
||||||
oplen++; /* next length */
|
oplen++; /* will check options with next length (+1) */
|
||||||
else if (memcmp(conv, option, oplen) == 0) { /* match? */
|
else if (memcmp(conv, option, oplen) == 0) { /* match? */
|
||||||
memcpy(buff, conv, oplen); /* copy valid option to buffer */
|
memcpy(buff, conv, oplen); /* copy valid option to buffer */
|
||||||
buff[oplen] = '\0';
|
buff[oplen] = '\0';
|
||||||
@ -280,8 +281,10 @@ static const char *checkoption (lua_State *L, const char *conv, char *buff) {
|
|||||||
|
|
||||||
|
|
||||||
static int os_date (lua_State *L) {
|
static int os_date (lua_State *L) {
|
||||||
const char *s = luaL_optstring(L, 1, "%c");
|
size_t slen;
|
||||||
|
const char *s = luaL_optlstring(L, 1, "%c", &slen);
|
||||||
time_t t = luaL_opt(L, l_checktime, 2, time(NULL));
|
time_t t = luaL_opt(L, l_checktime, 2, time(NULL));
|
||||||
|
const char *se = s + slen; /* 's' end */
|
||||||
struct tm tmr, *stm;
|
struct tm tmr, *stm;
|
||||||
if (*s == '!') { /* UTC? */
|
if (*s == '!') { /* UTC? */
|
||||||
stm = l_gmtime(&t, &tmr);
|
stm = l_gmtime(&t, &tmr);
|
||||||
@ -300,13 +303,14 @@ static int os_date (lua_State *L) {
|
|||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
cc[0] = '%';
|
cc[0] = '%';
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
while (*s) {
|
while (s < se) {
|
||||||
if (*s != '%') /* not a conversion specifier? */
|
if (*s != '%') /* not a conversion specifier? */
|
||||||
luaL_addchar(&b, *s++);
|
luaL_addchar(&b, *s++);
|
||||||
else {
|
else {
|
||||||
size_t reslen;
|
size_t reslen;
|
||||||
char *buff = luaL_prepbuffsize(&b, SIZETIMEFMT);
|
char *buff = luaL_prepbuffsize(&b, SIZETIMEFMT);
|
||||||
s = checkoption(L, s + 1, cc + 1); /* copy specifier to 'cc' */
|
s++; /* skip '%' */
|
||||||
|
s = checkoption(L, s, se - s, cc + 1); /* copy specifier to 'cc' */
|
||||||
reslen = strftime(buff, SIZETIMEFMT, cc, stm);
|
reslen = strftime(buff, SIZETIMEFMT, cc, stm);
|
||||||
luaL_addsize(&b, reslen);
|
luaL_addsize(&b, reslen);
|
||||||
}
|
}
|
||||||
|
14
3rdparty/lua/src/lparser.c
vendored
14
3rdparty/lua/src/lparser.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.153 2016/05/13 19:10:16 roberto Exp $
|
** $Id: lparser.c,v 2.155 2016/08/01 19:51:24 roberto Exp $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -323,6 +323,8 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
|
|||||||
luaK_nil(fs, reg, extra);
|
luaK_nil(fs, reg, extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nexps > nvars)
|
||||||
|
ls->fs->freereg -= nexps - nvars; /* remove extra values */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -764,7 +766,7 @@ static void parlist (LexState *ls) {
|
|||||||
}
|
}
|
||||||
case TK_DOTS: { /* param -> '...' */
|
case TK_DOTS: { /* param -> '...' */
|
||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
f->is_vararg = 2; /* declared vararg */
|
f->is_vararg = 1; /* declared vararg */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: luaX_syntaxerror(ls, "<name> or '...' expected");
|
default: luaX_syntaxerror(ls, "<name> or '...' expected");
|
||||||
@ -960,7 +962,6 @@ static void simpleexp (LexState *ls, expdesc *v) {
|
|||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
check_condition(ls, fs->f->is_vararg,
|
check_condition(ls, fs->f->is_vararg,
|
||||||
"cannot use '...' outside a vararg function");
|
"cannot use '...' outside a vararg function");
|
||||||
fs->f->is_vararg = 1; /* function actually uses vararg */
|
|
||||||
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
|
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1160,11 +1161,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
|
|||||||
int nexps;
|
int nexps;
|
||||||
checknext(ls, '=');
|
checknext(ls, '=');
|
||||||
nexps = explist(ls, &e);
|
nexps = explist(ls, &e);
|
||||||
if (nexps != nvars) {
|
if (nexps != nvars)
|
||||||
adjust_assign(ls, nvars, nexps, &e);
|
adjust_assign(ls, nvars, nexps, &e);
|
||||||
if (nexps > nvars)
|
|
||||||
ls->fs->freereg -= nexps - nvars; /* remove extra values */
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
luaK_setoneret(ls->fs, &e); /* close last expression */
|
luaK_setoneret(ls->fs, &e); /* close last expression */
|
||||||
luaK_storevar(ls->fs, &lh->v, &e);
|
luaK_storevar(ls->fs, &lh->v, &e);
|
||||||
@ -1615,7 +1613,7 @@ static void mainfunc (LexState *ls, FuncState *fs) {
|
|||||||
BlockCnt bl;
|
BlockCnt bl;
|
||||||
expdesc v;
|
expdesc v;
|
||||||
open_func(ls, fs, &bl);
|
open_func(ls, fs, &bl);
|
||||||
fs->f->is_vararg = 2; /* main function is always declared vararg */
|
fs->f->is_vararg = 1; /* main function is always declared vararg */
|
||||||
init_exp(&v, VLOCAL, 0); /* create and... */
|
init_exp(&v, VLOCAL, 0); /* create and... */
|
||||||
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
|
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
|
||||||
luaX_next(ls); /* read first token */
|
luaX_next(ls); /* read first token */
|
||||||
|
5
3rdparty/lua/src/lstate.h
vendored
5
3rdparty/lua/src/lstate.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 2.130 2015/12/16 16:39:38 roberto Exp $
|
** $Id: lstate.h,v 2.133 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -88,7 +88,7 @@ typedef struct CallInfo {
|
|||||||
} u;
|
} u;
|
||||||
ptrdiff_t extra;
|
ptrdiff_t extra;
|
||||||
short nresults; /* expected number of results from this function */
|
short nresults; /* expected number of results from this function */
|
||||||
lu_byte callstatus;
|
unsigned short callstatus;
|
||||||
} CallInfo;
|
} CallInfo;
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +104,7 @@ typedef struct CallInfo {
|
|||||||
#define CIST_TAIL (1<<5) /* call was tail called */
|
#define CIST_TAIL (1<<5) /* call was tail called */
|
||||||
#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */
|
#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */
|
||||||
#define CIST_LEQ (1<<7) /* using __lt for __le */
|
#define CIST_LEQ (1<<7) /* using __lt for __le */
|
||||||
|
#define CIST_FIN (1<<8) /* call is running a finalizer */
|
||||||
|
|
||||||
#define isLua(ci) ((ci)->callstatus & CIST_LUA)
|
#define isLua(ci) ((ci)->callstatus & CIST_LUA)
|
||||||
|
|
||||||
|
18
3rdparty/lua/src/lstrlib.c
vendored
18
3rdparty/lua/src/lstrlib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.251 2016/05/20 14:13:21 roberto Exp $
|
** $Id: lstrlib.c,v 1.254 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -839,11 +839,12 @@ static lua_Number adddigit (char *buff, int n, lua_Number x) {
|
|||||||
|
|
||||||
|
|
||||||
static int num2straux (char *buff, int sz, lua_Number x) {
|
static int num2straux (char *buff, int sz, lua_Number x) {
|
||||||
if (x != x || x == HUGE_VAL || x == -HUGE_VAL) /* inf or NaN? */
|
/* if 'inf' or 'NaN', format it like '%g' */
|
||||||
return l_sprintf(buff, sz, LUA_NUMBER_FMT, x); /* equal to '%g' */
|
if (x != x || x == (lua_Number)HUGE_VAL || x == -(lua_Number)HUGE_VAL)
|
||||||
|
return l_sprintf(buff, sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)x);
|
||||||
else if (x == 0) { /* can be -0... */
|
else if (x == 0) { /* can be -0... */
|
||||||
/* create "0" or "-0" followed by exponent */
|
/* create "0" or "-0" followed by exponent */
|
||||||
return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", x);
|
return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", (LUAI_UACNUMBER)x);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int e;
|
int e;
|
||||||
@ -933,7 +934,7 @@ static void addquoted (luaL_Buffer *b, const char *s, size_t len) {
|
|||||||
static void checkdp (char *buff, int nb) {
|
static void checkdp (char *buff, int nb) {
|
||||||
if (memchr(buff, '.', nb) == NULL) { /* no dot? */
|
if (memchr(buff, '.', nb) == NULL) { /* no dot? */
|
||||||
char point = lua_getlocaledecpoint(); /* try locale point */
|
char point = lua_getlocaledecpoint(); /* try locale point */
|
||||||
char *ppoint = (char*)memchr(buff, point, nb);
|
char *ppoint = (char *)memchr(buff, point, nb);
|
||||||
if (ppoint) *ppoint = '.'; /* change it to a dot */
|
if (ppoint) *ppoint = '.'; /* change it to a dot */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -960,7 +961,7 @@ static void addliteral (lua_State *L, luaL_Buffer *b, int arg) {
|
|||||||
const char *format = (n == LUA_MININTEGER) /* corner case? */
|
const char *format = (n == LUA_MININTEGER) /* corner case? */
|
||||||
? "0x%" LUA_INTEGER_FRMLEN "x" /* use hexa */
|
? "0x%" LUA_INTEGER_FRMLEN "x" /* use hexa */
|
||||||
: LUA_INTEGER_FMT; /* else use default format */
|
: LUA_INTEGER_FMT; /* else use default format */
|
||||||
nb = l_sprintf(buff, MAX_ITEM, format, n);
|
nb = l_sprintf(buff, MAX_ITEM, format, (LUAI_UACINT)n);
|
||||||
}
|
}
|
||||||
luaL_addsize(b, nb);
|
luaL_addsize(b, nb);
|
||||||
break;
|
break;
|
||||||
@ -1041,7 +1042,7 @@ static int str_format (lua_State *L) {
|
|||||||
case 'o': case 'u': case 'x': case 'X': {
|
case 'o': case 'u': case 'x': case 'X': {
|
||||||
lua_Integer n = luaL_checkinteger(L, arg);
|
lua_Integer n = luaL_checkinteger(L, arg);
|
||||||
addlenmod(form, LUA_INTEGER_FRMLEN);
|
addlenmod(form, LUA_INTEGER_FRMLEN);
|
||||||
nb = l_sprintf(buff, MAX_ITEM, form, n);
|
nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACINT)n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'a': case 'A':
|
case 'a': case 'A':
|
||||||
@ -1051,8 +1052,9 @@ static int str_format (lua_State *L) {
|
|||||||
break;
|
break;
|
||||||
case 'e': case 'E': case 'f':
|
case 'e': case 'E': case 'f':
|
||||||
case 'g': case 'G': {
|
case 'g': case 'G': {
|
||||||
|
lua_Number n = luaL_checknumber(L, arg);
|
||||||
addlenmod(form, LUA_NUMBER_FRMLEN);
|
addlenmod(form, LUA_NUMBER_FRMLEN);
|
||||||
nb = l_sprintf(buff, MAX_ITEM, form, luaL_checknumber(L, arg));
|
nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACNUMBER)n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'q': {
|
case 'q': {
|
||||||
|
46
3rdparty/lua/src/ltable.c
vendored
46
3rdparty/lua/src/ltable.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 2.117 2015/11/19 19:16:22 roberto Exp $
|
** $Id: ltable.c,v 2.118 2016/11/07 12:38:35 roberto Exp $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -74,8 +74,6 @@
|
|||||||
|
|
||||||
#define dummynode (&dummynode_)
|
#define dummynode (&dummynode_)
|
||||||
|
|
||||||
#define isdummy(n) ((n) == dummynode)
|
|
||||||
|
|
||||||
static const Node dummynode_ = {
|
static const Node dummynode_ = {
|
||||||
{NILCONSTANT}, /* value */
|
{NILCONSTANT}, /* value */
|
||||||
{{NILCONSTANT, 0}} /* key */
|
{{NILCONSTANT, 0}} /* key */
|
||||||
@ -308,14 +306,14 @@ static void setarrayvector (lua_State *L, Table *t, unsigned int size) {
|
|||||||
|
|
||||||
|
|
||||||
static void setnodevector (lua_State *L, Table *t, unsigned int size) {
|
static void setnodevector (lua_State *L, Table *t, unsigned int size) {
|
||||||
int lsize;
|
|
||||||
if (size == 0) { /* no elements to hash part? */
|
if (size == 0) { /* no elements to hash part? */
|
||||||
t->node = cast(Node *, dummynode); /* use common 'dummynode' */
|
t->node = cast(Node *, dummynode); /* use common 'dummynode' */
|
||||||
lsize = 0;
|
t->lsizenode = 0;
|
||||||
|
t->lastfree = NULL; /* signal that it is using dummy node */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
lsize = luaO_ceillog2(size);
|
int lsize = luaO_ceillog2(size);
|
||||||
if (lsize > MAXHBITS)
|
if (lsize > MAXHBITS)
|
||||||
luaG_runerror(L, "table overflow");
|
luaG_runerror(L, "table overflow");
|
||||||
size = twoto(lsize);
|
size = twoto(lsize);
|
||||||
@ -326,9 +324,9 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) {
|
|||||||
setnilvalue(wgkey(n));
|
setnilvalue(wgkey(n));
|
||||||
setnilvalue(gval(n));
|
setnilvalue(gval(n));
|
||||||
}
|
}
|
||||||
|
t->lsizenode = cast_byte(lsize);
|
||||||
|
t->lastfree = gnode(t, size); /* all positions are free */
|
||||||
}
|
}
|
||||||
t->lsizenode = cast_byte(lsize);
|
|
||||||
t->lastfree = gnode(t, size); /* all positions are free */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,7 +335,7 @@ void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int j;
|
int j;
|
||||||
unsigned int oldasize = t->sizearray;
|
unsigned int oldasize = t->sizearray;
|
||||||
int oldhsize = t->lsizenode;
|
int oldhsize = allocsizenode(t);
|
||||||
Node *nold = t->node; /* save old hash ... */
|
Node *nold = t->node; /* save old hash ... */
|
||||||
if (nasize > oldasize) /* array part must grow? */
|
if (nasize > oldasize) /* array part must grow? */
|
||||||
setarrayvector(L, t, nasize);
|
setarrayvector(L, t, nasize);
|
||||||
@ -354,7 +352,7 @@ void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
|
|||||||
luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
|
luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
|
||||||
}
|
}
|
||||||
/* re-insert elements from hash part */
|
/* re-insert elements from hash part */
|
||||||
for (j = twoto(oldhsize) - 1; j >= 0; j--) {
|
for (j = oldhsize - 1; j >= 0; j--) {
|
||||||
Node *old = nold + j;
|
Node *old = nold + j;
|
||||||
if (!ttisnil(gval(old))) {
|
if (!ttisnil(gval(old))) {
|
||||||
/* doesn't need barrier/invalidate cache, as entry was
|
/* doesn't need barrier/invalidate cache, as entry was
|
||||||
@ -362,13 +360,13 @@ void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
|
|||||||
setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
|
setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isdummy(nold))
|
if (oldhsize > 0) /* not the dummy node? */
|
||||||
luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old hash */
|
luaM_freearray(L, nold, cast(size_t, oldhsize)); /* free old hash */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) {
|
void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) {
|
||||||
int nsize = isdummy(t->node) ? 0 : sizenode(t);
|
int nsize = allocsizenode(t);
|
||||||
luaH_resize(L, t, nasize, nsize);
|
luaH_resize(L, t, nasize, nsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +412,7 @@ Table *luaH_new (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
void luaH_free (lua_State *L, Table *t) {
|
void luaH_free (lua_State *L, Table *t) {
|
||||||
if (!isdummy(t->node))
|
if (!isdummy(t))
|
||||||
luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
|
luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
|
||||||
luaM_freearray(L, t->array, t->sizearray);
|
luaM_freearray(L, t->array, t->sizearray);
|
||||||
luaM_free(L, t);
|
luaM_free(L, t);
|
||||||
@ -422,10 +420,12 @@ void luaH_free (lua_State *L, Table *t) {
|
|||||||
|
|
||||||
|
|
||||||
static Node *getfreepos (Table *t) {
|
static Node *getfreepos (Table *t) {
|
||||||
while (t->lastfree > t->node) {
|
if (!isdummy(t)) {
|
||||||
t->lastfree--;
|
while (t->lastfree > t->node) {
|
||||||
if (ttisnil(gkey(t->lastfree)))
|
t->lastfree--;
|
||||||
return t->lastfree;
|
if (ttisnil(gkey(t->lastfree)))
|
||||||
|
return t->lastfree;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL; /* could not find a free place */
|
return NULL; /* could not find a free place */
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
|||||||
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
|
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
|
||||||
else if (ttisfloat(key)) {
|
else if (ttisfloat(key)) {
|
||||||
lua_Integer k;
|
lua_Integer k;
|
||||||
if (luaV_tointeger(key, &k, 0)) { /* index is int? */
|
if (luaV_tointeger(key, &k, 0)) { /* does index fit in an integer? */
|
||||||
setivalue(&aux, k);
|
setivalue(&aux, k);
|
||||||
key = &aux; /* insert it as an integer */
|
key = &aux; /* insert it as an integer */
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
|||||||
luaG_runerror(L, "table index is NaN");
|
luaG_runerror(L, "table index is NaN");
|
||||||
}
|
}
|
||||||
mp = mainposition(t, key);
|
mp = mainposition(t, key);
|
||||||
if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
|
if (!ttisnil(gval(mp)) || isdummy(t)) { /* main position is taken? */
|
||||||
Node *othern;
|
Node *othern;
|
||||||
Node *f = getfreepos(t); /* get a free place */
|
Node *f = getfreepos(t); /* get a free place */
|
||||||
if (f == NULL) { /* cannot find a free place? */
|
if (f == NULL) { /* cannot find a free place? */
|
||||||
@ -461,7 +461,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
|||||||
/* whatever called 'newkey' takes care of TM cache */
|
/* whatever called 'newkey' takes care of TM cache */
|
||||||
return luaH_set(L, t, key); /* insert key into grown table */
|
return luaH_set(L, t, key); /* insert key into grown table */
|
||||||
}
|
}
|
||||||
lua_assert(!isdummy(f));
|
lua_assert(!isdummy(t));
|
||||||
othern = mainposition(t, gkey(mp));
|
othern = mainposition(t, gkey(mp));
|
||||||
if (othern != mp) { /* is colliding node out of its main position? */
|
if (othern != mp) { /* is colliding node out of its main position? */
|
||||||
/* yes; move colliding node into free position */
|
/* yes; move colliding node into free position */
|
||||||
@ -651,7 +651,7 @@ int luaH_getn (Table *t) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
/* else must find a boundary in hash part */
|
/* else must find a boundary in hash part */
|
||||||
else if (isdummy(t->node)) /* hash part is empty? */
|
else if (isdummy(t)) /* hash part is empty? */
|
||||||
return j; /* that is easy... */
|
return j; /* that is easy... */
|
||||||
else return unbound_search(t, j);
|
else return unbound_search(t, j);
|
||||||
}
|
}
|
||||||
@ -664,6 +664,6 @@ Node *luaH_mainposition (const Table *t, const TValue *key) {
|
|||||||
return mainposition(t, key);
|
return mainposition(t, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int luaH_isdummy (Node *n) { return isdummy(n); }
|
int luaH_isdummy (const Table *t) { return isdummy(t); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
3rdparty/lua/src/ltable.h
vendored
12
3rdparty/lua/src/ltable.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltable.h,v 2.21 2015/11/03 15:47:30 roberto Exp $
|
** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -27,6 +27,14 @@
|
|||||||
#define invalidateTMcache(t) ((t)->flags = 0)
|
#define invalidateTMcache(t) ((t)->flags = 0)
|
||||||
|
|
||||||
|
|
||||||
|
/* true when 't' is using 'dummynode' as its hash part */
|
||||||
|
#define isdummy(t) ((t)->lastfree == NULL)
|
||||||
|
|
||||||
|
|
||||||
|
/* allocated size for hash nodes */
|
||||||
|
#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
|
||||||
|
|
||||||
|
|
||||||
/* returns the key, given the value of a table entry */
|
/* returns the key, given the value of a table entry */
|
||||||
#define keyfromval(v) \
|
#define keyfromval(v) \
|
||||||
(gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
|
(gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
|
||||||
@ -51,7 +59,7 @@ LUAI_FUNC int luaH_getn (Table *t);
|
|||||||
|
|
||||||
#if defined(LUA_DEBUG)
|
#if defined(LUA_DEBUG)
|
||||||
LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
|
LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
|
||||||
LUAI_FUNC int luaH_isdummy (Node *n);
|
LUAI_FUNC int luaH_isdummy (const Table *t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
2
3rdparty/lua/src/ltm.c
vendored
2
3rdparty/lua/src/ltm.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltm.c,v 2.37 2016/02/26 19:20:15 roberto Exp $
|
** $Id: ltm.c,v 2.38 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Tag methods
|
** Tag methods
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
9
3rdparty/lua/src/lua.c
vendored
9
3rdparty/lua/src/lua.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.226 2015/08/14 19:11:20 roberto Exp $
|
** $Id: lua.c,v 1.230 2017/01/12 17:14:26 roberto Exp $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(LUA_PROMPT)
|
#if !defined(LUA_PROMPT)
|
||||||
#define LUA_PROMPT "> "
|
#define LUA_PROMPT "> "
|
||||||
#define LUA_PROMPT2 ">> "
|
#define LUA_PROMPT2 ">> "
|
||||||
@ -37,8 +38,7 @@
|
|||||||
#define LUA_INIT_VAR "LUA_INIT"
|
#define LUA_INIT_VAR "LUA_INIT"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LUA_INITVARVERSION \
|
#define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX
|
||||||
LUA_INIT_VAR "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -55,6 +55,8 @@
|
|||||||
#elif defined(LUA_USE_WINDOWS) /* }{ */
|
#elif defined(LUA_USE_WINDOWS) /* }{ */
|
||||||
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
||||||
|
|
||||||
#else /* }{ */
|
#else /* }{ */
|
||||||
@ -529,6 +531,7 @@ static int runargs (lua_State *L, char **argv, int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int handle_luainit (lua_State *L) {
|
static int handle_luainit (lua_State *L) {
|
||||||
const char *name = "=" LUA_INITVARVERSION;
|
const char *name = "=" LUA_INITVARVERSION;
|
||||||
const char *init = getenv(name + 1);
|
const char *init = getenv(name + 1);
|
||||||
|
8
3rdparty/lua/src/lua.h
vendored
8
3rdparty/lua/src/lua.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.331 2016/05/30 15:53:28 roberto Exp $
|
** $Id: lua.h,v 1.332 2016/12/22 15:51:20 roberto Exp $
|
||||||
** Lua - A Scripting Language
|
** Lua - A Scripting Language
|
||||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||||
** See Copyright Notice at the end of this file
|
** See Copyright Notice at the end of this file
|
||||||
@ -19,11 +19,11 @@
|
|||||||
#define LUA_VERSION_MAJOR "5"
|
#define LUA_VERSION_MAJOR "5"
|
||||||
#define LUA_VERSION_MINOR "3"
|
#define LUA_VERSION_MINOR "3"
|
||||||
#define LUA_VERSION_NUM 503
|
#define LUA_VERSION_NUM 503
|
||||||
#define LUA_VERSION_RELEASE "3"
|
#define LUA_VERSION_RELEASE "4"
|
||||||
|
|
||||||
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
|
||||||
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
|
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
|
||||||
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2016 Lua.org, PUC-Rio"
|
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2017 Lua.org, PUC-Rio"
|
||||||
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
|
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
|
||||||
|
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ struct lua_Debug {
|
|||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 1994-2016 Lua.org, PUC-Rio.
|
* Copyright (C) 1994-2017 Lua.org, PUC-Rio.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
|
32
3rdparty/lua/src/luaconf.h
vendored
32
3rdparty/lua/src/luaconf.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.255 2016/05/01 20:06:09 roberto Exp $
|
** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -158,6 +158,18 @@
|
|||||||
** ===================================================================
|
** ===================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** LUA_PATH_SEP is the character that separates templates in a path.
|
||||||
|
** LUA_PATH_MARK is the string that marks the substitution points in a
|
||||||
|
** template.
|
||||||
|
** LUA_EXEC_DIR in a Windows path is replaced by the executable's
|
||||||
|
** directory.
|
||||||
|
*/
|
||||||
|
#define LUA_PATH_SEP ";"
|
||||||
|
#define LUA_PATH_MARK "?"
|
||||||
|
#define LUA_EXEC_DIR "!"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
|
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
|
||||||
** Lua libraries.
|
** Lua libraries.
|
||||||
@ -404,7 +416,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUA_NUMBER is the floating-point type used by Lua.
|
@@ LUA_NUMBER is the floating-point type used by Lua.
|
||||||
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
|
@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
|
||||||
@@ over a floating number.
|
@@ over a floating number.
|
||||||
@@ l_mathlim(x) corrects limit name 'x' to the proper float type
|
@@ l_mathlim(x) corrects limit name 'x' to the proper float type
|
||||||
** by prefixing it with one of FLT/DBL/LDBL.
|
** by prefixing it with one of FLT/DBL/LDBL.
|
||||||
@ -421,7 +433,8 @@
|
|||||||
|
|
||||||
#define l_floor(x) (l_mathop(floor)(x))
|
#define l_floor(x) (l_mathop(floor)(x))
|
||||||
|
|
||||||
#define lua_number2str(s,sz,n) l_sprintf((s), sz, LUA_NUMBER_FMT, (n))
|
#define lua_number2str(s,sz,n) \
|
||||||
|
l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ lua_numbertointeger converts a float number to an integer, or
|
@@ lua_numbertointeger converts a float number to an integer, or
|
||||||
@ -498,7 +511,7 @@
|
|||||||
**
|
**
|
||||||
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
|
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
|
||||||
**
|
**
|
||||||
@@ LUAI_UACINT is the result of an 'usual argument conversion'
|
@@ LUAI_UACINT is the result of a 'default argument promotion'
|
||||||
@@ over a lUA_INTEGER.
|
@@ over a lUA_INTEGER.
|
||||||
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
|
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
|
||||||
@@ LUA_INTEGER_FMT is the format for writing integers.
|
@@ LUA_INTEGER_FMT is the format for writing integers.
|
||||||
@ -511,10 +524,12 @@
|
|||||||
/* The following definitions are good for most cases here */
|
/* The following definitions are good for most cases here */
|
||||||
|
|
||||||
#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
|
#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
|
||||||
#define lua_integer2str(s,sz,n) l_sprintf((s), sz, LUA_INTEGER_FMT, (n))
|
|
||||||
|
|
||||||
#define LUAI_UACINT LUA_INTEGER
|
#define LUAI_UACINT LUA_INTEGER
|
||||||
|
|
||||||
|
#define lua_integer2str(s,sz,n) \
|
||||||
|
l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** use LUAI_UACINT here to avoid problems with promotions (which
|
** use LUAI_UACINT here to avoid problems with promotions (which
|
||||||
** can turn a comparison between unsigneds into a signed comparison)
|
** can turn a comparison between unsigneds into a signed comparison)
|
||||||
@ -612,7 +627,8 @@
|
|||||||
** provide its own implementation.
|
** provide its own implementation.
|
||||||
*/
|
*/
|
||||||
#if !defined(LUA_USE_C89)
|
#if !defined(LUA_USE_C89)
|
||||||
#define lua_number2strx(L,b,sz,f,n) ((void)L, l_sprintf(b,sz,f,n))
|
#define lua_number2strx(L,b,sz,f,n) \
|
||||||
|
((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -728,11 +744,11 @@
|
|||||||
/*
|
/*
|
||||||
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
|
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
|
||||||
** CHANGE it if it uses too much C-stack space. (For long double,
|
** CHANGE it if it uses too much C-stack space. (For long double,
|
||||||
** 'string.format("%.99f", 1e4932)' needs ~5030 bytes, so a
|
** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a
|
||||||
** smaller buffer would force a memory allocation for each call to
|
** smaller buffer would force a memory allocation for each call to
|
||||||
** 'string.format'.)
|
** 'string.format'.)
|
||||||
*/
|
*/
|
||||||
#if defined(LUA_FLOAT_LONGDOUBLE)
|
#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
|
||||||
#define LUAL_BUFFERSIZE 8192
|
#define LUAL_BUFFERSIZE 8192
|
||||||
#else
|
#else
|
||||||
#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
|
#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
|
||||||
|
5
3rdparty/lua/src/lualib.h
vendored
5
3rdparty/lua/src/lualib.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $
|
** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $
|
||||||
** Lua standard libraries
|
** Lua standard libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -11,6 +11,9 @@
|
|||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* version suffix for environment variable names */
|
||||||
|
#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
|
||||||
|
|
||||||
|
|
||||||
LUAMOD_API int (luaopen_base) (lua_State *L);
|
LUAMOD_API int (luaopen_base) (lua_State *L);
|
||||||
|
|
||||||
|
2
3rdparty/lua/src/lutf8lib.c
vendored
2
3rdparty/lua/src/lutf8lib.c
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lutf8lib.c,v 1.15 2015/03/28 19:16:55 roberto Exp $
|
** $Id: lutf8lib.c,v 1.16 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Standard library for UTF-8 manipulation
|
** Standard library for UTF-8 manipulation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
2
3rdparty/lua/src/lvm.h
vendored
2
3rdparty/lua/src/lvm.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.h,v 2.40 2016/01/05 16:07:21 roberto Exp $
|
** $Id: lvm.h,v 2.41 2016/12/22 13:08:50 roberto Exp $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user