Skip to content

Commit

Permalink
Import Lua 5.2.0 (alpha)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lua Team authored and ittner committed Nov 16, 2010
1 parent bb563ad commit 9cc317b
Show file tree
Hide file tree
Showing 19 changed files with 286 additions and 286 deletions.
2 changes: 1 addition & 1 deletion README
@@ -1,5 +1,5 @@

This is Lua 5.2 (work5), released on 30 Oct 2010.
This is Lua 5.2 (alpha), released on 16 Nov 2010.

For installation instructions, license details, and
further information about Lua, see doc/readme.html.
Expand Down
14 changes: 7 additions & 7 deletions doc/contents.html
Expand Up @@ -22,8 +22,8 @@ <H1>

<P>
<IMG SRC="alert.png" ALIGN="absbottom" ALT="[!]">
<EM>This is a work version of Lua 5.2.
Everything may change in the final version.</EM>
<EM>This is an alpha version of Lua 5.2.
Some details may change in the final version.</EM>

<P>
The reference manual is the official definition of the Lua language.
Expand Down Expand Up @@ -52,7 +52,7 @@ <H2><A NAME="contents">Contents</A></H2>
<LI><A HREF="manual.html#2.1">2.1 &ndash; Values and Types</A>
<LI><A HREF="manual.html#2.2">2.2 &ndash; Environments and the Global Environment</A>
<LI><A HREF="manual.html#2.3">2.3 &ndash; Error Handling</A>
<LI><A HREF="manual.html#2.4">2.4 &ndash; Metatables</A>
<LI><A HREF="manual.html#2.4">2.4 &ndash; Metatables and Metamethods</A>
<LI><A HREF="manual.html#2.5">2.5 &ndash; Garbage Collection</A>
<UL>
<LI><A HREF="manual.html#2.5.1">2.5.1 &ndash; Garbage-Collection Metamethods</A>
Expand Down Expand Up @@ -484,7 +484,6 @@ <H3>auxiliary library</H3>
<A HREF="manual.html#luaL_newlib">luaL_newlib</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_setfuncs">luaL_setfuncs</A><BR>
<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>
<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
Expand All @@ -497,11 +496,12 @@ <H3>auxiliary library</H3>
<A HREF="manual.html#luaL_pushresult">luaL_pushresult</A><BR>
<A HREF="manual.html#luaL_ref">luaL_ref</A><BR>
<A HREF="manual.html#luaL_requiref">luaL_requiref</A><BR>
<A HREF="manual.html#luaL_setfuncs">luaL_setfuncs</A><BR>
<A HREF="manual.html#luaL_setmetatable">luaL_setmetatable</A><BR>
<A HREF="manual.html#luaL_testudata">luaL_testudata</A><BR>
<A HREF="manual.html#luaL_tolstring">luaL_tolstring</A><BR>
<A HREF="manual.html#luaL_traceback">luaL_traceback</A><BR>
<A HREF="manual.html#luaL_typename">luaL_typename</A><BR>
<A HREF="manual.html#luaL_typeerror">luaL_typeerror</A><BR>
<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>
<A HREF="manual.html#luaL_where">luaL_where</A><BR>

Expand All @@ -512,10 +512,10 @@ <H3>auxiliary library</H3>
<HR>
<SMALL>
Last update:
Sat Oct 30 21:34:44 BRST 2010
Tue Nov 16 09:56:07 BRST 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (work5)
Last change: revised for Lua 5.2.0 (alpha)
-->

</BODY>
Expand Down
100 changes: 36 additions & 64 deletions doc/manual.html
Expand Up @@ -17,8 +17,8 @@ <h1>
</h1>

<IMG SRC="alert.png" ALIGN="absbottom" ALT="[!]">
<EM>This is a work version of Lua 5.2.
Everything may change in the final version.</EM>
<EM>This is an alpha version of Lua 5.2.
Some details may change in the final version.</EM>
<P>

by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
Expand All @@ -38,7 +38,7 @@ <h1>
<!-- ====================================================================== -->
<p>

<!-- $Id: manual.of,v 1.61 2010/10/29 12:51:39 roberto Exp $ -->
<!-- $Id: manual.of,v 1.62 2010/11/16 11:38:25 roberto Exp $ -->



Expand Down Expand Up @@ -287,7 +287,7 @@ <h2>2.3 &ndash; <a name="2.3">Error Handling</a></h2>



<h2>2.4 &ndash; <a name="2.4">Metatables</a></h2>
<h2>2.4 &ndash; <a name="2.4">Metatables and Metamethods</a></h2>

<p>
Every value in Lua can have a <em>metatable</em>.
Expand All @@ -305,7 +305,7 @@ <h2>2.4 &ndash; <a name="2.4">Metatables</a></h2>
<p>
We call the keys in a metatable <em>events</em>
and the values <em>metamethods</em>.
In the previous example, the event is <code>"add"</code>
In the previous example, the event is <code>"__add"</code>
and the metamethod is the function that performs the addition.


Expand Down Expand Up @@ -383,7 +383,7 @@ <h2>2.4 &ndash; <a name="2.4">Metatables</a></h2>

