summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2010-01-14 12:00:00 +0000
committerrepogen <>2010-01-14 12:00:00 +0000
commitecd48c2901f08a88db32139b97c35c59eba1f19e (patch)
tree526e8dac3e037de0024b37c89fa3150baeea969f
parent22912c77c80f8de8f7accd3319c726f7c5349fd3 (diff)
downloadlua-github-ecd48c2901f08a88db32139b97c35c59eba1f19e.tar.gz
Lua 5.2.0-work25.2.0-work2
-rw-r--r--Makefile4
-rw-r--r--README2
-rw-r--r--doc/contents.html68
-rw-r--r--doc/lua.css5
-rw-r--r--doc/manual.css13
-rw-r--r--doc/manual.html126
-rw-r--r--doc/readme.html91
-rw-r--r--etc/Makefile6
-rw-r--r--etc/README6
-rw-r--r--etc/luavs.bat12
-rw-r--r--etc/min.c15
-rw-r--r--etc/noparser.c6
-rw-r--r--etc/one.c (renamed from etc/all.c)2
-rw-r--r--etc/strict.lua1
-rw-r--r--src/lapi.c7
-rw-r--r--src/lauxlib.h4
-rw-r--r--src/lbitlib.c5
-rw-r--r--src/lcode.c8
-rw-r--r--src/ldebug.c12
-rw-r--r--src/ldo.c10
-rw-r--r--src/loadlib.c42
-rw-r--r--src/ltablib.c4
-rw-r--r--src/ltm.c10
-rw-r--r--src/ltm.h6
-rw-r--r--src/lua.h8
-rw-r--r--src/luaconf.h10
26 files changed, 335 insertions, 148 deletions
diff --git a/Makefile b/Makefile
index 62e759a9..3e8b4b98 100644
--- a/Makefile
+++ b/Makefile
@@ -63,13 +63,13 @@ install: dummy
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
- cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ #cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
uninstall:
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC)
cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB)
- cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN)
+ #cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN)
local:
$(MAKE) install INSTALL_TOP=../install
diff --git a/README b/README
index f2377b02..678a301a 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is Lua 5.2 (work1), released on 08 Jan 2010.
+This is Lua 5.2 (work2), released on 13 Jan 2010.
For information about Lua, including installation instructions and
license details, see doc/readme.html.
diff --git a/doc/contents.html b/doc/contents.html
index beba089f..66d967e3 100644
--- a/doc/contents.html
+++ b/doc/contents.html
@@ -32,7 +32,7 @@ For a complete introduction to Lua programming, see the book
<A HREF="#index">index</A>
<HR>
<SMALL>
-Copyright &copy; 2006-2010 Lua.org, PUC-Rio.
+Copyright &copy; 2010 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html#5">Lua license</a>.
</SMALL>
@@ -59,6 +59,7 @@ Freely available under the terms of the
<LI><A HREF="manual.html#2.4.5">2.4.5 - For Statement</A>
<LI><A HREF="manual.html#2.4.6">2.4.6 - Function Calls as Statements</A>
<LI><A HREF="manual.html#2.4.7">2.4.7 - Local Declarations</A>
+<LI><A HREF="manual.html#2.4.8">2.4.8 - Lexical Environments</A>
</UL>
<LI><A HREF="manual.html#2.5">2.5 - Expressions</A>
<UL>
@@ -92,8 +93,9 @@ Freely available under the terms of the
<LI><A HREF="manual.html#3.4">3.4 - C Closures</A>
<LI><A HREF="manual.html#3.5">3.5 - Registry</A>
<LI><A HREF="manual.html#3.6">3.6 - Error Handling in C</A>
-<LI><A HREF="manual.html#3.7">3.7 - Functions and Types</A>
-<LI><A HREF="manual.html#3.8">3.8 - The Debug Interface</A>
+<LI><A HREF="manual.html#3.7">3.7 - Handling Yields in C</A>
+<LI><A HREF="manual.html#3.8">3.8 - Functions and Types</A>
+<LI><A HREF="manual.html#3.9">3.9 - The Debug Interface</A>
</UL>
<P>
<LI><A HREF="manual.html#4">4 - The Auxiliary Library</A>
@@ -112,9 +114,10 @@ Freely available under the terms of the
</UL>
<LI><A HREF="manual.html#5.5">5.5 - Table Manipulation</A>
<LI><A HREF="manual.html#5.6">5.6 - Mathematical Functions</A>
-<LI><A HREF="manual.html#5.7">5.7 - Input and Output Facilities</A>
-<LI><A HREF="manual.html#5.8">5.8 - Operating System Facilities</A>
-<LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A>
+<LI><A HREF="manual.html#5.7">5.7 - Bitwise operations</A>
+<LI><A HREF="manual.html#5.8">5.8 - Input and Output Facilities</A>
+<LI><A HREF="manual.html#5.9">5.9 - Operating System Facilities</A>
+<LI><A HREF="manual.html#5.10">5.10 - The Debug Library</A>
</UL>
<P>
<LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
@@ -140,10 +143,10 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-collectgarbage">collectgarbage</A><BR>
<A HREF="manual.html#pdf-dofile">dofile</A><BR>
<A HREF="manual.html#pdf-error">error</A><BR>
-<A HREF="manual.html#pdf-getfenv">getfenv</A><BR>
<A HREF="manual.html#pdf-getmetatable">getmetatable</A><BR>
<A HREF="manual.html#pdf-ipairs">ipairs</A><BR>
<A HREF="manual.html#pdf-load">load</A><BR>
+<A HREF="manual.html#pdf-loadin">loadin</A><BR>
<A HREF="manual.html#pdf-loadfile">loadfile</A><BR>
<A HREF="manual.html#pdf-loadstring">loadstring</A><BR>
<A HREF="manual.html#pdf-module">module</A><BR>
@@ -156,15 +159,22 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-rawset">rawset</A><BR>
<A HREF="manual.html#pdf-require">require</A><BR>
<A HREF="manual.html#pdf-select">select</A><BR>
-<A HREF="manual.html#pdf-setfenv">setfenv</A><BR>
<A HREF="manual.html#pdf-setmetatable">setmetatable</A><BR>
<A HREF="manual.html#pdf-tonumber">tonumber</A><BR>
<A HREF="manual.html#pdf-tostring">tostring</A><BR>
<A HREF="manual.html#pdf-type">type</A><BR>
-<A HREF="manual.html#pdf-unpack">unpack</A><BR>
<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
<P>
+<A HREF="manual.html#pdf-bit.band">bit.band</A><BR>
+<A HREF="manual.html#pdf-bit.bnot">bit.bnot</A><BR>
+<A HREF="manual.html#pdf-bit.bor">bit.bor</A><BR>
+<A HREF="manual.html#pdf-bit.brotate">bit.brotate</A><BR>
+<A HREF="manual.html#pdf-bit.bshift">bit.bshift</A><BR>
+<A HREF="manual.html#pdf-bit.btest">bit.btest</A><BR>
+<A HREF="manual.html#pdf-bit.bxor">bit.bxor</A><BR>
+<P>
+
<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
<A HREF="manual.html#pdf-coroutine.resume">coroutine.resume</A><BR>
<A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR>
@@ -187,6 +197,8 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-debug.setmetatable">debug.setmetatable</A><BR>
<A HREF="manual.html#pdf-debug.setupvalue">debug.setupvalue</A><BR>
<A HREF="manual.html#pdf-debug.traceback">debug.traceback</A><BR>
+<A HREF="manual.html#pdf-debug.upvalueid">debug.upvalueid</A><BR>
+<A HREF="manual.html#pdf-debug.upvaluejoin">debug.upvaluejoin</A><BR>
</TD>
<TD>
@@ -232,7 +244,6 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-math.huge">math.huge</A><BR>
<A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>
<A HREF="manual.html#pdf-math.log">math.log</A><BR>
-<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
<A HREF="manual.html#pdf-math.max">math.max</A><BR>
<A HREF="manual.html#pdf-math.min">math.min</A><BR>
<A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
@@ -261,12 +272,14 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-os.tmpname">os.tmpname</A><BR>
<P>
+<A HREF="manual.html#pdf-package.config">package.config</A><BR>
<A HREF="manual.html#pdf-package.cpath">package.cpath</A><BR>
<A HREF="manual.html#pdf-package.loaded">package.loaded</A><BR>
<A HREF="manual.html#pdf-package.loaders">package.loaders</A><BR>
<A HREF="manual.html#pdf-package.loadlib">package.loadlib</A><BR>
<A HREF="manual.html#pdf-package.path">package.path</A><BR>
<A HREF="manual.html#pdf-package.preload">package.preload</A><BR>
+<A HREF="manual.html#pdf-package.searchpath">package.searchpath</A><BR>
<A HREF="manual.html#pdf-package.seeall">package.seeall</A><BR>
<P>
@@ -288,9 +301,10 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-table.concat">table.concat</A><BR>
<A HREF="manual.html#pdf-table.insert">table.insert</A><BR>
-<A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR>
+<A HREF="manual.html#pdf-table.pack">table.pack</A><BR>
<A HREF="manual.html#pdf-table.remove">table.remove</A><BR>
<A HREF="manual.html#pdf-table.sort">table.sort</A><BR>
+<A HREF="manual.html#pdf-table.unpack">table.unpack</A><BR>
</TD>
<TD>
@@ -308,21 +322,23 @@ Freely available under the terms of the
<A HREF="manual.html#lua_atpanic">lua_atpanic</A><BR>
<A HREF="manual.html#lua_call">lua_call</A><BR>
+<A HREF="manual.html#lua_callk">lua_callk</A><BR>
<A HREF="manual.html#lua_checkstack">lua_checkstack</A><BR>
<A HREF="manual.html#lua_close">lua_close</A><BR>
+<A HREF="manual.html#lua_compare">lua_compare</A><BR>
<A HREF="manual.html#lua_concat">lua_concat</A><BR>
-<A HREF="manual.html#lua_cpcall">lua_cpcall</A><BR>
+<A HREF="manual.html#lua_copy">lua_copy</A><BR>
<A HREF="manual.html#lua_createtable">lua_createtable</A><BR>
<A HREF="manual.html#lua_dump">lua_dump</A><BR>
-<A HREF="manual.html#lua_equal">lua_equal</A><BR>
<A HREF="manual.html#lua_error">lua_error</A><BR>
<A HREF="manual.html#lua_gc">lua_gc</A><BR>
<A HREF="manual.html#lua_getallocf">lua_getallocf</A><BR>
+<A HREF="manual.html#lua_getctx">lua_getctx</A><BR>
<A HREF="manual.html#lua_getfenv">lua_getfenv</A><BR>
<A HREF="manual.html#lua_getfield">lua_getfield</A><BR>
<A HREF="manual.html#lua_getglobal">lua_getglobal</A><BR>
-<A HREF="manual.html#lua_gethook">lua_gethook</A><BR>
<A HREF="manual.html#lua_gethookcount">lua_gethookcount</A><BR>
+<A HREF="manual.html#lua_gethook">lua_gethook</A><BR>
<A HREF="manual.html#lua_gethookmask">lua_gethookmask</A><BR>
<A HREF="manual.html#lua_getinfo">lua_getinfo</A><BR>
<A HREF="manual.html#lua_getlocal">lua_getlocal</A><BR>
@@ -344,15 +360,15 @@ Freely available under the terms of the
<A HREF="manual.html#lua_istable">lua_istable</A><BR>
<A HREF="manual.html#lua_isthread">lua_isthread</A><BR>
<A HREF="manual.html#lua_isuserdata">lua_isuserdata</A><BR>
-<A HREF="manual.html#lua_lessthan">lua_lessthan</A><BR>
+<A HREF="manual.html#lua_len">lua_len</A><BR>
<A HREF="manual.html#lua_load">lua_load</A><BR>
<A HREF="manual.html#lua_newstate">lua_newstate</A><BR>
<A HREF="manual.html#lua_newtable">lua_newtable</A><BR>
<A HREF="manual.html#lua_newthread">lua_newthread</A><BR>
<A HREF="manual.html#lua_newuserdata">lua_newuserdata</A><BR>
<A HREF="manual.html#lua_next">lua_next</A><BR>
-<A HREF="manual.html#lua_objlen">lua_objlen</A><BR>
<A HREF="manual.html#lua_pcall">lua_pcall</A><BR>
+<A HREF="manual.html#lua_pcallk">lua_pcallk</A><BR>
<A HREF="manual.html#lua_pop">lua_pop</A><BR>
<A HREF="manual.html#lua_pushboolean">lua_pushboolean</A><BR>
<A HREF="manual.html#lua_pushcclosure">lua_pushcclosure</A><BR>
@@ -369,10 +385,11 @@ Freely available under the terms of the
<A HREF="manual.html#lua_pushvalue">lua_pushvalue</A><BR>
<A HREF="manual.html#lua_pushvfstring">lua_pushvfstring</A><BR>
<A HREF="manual.html#lua_rawequal">lua_rawequal</A><BR>
-<A HREF="manual.html#lua_rawget">lua_rawget</A><BR>
<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>
-<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>
+<A HREF="manual.html#lua_rawget">lua_rawget</A><BR>
+<A HREF="manual.html#lua_rawlen">lua_rawlen</A><BR>
<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>
+<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>
<A HREF="manual.html#lua_register">lua_register</A><BR>
<A HREF="manual.html#lua_remove">lua_remove</A><BR>
<A HREF="manual.html#lua_replace">lua_replace</A><BR>
@@ -399,9 +416,13 @@ Freely available under the terms of the
<A HREF="manual.html#lua_touserdata">lua_touserdata</A><BR>
<A HREF="manual.html#lua_type">lua_type</A><BR>
<A HREF="manual.html#lua_typename">lua_typename</A><BR>
+<A HREF="manual.html#lua_upvalueid">lua_upvalueid</A><BR>
<A HREF="manual.html#lua_upvalueindex">lua_upvalueindex</A><BR>
+<A HREF="manual.html#lua_upvaluejoin">lua_upvaluejoin</A><BR>
+<A HREF="manual.html#lua_version">lua_version</A><BR>
<A HREF="manual.html#lua_xmove">lua_xmove</A><BR>
<A HREF="manual.html#lua_yield">lua_yield</A><BR>
+<A HREF="manual.html#lua_yieldk">lua_yieldk</A><BR>
</TD>
<TD>
@@ -430,12 +451,14 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_checkstring">luaL_checkstring</A><BR>
<A HREF="manual.html#luaL_checktype">luaL_checktype</A><BR>
<A HREF="manual.html#luaL_checkudata">luaL_checkudata</A><BR>
+<A HREF="manual.html#luaL_checkversion">luaL_checkversion</A><BR>
<A HREF="manual.html#luaL_dofile">luaL_dofile</A><BR>
<A HREF="manual.html#luaL_dostring">luaL_dostring</A><BR>
<A HREF="manual.html#luaL_error">luaL_error</A><BR>
<A HREF="manual.html#luaL_getmetafield">luaL_getmetafield</A><BR>
<A HREF="manual.html#luaL_getmetatable">luaL_getmetatable</A><BR>
<A HREF="manual.html#luaL_gsub">luaL_gsub</A><BR>
+<A HREF="manual.html#luaL_len">luaL_len</A><BR>
<A HREF="manual.html#luaL_loadbuffer">luaL_loadbuffer</A><BR>
<A HREF="manual.html#luaL_loadfile">luaL_loadfile</A><BR>
<A HREF="manual.html#luaL_loadstring">luaL_loadstring</A><BR>
@@ -452,8 +475,11 @@ Freely available under the terms of the
<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_register">luaL_register</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_typeerror">luaL_typeerror</A><BR>
<A HREF="manual.html#luaL_typename">luaL_typename</A><BR>
-<A HREF="manual.html#luaL_typerror">luaL_typerror</A><BR>
<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>
<A HREF="manual.html#luaL_where">luaL_where</A><BR>
@@ -465,10 +491,10 @@ Freely available under the terms of the
<HR>
<SMALL>
Last update:
-Fri Jan 8 16:29:00 BRST 2010
+Wed Jan 13 15:31:47 BRST 2010
</SMALL>
<!--
-Last change: fake for Lua 5.2.0-work1
+Last change: revised for Lua 5.2.0 (work2)
-->
</BODY>
diff --git a/doc/lua.css b/doc/lua.css
index 039cf116..40041a47 100644
--- a/doc/lua.css
+++ b/doc/lua.css
@@ -39,3 +39,8 @@ hr {
background-color: #a0a0a0 ;
}
+:target {
+ background-color: #F8F8F8 ;
+ padding: 8px ;
+ border: solid #a0a0a0 2px ;
+}
diff --git a/doc/manual.css b/doc/manual.css
new file mode 100644
index 00000000..eed5afd9
--- /dev/null
+++ b/doc/manual.css
@@ -0,0 +1,13 @@
+h3 code {
+ font-family: inherit ;
+}
+
+pre {
+ font-size: 105% ;
+}
+
+span.apii {
+ float: right ;
+ font-family: inherit ;
+}
+
diff --git a/doc/manual.html b/doc/manual.html
index 83d2bb09..6ebd0740 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -1,31 +1,39 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Lua 5.2 Reference Manual</title>
-<link rel="stylesheet" href="lua.css">
+<link rel="stylesheet" type="text/css" href="lua.css">
+<link rel="stylesheet" type="text/css" href="manual.css">
+<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
</head>
-<body bgcolor="#FFFFFF">
+<body>
<hr>
<h1>
-<a href="http://www.lua.org/home.html"><img src="logo.gif" alt="[Lua logo]" border="0"></a>
+<a href="http://www.lua.org/"><img src="logo.gif" alt="" border="0"></a>
Lua 5.2 Reference Manual
</h1>
by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
<p>
<small>
-<a href="http://www.lua.org/copyright.html">Copyright</a>
-&copy; 2010 Lua.org, PUC-Rio. All rights reserved.
+Copyright &copy; 2010 Lua.org, PUC-Rio.
+Freely available under the terms of the
+<a href="http://www.lua.org/license.html#5">Lua license</a>.
</small>
<hr>
+<p>
+
+<a href="contents.html#contents">contents</A>
+&middot;
+<a href="contents.html#index">index</A>
<!-- ====================================================================== -->
<p>
-<!-- $Id: manual.of,v 1.53 2010/01/08 18:18:46 roberto Exp roberto $ -->
+<!-- $Id: manual.of,v 1.54 2010/01/13 16:50:58 roberto Exp roberto $ -->
@@ -166,10 +174,12 @@ and can contain the following C-like escape sequences:
and '<code>\'</code>' (apostrophe [single quote]).
Moreover, a backslash followed by a real newline
results in a newline in the string.
-A character in a string can also be specified by its numerical value
-using the escape sequence <code>\<em>ddd</em></code>,
+A character in a string can also be specified by its numerical value.
+This can be done with the escape sequence <code>\x<em>XX</em></code>,
+where <em>XX</em> is a sequence of exactly two hexadecimal digits,
+and with the escape sequence <code>\<em>ddd</em></code>,
where <em>ddd</em> is a sequence of up to three decimal digits.
-(Note that if a numerical escape is to be followed by a digit,
+(Note that if a decimal escape is to be followed by a digit,
it must be expressed using exactly three digits.)
Strings in Lua can contain any 8-bit value, including embedded zeros,
which can be specified as '<code>\0</code>'.
@@ -2053,7 +2063,8 @@ the speed of memory allocation.
<p>
If you set the step multiplier to a very large number
-(such as <em>2^30</em>),
+(larger than 10% of the maximum number of
+bytes that the program may use),
the collector behaves like a stop-the-world collector.
If you then set the pause to 200,
the collector behaves as in old Lua versions,
@@ -5104,6 +5115,15 @@ will return identical ids for those upvalue indices.
+<hr><h3><a name="lua_upvaluejoin"><code>lua_upvaluejoin</code></a></h3>
+<pre>void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
+ int fidx2, int n2);</pre><p>
+TO BE DONE!!
+
+
+
+
+
<h1>4 - <a name="4">The Auxiliary Library</a></h1>
@@ -6000,10 +6020,33 @@ it returns <code>NULL</code> instead of throwing an error.
+<hr><h3><a name="luaL_tolstring"><code>luaL_tolstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>e</em>]</span>
+<pre>const char *luaL_tolstring (lua_State *L, int idx, size_t *len);</pre>
+
+<p>
+Converts any Lua value at the given acceptable index to a C&nbsp;string
+in a reasonable format.
+The resulting string is pushed onto the stack and also
+returned by the function.
+If <code>len</code> is not <code>NULL</code>,
+the function also sets <code>*len</code> with the string length.
+
+
+<p>
+If the value has a metatable with a <code>"__tostring"</code> field,
+then <code>luaL_tolstring</code> calls the corresponding metamethod
+with the value as argument,
+and uses the result of the call as its result.
+
+
+
+
+
<hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p>
<span class="apii">[-0, +1, <em>m</em>]</span>
-<pre>luaL_traceback (lua_State *L, lua_State *L1,
- const char *msg, int level);</pre>
+<pre>void luaL_traceback (lua_State *L, lua_State *L1,
+ const char *msg, int level);</pre>
<p>
Creates and pushes a traceback of the stack <code>L1</code>.
@@ -7111,22 +7154,23 @@ A path is string containing a sequence of
<em>templates</em> separated by semicolons.
For each template,
the function changes each interrogation
-mark in the template by <code>name</code>,
+mark in the template by a copy of <code>name</code>
+wherein all dots were replaced by the system's directory separator,
and then tries to open the resulting file name.
For instance, if the path is the string
<pre>
"./?.lua;./?.lc;/usr/local/?/init.lua"
</pre><p>
-the search for name <code>foo</code>
+the search for the name <code>foo.a</code>
will try to open the files
-<code>./foo.lua</code>, <code>./foo.lc</code>, and
-<code>/usr/local/foo/init.lua</code>, in that order.
+<code>./foo/a.lua</code>, <code>./foo/a.lc</code>, and
+<code>/usr/local/foo/a/init.lua</code>, in that order.
<p>
Returns the resulting name of the first file that it can
-open in read mode (after closing it),
+open in read mode (after closing the file),
or <b>nil</b> plus an error message if none succeeds.
(This error message lists all file names it tried to open.)
@@ -7950,7 +7994,7 @@ Returns <em>m2<sup>e</sup></em> (<code>e</code> should be an integer).
<p>
Returns the logarithm of <code>x</code> in the given base.
-The default for <code>base</code> is $e$
+The default for <code>base</code> is <em>e</em>
(so that the function returns the natural logarithm of <code>x</code>).
@@ -9140,6 +9184,36 @@ to start the traceback
+<p>
+<hr><h3><a name="pdf-debug.upvalueid"><code>debug.upvalueid (function, n)</code></a></h3>
+
+
+<p>
+Returns an unique identifier (as a light userdata)
+for the upvalue numbered <code>n</code>
+from the given function.
+
+
+<p>
+These unique identifiers allow a program to check whether different
+closures share upvalues.
+Lua closures that share an upvalue
+(that is, that access a same external local variable)
+will return identical ids for those upvalue indices.
+
+
+
+
+<p>
+<hr><h3><a name="pdf-debug.upvaluejoin"><code>debug.upvaluejoin ()</code></a></h3>
+
+
+<p>
+TO BE DONE!!
+
+
+
+
@@ -9319,7 +9393,7 @@ Weak tables with weak keys now perform like <em>ephemeron tables</em>.
<li>
Threads do not have individual environments.
-All threads share a sinle fixed environment.
+All threads share a single fixed environment.
</li>
</ul>
@@ -9367,7 +9441,7 @@ and therefore must be called as <a href="#pdf-table.unpack"><code>table.unpack</
<ul>
<li>
-Pseudoindex <code>LUA_GLOBALSINDEX</code> was deprecated.
+Pseudoindex <code>LUA_GLOBALSINDEX</code> was removed.
You may use the pseudoindex <a href="#pdf-LUA_ENVIRONINDEX"><code>LUA_ENVIRONINDEX</code></a> instead,
if the C&nbsp;function does not change its standard environment.
Otherwise, you should get the global environment from the registry
@@ -9484,5 +9558,15 @@ Here is the complete syntax of Lua in extended BNF.
+
+<HR>
+<SMALL>
+Last update:
+Wed Jan 13 15:29:29 BRST 2010
+</SMALL>
+<!--
+Last change: revised for Lua 5.2.0 (work2)
+-->
+
</body></html>
diff --git a/doc/readme.html b/doc/readme.html
index 7640d3af..6d9e601e 100644
--- a/doc/readme.html
+++ b/doc/readme.html
@@ -21,6 +21,13 @@ blockquote, .display {
padding-right: 15px;
background: transparent url(external.png) no-repeat center right;
}
+
+tt, kbd {
+ font-size: 120% ;
+ xcolor: black ;
+ xpadding: 4px ;
+ xbackground-color: #E0E0E0 ;
+}
</STYLE>
</HEAD>
@@ -80,7 +87,6 @@ distributed in this package.
<P>
<H2><A NAME="install">Installing Lua</A></H2>
-<DIV CLASS="review">how much detail?</DIV><P>
Lua is distributed in source form.
You need to build it before using it.
@@ -100,7 +106,7 @@ See below for
<H3>Building Lua</H3>
-In most Unix-like platforms, simply do "make" with a suitable target.
+In most Unix-like platforms, simply do "<KBD>make</KBD>" with a suitable target.
Here are the details.
<P>
@@ -111,13 +117,13 @@ the top-level directory, which is named lua-5.2.
The Makefile there controls both the build process and the installation process.
<P>
<LI>
- Do "make" and see if your platform is listed.
+ Do "<KBD>make</KBD>" and see if your platform is listed.
The platforms currently supported are:
<BLOCKQUOTE>
aix ansi bsd freebsd generic linux macosx mingw posix solaris
</BLOCKQUOTE>
<P>
- If your platform is listed, just do "make xxx", where xxx
+ If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
is your platform name.
<P>
If your platform is not listed, try the closest one or posix, generic,
@@ -131,7 +137,7 @@ luac (the compiler),
and liblua.a (the library).
<P>
<LI>
- If you want to check that Lua has been built correctly, do "make test"
+ If you want to check that Lua has been built correctly, do "<KBD>make test</KBD>"
after building Lua. This will run the interpreter on a "hello world"
Lua program from the test directory.
You may want to try other example programs in that directory.
@@ -140,19 +146,19 @@ and liblua.a (the library).
<H3>Installing Lua</H3>
Once you have built Lua, you may want to install it in an official
- place in your system. In this case, do "make install". The official
+ place in your system. In this case, do "<KBD>make install</KBD>". The official
place and the way to install files are defined in Makefile. You'll
probably need the right permissions to install files.
<P>
- If you want to build and install Lua in one step, do <SPAN CLASS="display">"make xxx install"</SPAN>,
+ If you want to build and install Lua in one step, do "<KBD>make xxx install</KBD>",
where xxx is your platform name.
<P>
- If you want to install Lua locally, then do "make local". This will
- create directories bin, include, lib, man, and install Lua there as
- follows:
- <SPAN CLASS="review">review!</SPAN>
+ If you want to install Lua locally, then do "<KBD>make local</KBD>".
+ This will create a directory <TT>install</TT> with subdirectories
+ <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>,
+ and install Lua there as follows:
<P>
<DL CLASS="display">
@@ -185,15 +191,15 @@ and liblua.a (the library).
<P>
If you want to install Lua locally, but in some other directory, do
- "make install INSTALL_TOP=xxx", where xxx is your chosen directory.
+ "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
<P>
<H3><A NAME="customization">Customization</A></H3>
Three kinds of things can be customized by editing a file:
<UL>
- <LI> Where and how to install Lua &ndash; edit Makefile.
- <LI> How to build Lua &ndash; edit src/Makefile.
- <LI> Lua features &ndash; edit src/luaconf.h.
+ <LI> Where and how to install Lua &mdash; edit Makefile.
+ <LI> How to build Lua &mdash; edit src/Makefile.
+ <LI> Lua features &mdash; edit src/luaconf.h.
</UL>
<P>
@@ -205,6 +211,7 @@ and liblua.a (the library).
to edit src/luaconf.h before building and installing Lua.
The edited file will be the one installed, and
it will be used by any Lua clients that you build, to ensure consistency.
+ (Further customization is possible by editing the Lua sources.)
<P>
We strongly recommend that you enable dynamic loading. This is done
@@ -223,11 +230,11 @@ and liblua.a (the library).
<DT>
library:
<DD>
- lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
- lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c
- ltable.c ltm.c lundump.c lvm.c lzio.c
- lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c
- ltablib.c lstrlib.c loadlib.c linit.c
+lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
+lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
+ltm.c lundump.c lvm.c lzio.c
+lauxlib.c lbaselib.c lbitlib.c ldblib.c liolib.c lmathlib.c loslib.c
+ltablib.c lstrlib.c loadlib.c linit.c
<DT>
interpreter:
<DD>
@@ -238,12 +245,12 @@ compiler:
library, luac.c print.c
</DL>
- If you use Visual Studio .NET, you can use etc/luavs.bat in its
+ If you use Visual Studio .NET, you can use <TT>etc/luavs.bat</TT> in its
"Command Prompt".
<P>
If all you want is to build the Lua interpreter, you may put all .c files
- in a single project, except for luac.c and print.c. Or just use etc/all.c.
+ in a single project, except for luac.c and print.c. Or just use <TT>etc/one.c</TT>.
<P>
To use Lua as a library in your own programs you'll need to know how to
@@ -254,7 +261,7 @@ compiler:
into each dynamic library. For Unix, we recommend that the Lua library
be linked statically into the host program and its symbols exported for
dynamic linking; src/Makefile does this for the Lua interpreter.
- For Windows, we recommend that the Lua library be DLL.
+ For Windows, we recommend that the Lua library be a DLL.
<P>
As mentioned above, you may edit src/luaconf.h to customize
@@ -262,10 +269,9 @@ compiler:
<P>
<H2><A NAME="changes">Changes since Lua 5.1</A></H2>
-<DIV CLASS="review">incomplete!</DIV><P>
Here are the main changes in Lua since its last release.
-The
+The
<A HREF="contents.html">reference manual</A>
lists the
<A HREF="manual.html#7">incompatibilities</A> that had to be introduced.
@@ -274,15 +280,32 @@ lists the
<H3>Language</H3>
<UL>
<LI> new lexical environments.
+<LI> no more fenv for threads.
+<LI> ephemeron tables.
+<LI> yieldable pcall/metamethods.
+<LI> tables honor the <CODE>__len</CODE> metamethod.
+<LI> max constants per function raised to 2^26.
<LI> hex escapes in strings.
-<LI> tables and strings honor the <CODE>__len</CODE> metamethod.
+<LI> no more verification of opcode consistency.
+
</UL>
<H3>Libraries</H3>
<UL>
-<LI> new function <CODE>package.searchpath</CODE>.
+<LI> new library for bitwise operations.
<LI> new metamethods <CODE>__pairs</CODE> and <CODE>__ipairs</CODE>.
<LI> arguments for function called through <CODE>xpcall</CODE>.
+<LI> optional argument to load (to control binary x text).
+<LI> <CODE>loadlib</CODE> may load libraries with global names (RTLD_GLOBAL).
+<LI> new function <CODE>package.searchpath</CODE>.
+<LI> optional base in <CODE>math.log</CODE>.
+<LI> <CODE>file:write</CODE> returns file.
+<LI> closing a pipe returns exit status.
+<LI> <CODE>os.exit</CODE> may close state.
+<LI> new option 'isrunning' for <CODE>collectgarbage</CODE> and <CODE>lua_gc</CODE>.
+<LI> frontier patterns.
+<LI> <CODE>ipairs</CODE> now goes until #t.
+
</UL>
<H3>Implementation</H3>
@@ -291,9 +314,12 @@ lists the
(core forces a full collection when allocation fails).
<LI> ephemeron tables
(tables with weak keys only visit value when key is accessible)
-<LI> handling of non-string error messages.
+<LI> handling of non-string error messages in the standalone interpreter.
<LI> udata with finalizers are kept in a separated list for the GC.
-<SPAN CLASS="review">relevant?</SPAN>
+<LI> CallInfo stack now is a linked list.
+<LI> internal (immutable) version of ctypes.
+<LI> parser uses much less C-stack space (no more auto arrays).
+<LI> new hash for floats.
</UL>
@@ -317,7 +343,7 @@ For details and rationale, see
<P>
<BLOCKQUOTE>
-Copyright &copy; 1994-2010 Lua.org, PUC-Rio.
+Copyright &copy; 1994&ndash;2010 Lua.org, PUC-Rio.
<P>
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -346,8 +372,11 @@ THE SOFTWARE.
<HR>
<SMALL>
Last update:
-Fri Jan 8 16:41:16 BRST 2010
+Wed Jan 13 15:35:05 BRST 2010
</SMALL>
+<!--
+Last change: revised for Lua 5.2.0 (work2)
+-->
</BODY>
</HTML>
diff --git a/etc/Makefile b/etc/Makefile
index 6d00008d..5f6ed872 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -9,7 +9,7 @@ TST= $(TOP)/test
CC= gcc
CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS)
-MYCFLAGS=
+MYCFLAGS=
MYLDFLAGS= -Wl,-E
MYLIBS= -lm
#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
@@ -21,6 +21,8 @@ default:
min: min.c
$(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)
echo 'print"Hello there!"' | ./a.out
+ ./a.out $(TST)/hello.lua
+ echo 'print("Hello world, from",_VERSION,"!")' | ./a.out
noparser: noparser.o
$(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS)
@@ -29,7 +31,7 @@ noparser: noparser.o
-./a.out -e'a=1'
one:
- $(CC) $(CFLAGS) all.c $(MYLIBS)
+ $(CC) $(CFLAGS) one.c $(MYLIBS)
./a.out $(TST)/hello.lua
strict:
diff --git a/etc/README b/etc/README
index 99cbb523..300257ae 100644
--- a/etc/README
+++ b/etc/README
@@ -1,10 +1,10 @@
This directory contains some useful files and code.
Unlike the code in ../src, everything here is in the public domain.
-If any of the makes fail, you're probably not using the same libraries
-used to build Lua. Set MYLIBS in Makefile or in the command line accordingly.
+If any of the makes fail, you're probably not using the same libraries used
+to build Lua. Set MYLIBS in Makefile or in the command line accordingly.
-all.c
+one.c
Full Lua interpreter in a single file.
Do "make one" for a demo.
diff --git a/etc/luavs.bat b/etc/luavs.bat
index 08c2bedd..14518713 100644
--- a/etc/luavs.bat
+++ b/etc/luavs.bat
@@ -1,6 +1,6 @@
-@rem Script to build Lua under "Visual Studio .NET Command Prompt".
+@rem Script to build Lua 5.2 under "Visual Studio .NET Command Prompt".
@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat .
-@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src.
+@rem It creates lua52.dll, lua52.lib, lua.exe, and luac.exe in src.
@rem (contributed by David Manura and Mike Pall)
@setlocal
@@ -11,11 +11,11 @@
cd src
%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
-%MYLINK% /DLL /out:lua51.dll l*.obj
-if exist lua51.dll.manifest^
- %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2
+%MYLINK% /DLL /out:lua52.dll l*.obj
+if exist lua52.dll.manifest^
+ %MYMT% -manifest lua52.dll.manifest -outputresource:lua52.dll;2
%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c
-%MYLINK% /out:lua.exe lua.obj lua51.lib
+%MYLINK% /out:lua.exe lua.obj lua52.lib
if exist lua.exe.manifest^
%MYMT% -manifest lua.exe.manifest -outputresource:lua.exe
%MYCOMPILE% l*.c print.c
diff --git a/etc/min.c b/etc/min.c
index 81e3b73d..0b6a5c32 100644
--- a/etc/min.c
+++ b/etc/min.c
@@ -1,6 +1,6 @@
/*
* min.c -- a minimal Lua interpreter
-* runs one file from the command line or stdin if none given.
+* runs one file from the command line or stdin if no file given.
* minimal error handling, no traceback, no interaction, no standard library,
* only a "print" function.
*/
@@ -15,22 +15,19 @@ static int print(lua_State *L)
{
int n=lua_gettop(L);
int i;
- const char *s="";
for (i=1; i<=n; i++)
- {
- printf("%s%s",s,luaL_tolstring(L,i,NULL));
- s="\t";
- }
+ printf("%s ",luaL_tolstring(L,i,NULL));
printf("\n");
return 0;
}
int main(int argc, char *argv[])
{
- lua_State *L=lua_open();
- lua_register(L,"print",print);
+ lua_State *L=luaL_newstate();
luaL_openlibs(L);
- if (luaL_dofile(L,argv[1])!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
+ lua_register(L,"print",print);
+ if (luaL_dofile(L,argv[1])!=0)
+ fprintf(stderr,"%s: %s\n",argv[0],lua_tostring(L,-1));
lua_close(L);
return 0;
}
diff --git a/etc/noparser.c b/etc/noparser.c
index 5e0e2031..f1fd4aea 100644
--- a/etc/noparser.c
+++ b/etc/noparser.c
@@ -34,7 +34,7 @@ LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Varlist *varl
UNUSED(z);
UNUSED(buff);
UNUSED(name);
- lua_pushliteral(L,"parser not loaded");
+ lua_pushliteral(L,"parser not available");
lua_error(L);
return NULL;
}
@@ -49,7 +49,7 @@ LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data,
UNUSED(w);
UNUSED(data);
UNUSED(strip);
- lua_pushliteral(L,"dumper not loaded");
+ lua_pushliteral(L,"dumper not available");
lua_error(L);
return 0;
}
@@ -63,7 +63,7 @@ LUAI_FUNC Proto *luaU_undump (lua_State *L, ZIO *z, Mbuffer *buff, const char *n
UNUSED(z);
UNUSED(buff);
UNUSED(name);
- lua_pushliteral(L,"cannot load binary chunks");
+ lua_pushliteral(L,"binary loader not available");
lua_error(L);
return NULL;
}
diff --git a/etc/all.c b/etc/one.c
index a7f21b7d..be1f3a40 100644
--- a/etc/all.c
+++ b/etc/one.c
@@ -1,5 +1,5 @@
/*
-* all.c -- Lua core, libraries, and interpreter in a single file
+* one.c -- Lua core, libraries, and interpreter in a single file
*/
/* default is to build the full interpreter */
diff --git a/etc/strict.lua b/etc/strict.lua
index 604619dd..5ce1aa85 100644
--- a/etc/strict.lua
+++ b/etc/strict.lua
@@ -6,6 +6,7 @@
-- anywhere or assigned to inside a function.
--
+require"debug"
local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
local mt = getmetatable(_G)
diff --git a/src/lapi.c b/src/lapi.c
index b822a725..56c0c1e9 100644
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.109 2010/01/08 15:16:56 roberto Exp $
+** $Id: lapi.c,v 2.111 2010/01/13 16:18:25 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -255,7 +255,7 @@ LUA_API int lua_type (lua_State *L, int idx) {
LUA_API const char *lua_typename (lua_State *L, int t) {
UNUSED(L);
- return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ return typename(t);
}
@@ -300,7 +300,8 @@ LUA_API void lua_arith (lua_State *L, int op) {
luaO_arith(op, nvalue(L->top - 2), nvalue(L->top - 1)));
}
else
- luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD);
+ luaV_arith(L, L->top - 2, L->top - 2, L->top - 1,
+ cast(TMS, op - LUA_OPADD + TM_ADD));
L->top--;
lua_unlock(L);
}
diff --git a/src/lauxlib.h b/src/lauxlib.h
index d0143481..b8f2e2e5 100644
--- a/src/lauxlib.h
+++ b/src/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.98 2010/01/06 15:14:15 roberto Exp $
+** $Id: lauxlib.h,v 1.99 2010/01/11 16:00:45 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -29,8 +29,6 @@ typedef struct luaL_Reg {
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
-LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
- const luaL_Reg *l, int nup);
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l);
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
diff --git a/src/lbitlib.c b/src/lbitlib.c
index 5b6a6aae..1d5a2642 100644
--- a/src/lbitlib.c
+++ b/src/lbitlib.c
@@ -1,9 +1,12 @@
/*
-** $Id: lbitlib.c,v 1.2 2009/11/24 12:05:44 roberto Exp $
+** $Id: lbitlib.c,v 1.3 2010/01/12 19:40:02 roberto Exp $
** Standard library for bitwise operations
** See Copyright Notice in lua.h
*/
+#define lbitlib_c
+#define LUA_LIB
+
#include "lua.h"
#include "lauxlib.h"
diff --git a/src/lcode.c b/src/lcode.c
index 4f10e095..c55ebd54 100644
--- a/src/lcode.c
+++ b/src/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.42 2009/09/23 20:33:05 roberto Exp $
+** $Id: lcode.c,v 2.43 2010/01/11 17:38:30 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -830,15 +830,15 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
}
case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
case OPR_MOD: case OPR_POW: {
- codearith(fs, op - OPR_ADD + OP_ADD, e1, e2);
+ codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2);
break;
}
case OPR_EQ: case OPR_LT: case OPR_LE: {
- codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2);
+ codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2);
break;
}
case OPR_NE: case OPR_GT: case OPR_GE: {
- codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2);
+ codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2);
break;
}
default: lua_assert(0);
diff --git a/src/ldebug.c b/src/ldebug.c
index 1c18d701..2544a5dd 100644
--- a/src/ldebug.c
+++ b/src/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.61 2010/01/06 14:42:35 roberto Exp $
+** $Id: ldebug.c,v 2.63 2010/01/13 16:18:25 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -363,7 +363,7 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg,
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
- TMS tm = 0;
+ TMS tm;
Instruction i;
if ((ci->callstatus & CIST_TAIL) || !isLua(ci->previous))
return NULL; /* calling function is not Lua (or is unknown) */
@@ -416,7 +416,7 @@ static int isinstack (CallInfo *ci, const TValue *o) {
void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
CallInfo *ci = L->ci;
const char *name = NULL;
- const char *t = luaT_typenames[ttype(o)];
+ const char *t = typename(ttype(o));
const char *kind = (isLua(ci) && isinstack(ci, o)) ?
getobjname(L, ci, cast_int(o - ci->u.l.base), &name) :
NULL;
@@ -444,9 +444,9 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
- const char *t1 = luaT_typenames[ttype(p1)];
- const char *t2 = luaT_typenames[ttype(p2)];
- if (t1[2] == t2[2])
+ const char *t1 = typename(ttype(p1));
+ const char *t2 = typename(ttype(p2));
+ if (t1 == t2)
luaG_runerror(L, "attempt to compare two %s values", t1);
else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
diff --git a/src/ldo.c b/src/ldo.c
index 555113d3..4890ce21 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.79 2009/12/22 15:32:50 roberto Exp $
+** $Id: ldo.c,v 2.80 2010/01/13 16:17:32 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -554,8 +554,12 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
luai_userstateyield(L, nresults);
lua_lock(L);
api_checknelems(L, nresults);
- if (L->nny > 0)
- luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
+ if (L->nny > 0) {
+ if (L != G(L)->mainthread)
+ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
+ else
+ luaG_runerror(L, "attempt to yield from outside a coroutine");
+ }
L->status = LUA_YIELD;
if (isLua(ci)) { /* inside a hook? */
api_check(L, k == NULL, "hooks cannot continue after yielding");
diff --git a/src/loadlib.c b/src/loadlib.c
index 8b2d6911..90c785dc 100644
--- a/src/loadlib.c
+++ b/src/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.73 2010/01/06 14:35:17 roberto Exp $
+** $Id: loadlib.c,v 1.80 2010/01/13 16:30:27 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -129,9 +129,18 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
** =======================================================================
*/
+#include <windows.h>
#undef setprogdir
+/*
+** optional flags for LoadLibraryEx
+*/
+#if !defined(LUA_LLE_FLAGS)
+#define LUA_LLE_FLAGS 0
+#endif
+
+
static void setprogdir (lua_State *L) {
char buff[MAX_PATH + 1];
char *lb;
@@ -158,12 +167,12 @@ static void pusherror (lua_State *L) {
}
static void ll_unloadlib (void *lib) {
- FreeLibrary((HINSTANCE)lib);
+ FreeLibrary((HMODULE)lib);
}
static void *ll_load (lua_State *L, const char *path, int seeglb) {
- HINSTANCE lib = LoadLibrary(path);
+ HMODULE lib = LoadLibraryEx(path, NULL, LUA_LLE_FLAGS);
(void)(seeglb); /* symbols are 'global' by default? */
if (lib == NULL) pusherror(L);
return lib;
@@ -171,7 +180,7 @@ static void *ll_load (lua_State *L, const char *path, int seeglb) {
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
- lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym);
+ lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
if (f == NULL) pusherror(L);
return f;
}
@@ -344,7 +353,9 @@ static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
lua_CFunction f = ll_sym(L, *reg, sym);
if (f == NULL)
return ERRFUNC; /* unable to find function */
- lua_pushcfunction(L, f); /* else return function */
+ lua_pushcfunction(L, f); /* else create new function... */
+ lua_pushglobaltable(L); /* ... and set the standard global table... */
+ lua_setfenv(L, -2); /* ... as its environment */
return 0; /* no errors */
}
}
@@ -394,6 +405,7 @@ static const char *pushnexttemplate (lua_State *L, const char *path) {
static const char *searchpath (lua_State *L, const char *name,
const char *path) {
+ name = luaL_gsub(L, name, ".", LUA_DIRSEP);
lua_pushliteral(L, ""); /* error accumulator */
while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename = luaL_gsub(L, lua_tostring(L, -1),
@@ -423,7 +435,6 @@ static int ll_searchpath (lua_State *L) {
static const char *findfile (lua_State *L, const char *name,
const char *pname) {
const char *path;
- name = luaL_gsub(L, name, ".", LUA_DIRSEP);
lua_getfield(L, LUA_ENVIRONINDEX, pname);
path = lua_tostring(L, -1);
if (path == NULL)
@@ -449,13 +460,20 @@ static int loader_Lua (lua_State *L) {
}
-static int loadfunc(lua_State *L, const char *filename, const char *modname) {
+static int loadfunc (lua_State *L, const char *filename, const char *modname) {
const char *funcname;
- const char *mark = strchr(modname, *LUA_IGMARK);
- if (mark) modname = mark + 1;
- funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
- funcname = lua_pushfstring(L, POF"%s", funcname);
- lua_remove(L, -2); /* remove 'gsub' result */
+ const char *mark;
+ modname = luaL_gsub(L, modname, ".", LUA_OFSEP);
+ mark = strchr(modname, *LUA_IGMARK);
+ if (mark) {
+ int stat;
+ funcname = lua_pushlstring(L, modname, mark - modname);
+ funcname = lua_pushfstring(L, POF"%s", funcname);
+ stat = ll_loadfunc(L, filename, funcname);
+ if (stat != ERRFUNC) return stat;
+ modname = mark + 1; /* else go ahead and try old-style name */
+ }
+ funcname = lua_pushfstring(L, POF"%s", modname);
return ll_loadfunc(L, filename, funcname);
}
diff --git a/src/ltablib.c b/src/ltablib.c
index b2360807..6ad6b8e0 100644
--- a/src/ltablib.c
+++ b/src/ltablib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.53 2009/12/28 16:30:31 roberto Exp $
+** $Id: ltablib.c,v 1.54 2010/01/13 19:59:10 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -178,6 +178,8 @@ static int pack (lua_State *L) {
for (; top >= 1; top--) /* assign elements */
lua_rawseti(L, LUA_ENVIRONINDEX, top);
lua_pushvalue(L, LUA_ENVIRONINDEX); /* return new table */
+ /* remove new table from environment to allow its later collection */
+ lua_copy(L, LUA_REGISTRYINDEX, LUA_ENVIRONINDEX);
return 1;
}
diff --git a/src/ltm.c b/src/ltm.c
index cf675652..3a9e73ca 100644
--- a/src/ltm.c
+++ b/src/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.10 2009/11/19 19:06:52 roberto Exp $
+** $Id: ltm.c,v 2.11 2010/01/13 16:18:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -19,10 +19,12 @@
#include "ltm.h"
+static const char udatatypename[] = "userdata";
-LUAI_DDEF const char *const luaT_typenames[] = {
- "nil", "boolean", "userdata", "number",
- "string", "table", "function", "userdata", "thread",
+LUAI_DDEF const char *const luaT_typenames_[] = {
+ "no value",
+ "nil", "boolean", udatatypename, "number",
+ "string", "table", "function", udatatypename, "thread",
"proto", "upval"
};
diff --git a/src/ltm.h b/src/ltm.h
index ba935d49..732aa12d 100644
--- a/src/ltm.h
+++ b/src/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.8 2009/11/19 19:06:52 roberto Exp $
+** $Id: ltm.h,v 2.9 2010/01/13 16:18:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -43,7 +43,9 @@ typedef enum {
#define fasttm(l,et,e) gfasttm(G(l), et, e)
-LUAI_DDEC const char *const luaT_typenames[];
+#define typename(x) luaT_typenames_[(x) + 1]
+
+LUAI_DDEC const char *const luaT_typenames_[];
LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
diff --git a/src/lua.h b/src/lua.h
index b86ac6cf..f79df970 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.260 2010/01/06 15:08:00 roberto Exp $
+** $Id: lua.h,v 1.261 2010/01/11 17:15:11 roberto Exp $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
#define LUA_VERSION "Lua 5.2"
-#define LUA_RELEASE "Lua 5.2.0 (work1)"
+#define LUA_RELEASE "Lua 5.2.0 (work2)"
#define LUA_VERSION_NUM 502
-#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2008 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2010 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
@@ -395,7 +395,7 @@ struct lua_Debug {
/******************************************************************************
-* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
+* Copyright (C) 1994-2010 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
diff --git a/src/luaconf.h b/src/luaconf.h
index 9cd0beb2..b16e9991 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.127 2010/01/06 15:15:04 roberto Exp $
+** $Id: luaconf.h,v 1.130 2010/01/11 17:15:30 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -34,7 +34,6 @@
#endif
#if defined(LUA_WIN)
-#include <windows.h>
#define LUA_DL_DLL
#endif
@@ -92,8 +91,8 @@
#else
#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#define LUA_LDIR LUA_ROOT "share/lua/5.2/"
+#define LUA_CDIR LUA_ROOT "lib/lua/5.2/"
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"
@@ -440,8 +439,9 @@ LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
/* On a Microsoft compiler, use assembler */
#if defined(_MSC_VER)
-#define lua_number2int(i,d) __asm fld d __asm fistp i
+#define lua_number2int(i,d) {__asm fld d __asm fistp i}
#define lua_number2integer(i,n) lua_number2int(i, n)
+#define lua_number2uint(i,n) lua_number2int(i, n)
#else
/* the next trick should work on any Pentium, but sometimes clashes