<p>
For the unary <code>-</code> and <code>#</code> operators,
the metamethod is called repeating the first argument as a second argument.
the metamethod is called with a dummy second argument.
This extra argument is only to simplify Lua's internals;
it may be removed in future versions and therefore it is not present
in the following code.
Expand Down Expand Up @@ -2731,13 +2731,12 @@ <h2>4.8 &ndash; <a name="4.8">Functions and Types</a></h2>
return realloc(ptr, nsize);
}
</pre><p>
This code assumes
Note that ANSI&nbsp;C ensures
that <code>free(NULL)</code> has no effect and that
<code>realloc(NULL, size)</code> is equivalent to <code>malloc(size)</code>.
ANSI&nbsp;C ensures both behaviors.
It also assumes that <code>realloc</code> does not fail when shrinking a block.
(ANSI&nbsp;C does not ensure this behavior,
but it seems a safe assumption.)
This code assumes that <code>realloc</code> does not fail when shrinking a block.
ANSI&nbsp;C does not ensure this behavior,
but it seems a safe assumption.



Expand Down Expand Up @@ -5989,6 +5988,19 @@ <h2>5.1 &ndash; <a name="5.1">Functions and Types</a></h2>



<hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>

<p>
Sets the metatable of the object at the top of the stack
as the metatable associated with name <code>tname</code>
in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).





<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>void luaL_openlibs (lua_State *L);</pre>
Expand Down Expand Up @@ -6280,24 +6292,6 @@ <h2>5.1 &ndash; <a name="5.1">Functions and Types</a></h2>



<hr><h3><a name="luaL_typeerror"><code>luaL_typeerror</code></a></h3><p>
<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_typeerror (lua_State *L, int narg, const char *tname);</pre>

<p>
Generates an error with a message like the following:

<pre>
<em>location</em>: bad argument <em>narg</em> to '<em>func</em>' (<em>tname</em> expected, got <em>rt</em>)
</pre><p>
where <code><em>location</em></code> is produced by <a href="#luaL_where"><code>luaL_where</code></a>,
<code><em>func</em></code> is the name of the current function,
and <code><em>rt</em></code> is the type name of the actual argument.





<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
Expand Down Expand Up @@ -7020,8 +7014,6 @@ <h2>6.2 &ndash; <a name="6.2">Coroutine Manipulation</a></h2>

<p>
Suspends the execution of the calling coroutine.
The coroutine cannot be running a C&nbsp;function,
a metamethod, or an iterator.
Any arguments to <code>yield</code> are passed as extra results to <code>resume</code>.


Expand Down Expand Up @@ -8586,20 +8578,13 @@ <h2>6.8 &ndash; <a name="6.8">Input and Output Facilities</a></h2>


<p>
<hr><h3><a name="pdf-io.lines"><code>io.lines ([filename] [, keepNL])</code></a></h3>
<hr><h3><a name="pdf-io.lines"><code>io.lines ([filename] &middot;&middot;&middot;)</code></a></h3>


<p>
Opens the given file name in read mode
and returns an iterator function that,
each time it is called,
returns a new line from the file.
Therefore, the construction

<pre>
for line in io.lines(filename) do <em>body</em> end
</pre><p>
will iterate over all lines of the file.
and returns an iterator function that
works like <code>file:lines(&middot;&middot;&middot;)</code> over the oppened file.
When the iterator function detects the end of file,
it returns <b>nil</b> (to finish the loop) and automatically closes the file.

Expand All @@ -8611,11 +8596,6 @@ <h2>6.8 &ndash; <a name="6.8">Input and Output Facilities</a></h2>
In this case it does not close the file when the loop ends.


<p>
By default, <code>lines</code> removes the newline at the end of each line.
If <code>keepNL</code> is <b>true</b>, it will keep the newlines.




<p>
Expand Down Expand Up @@ -8750,29 +8730,26 @@ <h2>6.8 &ndash; <a name="6.8">Input and Output Facilities</a></h2>


<p>
<hr><h3><a name="pdf-file:lines"><code>file:lines ([keepNL])</code></a></h3>
<hr><h3><a name="pdf-file:lines"><code>file:lines (&middot;&middot;&middot;)</code></a></h3>


<p>
Returns an iterator function that,
each time it is called,
returns a new line from the file.
reads the file according to the given formats.
When no format is given,
uses "*l" as a default.
Therefore, the construction

<pre>
for line in file:lines() do <em>body</em> end
for c in file:lines(1) do <em>body</em> end
</pre><p>
will iterate over all lines of the file,
will iterate over all characters of the file,
starting at the current position.
(Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
when the loop ends.)


<p>
By default, <code>lines</code> removes the newline at the end of each line.
If <code>keepNL</code> is <b>true</b>, it will keep the newlines.




<p>
Expand Down Expand Up @@ -9673,11 +9650,6 @@ <h2>8.2 &ndash; <a name="8.2">Changes in the Libraries</a></h2>
and it is easy to set up a module with regular Lua code.
</li>

<li>
The debug library is not loaded by default.
You must explicitly require it.
</li>

<li>
Functions <code>setfenv</code> and <code>getfenv</code> are deprecated.
To set the environment of a Lua function,
Expand Down Expand Up @@ -9767,8 +9739,8 @@ <h2>8.3 &ndash; <a name="8.3">Changes in the API</a></h2>
</li>

<li>
<code>luaL_typerror</code> was renamed <a href="#luaL_typeerror"><code>luaL_typeerror</code></a>,
to have a correct spelling.
<code>luaL_typerror</code> was deprecated.
Write your own version if you need it.
</li>

<li>
Expand Down Expand Up @@ -9873,10 +9845,10 @@ <h1>9 &ndash; <a name="9">The Complete Syntax of Lua</a></h1>
<HR>
<SMALL>
Last update:
Sat Oct 30 21:36:20 BRST 2010
Tue Nov 16 09:52:41 BRST 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (work5)
Last change: revised for Lua 5.2.0 (alpha)
-->

</body></html>
Expand Down
15 changes: 8 additions & 7 deletions doc/readme.html
Expand Up @@ -27,13 +27,13 @@
<HR>
<H1>
<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
Welcome to Lua 5.2 (work5)
Welcome to Lua 5.2 (alpha)
</H1>

<P>
<IMG SRC="alert.png" ALIGN="absbottom" ALT="[!]">
<EM>This is a work version of Lua 5.2.
Everything may change in the final version.</EM>
<EM>This is an alpha version of Lua 5.2.
Some details may change in the final version.</EM>

<P>
<A HREF="#about">about</A>
Expand Down Expand Up @@ -323,12 +323,13 @@ <H3>C API</H3>
<LI> new <CODE>lua_compare</CODE>, <CODE>lua_arith</CODE>, and <CODE>lua_len</CODE>
<LI> new <CODE>lua_version</CODE> and <CODE>luaL_version</CODE>
<LI> <CODE>lua_pushstring</CODE> and <CODE>pushlstring</CODE> return string
<LI> new <CODE>luaL_testudata</CODE>
<LI> new <CODE>luaL_testudata</CODE> and <CODE>luaL_setmetatable</CODE>
<LI> new <CODE>luaL_tolstring</CODE>
<LI> new <CODE>lua_copy</CODE>
<LI> new <CODE>lua_absindex</CODE>
<LI> new <CODE>lua_upvalueid</CODE> and <CODE>lua_upvaluejoin</CODE>
<LI> <CODE>nparams</CODE> and <CODE>isvarag</CODE> available in debug API
<LI> new <CODE>lua_Unsigned</CODE>
</UL>

<H3>Implementation</H3>
Expand All @@ -337,7 +338,7 @@ <H3>Implementation</H3>
<LI> internal (immutable) version of ctypes
<LI> simpler implementation for string buffers
<LI> udata with finalizers are kept in a separated list for the GC
<LI> <CODE>CallInfo</CODE>stack now is a linked list
<LI> <CODE>CallInfo</CODE> stack now is a linked list
<LI> parser uses much less C-stack space (no more auto arrays)
<LI> new hash for floats
<LI> handling of non-string error messages in the standalone interpreter
Expand Down Expand Up @@ -390,10 +391,10 @@ <H2><A NAME="license">License</A></H2>
<HR>
<SMALL>
Last update:
Sat Oct 30 21:36:38 BRST 2010
Thu Nov 11 15:16:22 BRST 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (work5)
Last change: revised for Lua 5.2.0 (alpha)
-->

</BODY>
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Expand Up @@ -7,7 +7,7 @@
PLAT= none

CC= gcc
CFLAGS= -O2 -Wall $(MYCFLAGS)
CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(MYCFLAGS)
LIBS= -lm $(MYLIBS)

AR= ar rcu
Expand Down Expand Up @@ -97,7 +97,7 @@ freebsd:
generic: $(ALL)

linux:
$(MAKE) $(ALL) MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -ldl -lreadline -lncurses"
$(MAKE) $(ALL) MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -ldl -lreadline"

macosx:
$(MAKE) $(ALL) MYCFLAGS="-DLUA_USE_MACOSX" MYLIBS="-lreadline"
Expand Down
6 changes: 3 additions & 3 deletions src/lapi.c
@@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.139 2010/10/25 20:31:11 roberto Exp $
** $Id: lapi.c,v 2.140 2010/11/03 15:16:17 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -353,7 +353,7 @@ LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *isnum) {
if (tonumber(o, &n)) {
lua_Unsigned res;
lua_Number num = nvalue(o);
lua_number2uint(res, num);
lua_number2unsigned(res, num);
if (isnum) *isnum = 1;
return res;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
LUA_API void lua_pushunsigned (lua_State *L, lua_Unsigned u) {
lua_Number n;
lua_lock(L);
n = lua_uint2number(u);
n = lua_unsigned2number(u);
setnvalue(L->top, n);
api_incr_top(L);
lua_unlock(L);
Expand Down

0 comments on commit 9cc317b

Please sign in to comment.