Merged in changes from Lua 5.1.2 (hopefully didn't miss anything)

Originally committed to SVN as r980.
This commit is contained in:
Niels Martin Hansen 2007-04-03 00:37:09 +00:00
parent 292ad1af33
commit 325b88df19
28 changed files with 5411 additions and 2977 deletions

View file

@ -2,27 +2,59 @@
<HEAD> <HEAD>
<TITLE>Lua 5.1 reference manual - contents</TITLE> <TITLE>Lua 5.1 reference manual - contents</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css"> <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
<STYLE TYPE="text/css">
ul {
list-style-type: none ;
list-style-position: outside ;
}
</STYLE>
</HEAD> </HEAD>
<BODY BGCOLOR="#FFFFFF"> <BODY>
<HR> <HR>
<H1> <H1>
<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A> <A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="" BORDER=0></A>
Lua 5.1 Reference Manual Lua 5.1 Reference Manual
</H1> </H1>
<SMALL> This is an online version of
<A HREF="http://www.lua.org/copyright.html">Copyright</A> <BLOCKQUOTE>
&copy; 2006 Lua.org, PUC-Rio. All rights reserved. <A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
</SMALL> <IMG SRC="cover.png" ALT="" TITLE="buy from Amazon" BORDER=1 ALIGN="left" HSPACE=12>
<HR> </A>
<B>Lua 5.1 Reference Manual</B>
<H2>Contents</H2> <BR>by R. Ierusalimschy, L. H. de Figueiredo, W. Celes
<UL> <BR>Lua.org, August 2006
<LI><A HREF="#quick">Quick index</A> <BR>ISBN 85-903798-3-3
<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
<IMG SRC="amazon.gif" ALT="[Buy from Amazon]" BORDER=0></A>
<BR CLEAR="all">
</BLOCKQUOTE>
<P> <P>
<LI><A HREF="manual.html">Top</A>
Buy a paper copy and
<A HREF="http://www.lua.org/donations.html">help to support</A>
the Lua project.
<P>
<A HREF="manual.html">start</A>
&middot;
<A HREF="#contents">contents</A>
&middot;
<A HREF="#index">index</A>
&middot;
<A HREF="http://www.lua.org/manual/5.1/errata.html">errata</A>
<HR>
<SMALL>
Copyright &copy; 2006-2007 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html#5">Lua license</a>.
</SMALL>
<P>
<H2><A NAME="contents">Contents</A></H2>
<UL style="padding: 0">
<LI><A HREF="manual.html#1">1 - Introduction</A> <LI><A HREF="manual.html#1">1 - Introduction</A>
<LI><A HREF="manual.html#2">2 - The Language</A> <LI><A HREF="manual.html#2">2 - The Language</A>
<UL> <UL>
@ -86,6 +118,9 @@ Lua 5.1 Reference Manual
<LI><A HREF="manual.html#5.2">5.2 - Coroutine Manipulation</A> <LI><A HREF="manual.html#5.2">5.2 - Coroutine Manipulation</A>
<LI><A HREF="manual.html#5.3">5.3 - Modules</A> <LI><A HREF="manual.html#5.3">5.3 - Modules</A>
<LI><A HREF="manual.html#5.4">5.4 - String Manipulation</A> <LI><A HREF="manual.html#5.4">5.4 - String Manipulation</A>
<UL>
<LI><A HREF="manual.html#5.4.1">5.4.1 - Patterns</A>
</UL>
<LI><A HREF="manual.html#5.5">5.5 - Table Manipulation</A> <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.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.7">5.7 - Input and Output Facilities</A>
@ -93,20 +128,53 @@ Lua 5.1 Reference Manual
<LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A> <LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A>
</UL> </UL>
<LI><A HREF="manual.html#6">6 - Lua Stand-alone</A> <LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
<LI><A HREF="manual.html#incompat">Incompatibilities with the Previous Version</A> <LI><A HREF="manual.html#7">7 - Incompatibilities with the Previous Version</A>
<LI><A HREF="manual.html#BNF">The Complete Syntax of Lua</A> <UL>
<LI><A HREF="manual.html#7.1">7.1 - Changes in the Language</A>
<LI><A HREF="manual.html#7.2">7.2 - Changes in the Libraries</A>
<LI><A HREF="manual.html#7.3">7.3 - Changes in the API</A>
</UL>
<LI><A HREF="manual.html#8">8 - The Complete Syntax of Lua</A>
</UL> </UL>
<H2><A NAME="quick">Quick index</A></H2> <H2><A NAME="index">Index</A></H2>
<TABLE> <TABLE WIDTH="100%">
<TR VALIGN="top"> <TR VALIGN="top">
<TD WIDTH="35%"> <TD>
<H3><A NAME="functions">Functions</A></H3> <H3><A NAME="functions">Lua functions</A></H3>
<A HREF="manual.html#pdf-_G">_G</A><BR> <A HREF="manual.html#pdf-_G">_G</A><BR>
<A HREF="manual.html#pdf-_VERSION">_VERSION</A><BR> <A HREF="manual.html#pdf-_VERSION">_VERSION</A><BR>
<A HREF="manual.html#pdf-assert">assert</A><BR> <A HREF="manual.html#pdf-assert">assert</A><BR>
<A HREF="manual.html#pdf-collectgarbage">collectgarbage</A><BR> <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-loadfile">loadfile</A><BR>
<A HREF="manual.html#pdf-loadstring">loadstring</A><BR>
<A HREF="manual.html#pdf-module">module</A><BR>
<A HREF="manual.html#pdf-next">next</A><BR>
<A HREF="manual.html#pdf-pairs">pairs</A><BR>
<A HREF="manual.html#pdf-pcall">pcall</A><BR>
<A HREF="manual.html#pdf-print">print</A><BR>
<A HREF="manual.html#pdf-rawequal">rawequal</A><BR>
<A HREF="manual.html#pdf-rawget">rawget</A><BR>
<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>
</TD>
<TD>
<H3>&nbsp;</H3>
<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR> <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.resume">coroutine.resume</A><BR>
<A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR> <A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR>
@ -127,8 +195,6 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-debug.setmetatable">debug.setmetatable</A><BR> <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.setupvalue">debug.setupvalue</A><BR>
<A HREF="manual.html#pdf-debug.traceback">debug.traceback</A><BR> <A HREF="manual.html#pdf-debug.traceback">debug.traceback</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-file:close">file:close</A><BR> <A HREF="manual.html#pdf-file:close">file:close</A><BR>
<A HREF="manual.html#pdf-file:flush">file:flush</A><BR> <A HREF="manual.html#pdf-file:flush">file:flush</A><BR>
<A HREF="manual.html#pdf-file:lines">file:lines</A><BR> <A HREF="manual.html#pdf-file:lines">file:lines</A><BR>
@ -136,8 +202,6 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-file:seek">file:seek</A><BR> <A HREF="manual.html#pdf-file:seek">file:seek</A><BR>
<A HREF="manual.html#pdf-file:setvbuf">file:setvbuf</A><BR> <A HREF="manual.html#pdf-file:setvbuf">file:setvbuf</A><BR>
<A HREF="manual.html#pdf-file:write">file:write</A><BR> <A HREF="manual.html#pdf-file:write">file:write</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-io.close">io.close</A><BR> <A HREF="manual.html#pdf-io.close">io.close</A><BR>
<A HREF="manual.html#pdf-io.flush">io.flush</A><BR> <A HREF="manual.html#pdf-io.flush">io.flush</A><BR>
<A HREF="manual.html#pdf-io.input">io.input</A><BR> <A HREF="manual.html#pdf-io.input">io.input</A><BR>
@ -149,10 +213,6 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-io.tmpfile">io.tmpfile</A><BR> <A HREF="manual.html#pdf-io.tmpfile">io.tmpfile</A><BR>
<A HREF="manual.html#pdf-io.type">io.type</A><BR> <A HREF="manual.html#pdf-io.type">io.type</A><BR>
<A HREF="manual.html#pdf-io.write">io.write</A><BR> <A HREF="manual.html#pdf-io.write">io.write</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-loadfile">loadfile</A><BR>
<A HREF="manual.html#pdf-loadstring">loadstring</A><BR>
<A HREF="manual.html#pdf-math.abs">math.abs</A><BR> <A HREF="manual.html#pdf-math.abs">math.abs</A><BR>
<A HREF="manual.html#pdf-math.acos">math.acos</A><BR> <A HREF="manual.html#pdf-math.acos">math.acos</A><BR>
<A HREF="manual.html#pdf-math.asin">math.asin</A><BR> <A HREF="manual.html#pdf-math.asin">math.asin</A><BR>
@ -166,12 +226,14 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-math.floor">math.floor</A><BR> <A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
<A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR> <A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR>
<A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR> <A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
<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.ldexp">math.ldexp</A><BR>
<A HREF="manual.html#pdf-math.log10">math.log10</A><BR> <A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
<A HREF="manual.html#pdf-math.log">math.log</A><BR> <A HREF="manual.html#pdf-math.log">math.log</A><BR>
<A HREF="manual.html#pdf-math.max">math.max</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.min">math.min</A><BR>
<A HREF="manual.html#pdf-math.modf">math.modf</A><BR> <A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
<A HREF="manual.html#pdf-math.pi">math.pi</A><BR>
<A HREF="manual.html#pdf-math.pow">math.pow</A><BR> <A HREF="manual.html#pdf-math.pow">math.pow</A><BR>
<A HREF="manual.html#pdf-math.rad">math.rad</A><BR> <A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
<A HREF="manual.html#pdf-math.random">math.random</A><BR> <A HREF="manual.html#pdf-math.random">math.random</A><BR>
@ -181,8 +243,6 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR> <A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR> <A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
<A HREF="manual.html#pdf-math.tan">math.tan</A><BR> <A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
<A HREF="manual.html#pdf-module">module</A><BR>
<A HREF="manual.html#pdf-next">next</A><BR>
<A HREF="manual.html#pdf-os.clock">os.clock</A><BR> <A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
<A HREF="manual.html#pdf-os.date">os.date</A><BR> <A HREF="manual.html#pdf-os.date">os.date</A><BR>
<A HREF="manual.html#pdf-os.difftime">os.difftime</A><BR> <A HREF="manual.html#pdf-os.difftime">os.difftime</A><BR>
@ -200,16 +260,6 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-package.path">package.path</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.preload">package.preload</A><BR>
<A HREF="manual.html#pdf-package.seeall">package.seeall</A><BR> <A HREF="manual.html#pdf-package.seeall">package.seeall</A><BR>
<A HREF="manual.html#pdf-pairs">pairs</A><BR>
<A HREF="manual.html#pdf-pcall">pcall</A><BR>
<A HREF="manual.html#pdf-print">print</A><BR>
<A HREF="manual.html#pdf-rawequal">rawequal</A><BR>
<A HREF="manual.html#pdf-rawget">rawget</A><BR>
<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-string.byte">string.byte</A><BR> <A HREF="manual.html#pdf-string.byte">string.byte</A><BR>
<A HREF="manual.html#pdf-string.char">string.char</A><BR> <A HREF="manual.html#pdf-string.char">string.char</A><BR>
<A HREF="manual.html#pdf-string.dump">string.dump</A><BR> <A HREF="manual.html#pdf-string.dump">string.dump</A><BR>
@ -229,15 +279,10 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR> <A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR>
<A HREF="manual.html#pdf-table.remove">table.remove</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.sort">table.sort</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>
</TD> </TD>
<TD> <TD>
<H3>API</H3> <H3>C API</H3>
<A HREF="manual.html#lua_Alloc">lua_Alloc</A><BR> <A HREF="manual.html#lua_Alloc">lua_Alloc</A><BR>
<A HREF="manual.html#lua_CFunction">lua_CFunction</A><BR> <A HREF="manual.html#lua_CFunction">lua_CFunction</A><BR>
<A HREF="manual.html#lua_Debug">lua_Debug</A><BR> <A HREF="manual.html#lua_Debug">lua_Debug</A><BR>
@ -337,12 +382,13 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#lua_touserdata">lua_touserdata</A><BR> <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_type">lua_type</A><BR>
<A HREF="manual.html#lua_typename">lua_typename</A><BR> <A HREF="manual.html#lua_typename">lua_typename</A><BR>
<A HREF="manual.html#lua_upvalueindex">lua_upvalueindex</A><BR>
<A HREF="manual.html#lua_xmove">lua_xmove</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_yield">lua_yield</A><BR>
</TD> </TD>
<TD> <TD>
<H3>Auxiliary library</H3> <H3>auxiliary library</H3>
<A HREF="manual.html#luaL_Buffer">luaL_Buffer</A><BR> <A HREF="manual.html#luaL_Buffer">luaL_Buffer</A><BR>
<A HREF="manual.html#luaL_Reg">luaL_Reg</A><BR> <A HREF="manual.html#luaL_Reg">luaL_Reg</A><BR>
<A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR> <A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR>
@ -365,6 +411,8 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#luaL_checkstring">luaL_checkstring</A><BR> <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_checktype">luaL_checktype</A><BR>
<A HREF="manual.html#luaL_checkudata">luaL_checkudata</A><BR> <A HREF="manual.html#luaL_checkudata">luaL_checkudata</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_error">luaL_error</A><BR>
<A HREF="manual.html#luaL_getmetafield">luaL_getmetafield</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_getmetatable">luaL_getmetatable</A><BR>
@ -398,8 +446,11 @@ Lua 5.1 Reference Manual
<HR> <HR>
<SMALL> <SMALL>
Last update: Last update:
Fri Feb 10 17:15:37 BRST 2006 Fri Mar 23 08:33:19 BRT 2007
</SMALL> </SMALL>
<!--
Last change: minor edit
-->
</BODY> </BODY>
</HTML> </HTML>

View file

@ -2,10 +2,25 @@ body {
color: #000000 ; color: #000000 ;
background-color: #FFFFFF ; background-color: #FFFFFF ;
font-family: sans-serif ; font-family: sans-serif ;
text-align: justify ;
margin-right: 20px ;
margin-left: 20px ;
}
h1, h2, h3, h4 {
font-weight: normal ;
font-style: italic ;
} }
a:link { a:link {
color: #000080 ; color: #000080 ;
background-color: inherit ;
text-decoration: none ;
}
a:visited {
background-color: inherit ;
text-decoration: none ;
} }
a:link:hover, a:visited:hover { a:link:hover, a:visited:hover {
@ -13,3 +28,14 @@ a:link:hover, a:visited:hover {
background-color: #E0E0FF ; background-color: #E0E0FF ;
} }
a:link:active, a:visited:active {
color: #FF0000 ;
}
hr {
border: 0 ;
height: 1px ;
color: #a0a0a0 ;
background-color: #a0a0a0 ;
}

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css"> <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
</HEAD> </HEAD>
<BODY BGCOLOR="#FFFFFF"> <BODY>
<HR> <HR>
<H1> <H1>
@ -12,8 +12,9 @@
Documentation Documentation
</H1> </H1>
This is the documentation included in the source distribution of Lua 5.1.2.
<UL> <UL>
<LI><A HREF="http://www.lua.org/">Official web site</A>
<LI><A HREF="contents.html">Reference manual</A> <LI><A HREF="contents.html">Reference manual</A>
<LI><A HREF="lua.html">lua man page</A> <LI><A HREF="lua.html">lua man page</A>
<LI><A HREF="luac.html">luac man page</A> <LI><A HREF="luac.html">luac man page</A>
@ -22,10 +23,17 @@ Documentation
<LI><A HREF="../test/README">lua/test/README</A> <LI><A HREF="../test/README">lua/test/README</A>
</UL> </UL>
Lua's
<A HREF="http://www.lua.org/">official web site</A>
contains updated documentation,
especially the
<A HREF="http://www.lua.org/manual/5.1/">reference manual</A>.
<P>
<HR> <HR>
<SMALL> <SMALL>
Last update: Last update:
Wed Sep 7 12:57:50 BRST 2005 Fri Mar 23 14:19:36 BRT 2007
</SMALL> </SMALL>
</BODY> </BODY>

View file

@ -20,7 +20,7 @@ MYLIBS=
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
PLATS= aix ansi bsd generic linux macosx mingw posix solaris PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a LUA_A= liblua.a
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
@ -77,10 +77,11 @@ echo:
# convenience targets for popular platforms # convenience targets for popular platforms
none: none:
@echo "Please choose a platform: $(PLATS)" @echo "Please choose a platform:"
@echo " $(PLATS)"
aix: aix:
$(MAKE) all CC="xlc" CFLAGS="-O2" MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
ansi: ansi:
$(MAKE) all MYCFLAGS=-DLUA_ANSI $(MAKE) all MYCFLAGS=-DLUA_ANSI
@ -88,6 +89,9 @@ ansi:
bsd: bsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
freebsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
generic: generic:
$(MAKE) all MYCFLAGS= $(MAKE) all MYCFLAGS=
@ -103,6 +107,7 @@ mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe
posix: posix:
$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
@ -121,15 +126,15 @@ lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \
lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h
lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \ lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
ldo.h lgc.h ltable.h
ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \
llex.h lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h \ llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
ltm.h ldo.h lfunc.h lstring.h lgc.h lvm.h lfunc.h lstring.h lgc.h ltable.h lvm.h
ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h ltable.h \ lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \
lstring.h lundump.h lvm.h ltable.h lundump.h lvm.h
ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h lundump.h lzio.h lmem.h lundump.h
lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \
@ -139,7 +144,7 @@ lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h
liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h
llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h llex.h lparser.h ltable.h lstring.h lgc.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h ltm.h lzio.h lmem.h ldo.h
@ -150,8 +155,8 @@ lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h
lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \ lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
ldo.h lfunc.h lstring.h lgc.h lfunc.h lstring.h lgc.h ltable.h
lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h
lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 2.53 2006/01/10 12:50:00 roberto Exp $ ** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -32,7 +32,7 @@
const char lua_ident[] = const char lua_ident[] =
"$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n" "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
"$Authors: " LUA_AUTHORS " $\n" "$Authors: " LUA_AUTHORS " $\n"
"$URL: www.lua.org $\n"; "$URL: www.lua.org $\n";
@ -199,6 +199,9 @@ LUA_API void lua_insert (lua_State *L, int idx) {
LUA_API void lua_replace (lua_State *L, int idx) { LUA_API void lua_replace (lua_State *L, int idx) {
StkId o; StkId o;
lua_lock(L); lua_lock(L);
/* explicit test for incompatible code */
if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
luaG_runerror(L, "no calling environment");
api_checknelems(L, 1); api_checknelems(L, 1);
o = index2adr(L, idx); o = index2adr(L, idx);
api_checkvalidindex(L, o); api_checkvalidindex(L, o);

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $ ** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 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
*/ */
@ -123,12 +123,18 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud); void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
luaL_typerror(L, ud, tname);
lua_pop(L, 2); /* remove both metatables */ lua_pop(L, 2); /* remove both metatables */
return p; return p;
} }
}
}
luaL_typerror(L, ud, tname); /* else error */
return NULL; /* to avoid warnings */
}
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.h,v 1.87 2005/12/29 15:32:11 roberto Exp $ ** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 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
*/ */
@ -108,9 +108,11 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
#define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, 0, 0)) #define luaL_dofile(L, fn) \
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0)) #define luaL_dostring(L, s) \
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lbaselib.c,v 1.189 2006/01/18 11:49:12 roberto Exp $ ** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $
** Basic library ** Basic library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -114,11 +114,11 @@ static int luaB_setmetatable (lua_State *L) {
} }
static void getfunc (lua_State *L) { static void getfunc (lua_State *L, int opt) {
if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
else { else {
lua_Debug ar; lua_Debug ar;
int level = luaL_optint(L, 1, 1); int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
if (lua_getstack(L, level, &ar) == 0) if (lua_getstack(L, level, &ar) == 0)
luaL_argerror(L, 1, "invalid level"); luaL_argerror(L, 1, "invalid level");
@ -131,7 +131,7 @@ static void getfunc (lua_State *L) {
static int luaB_getfenv (lua_State *L) { static int luaB_getfenv (lua_State *L) {
getfunc(L); getfunc(L, 1);
if (lua_iscfunction(L, -1)) /* is a C function? */ if (lua_iscfunction(L, -1)) /* is a C function? */
lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
else else
@ -142,7 +142,7 @@ static int luaB_getfenv (lua_State *L) {
static int luaB_setfenv (lua_State *L) { static int luaB_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE); luaL_checktype(L, 2, LUA_TTABLE);
getfunc(L); getfunc(L, 0);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
/* change environment of current thread */ /* change environment of current thread */

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp $ ** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $
** Code generator for Lua ** Code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -35,9 +35,13 @@ static int isnumeral(expdesc *e) {
void luaK_nil (FuncState *fs, int from, int n) { void luaK_nil (FuncState *fs, int from, int n) {
Instruction *previous; Instruction *previous;
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
if (fs->pc == 0) /* function start? */ if (fs->pc == 0) { /* function start? */
if (from >= fs->nactvar)
return; /* positions are already clean */ return; /* positions are already clean */
if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { }
else {
previous = &fs->f->code[fs->pc-1];
if (GET_OPCODE(*previous) == OP_LOADNIL) {
int pfrom = GETARG_A(*previous); int pfrom = GETARG_A(*previous);
int pto = GETARG_B(*previous); int pto = GETARG_B(*previous);
if (pfrom <= from && from <= pto+1) { /* can connect both? */ if (pfrom <= from && from <= pto+1) { /* can connect both? */
@ -47,6 +51,7 @@ void luaK_nil (FuncState *fs, int from, int n) {
} }
} }
} }
}
luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
} }
@ -657,10 +662,16 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
if (constfolding(op, e1, e2)) if (constfolding(op, e1, e2))
return; return;
else { else {
int o1 = luaK_exp2RK(fs, e1);
int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
int o1 = luaK_exp2RK(fs, e1);
if (o1 > o2) {
freeexp(fs, e1);
freeexp(fs, e2);
}
else {
freeexp(fs, e2); freeexp(fs, e2);
freeexp(fs, e1); freeexp(fs, e1);
}
e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
e1->k = VRELOCABLE; e1->k = VRELOCABLE;
} }
@ -718,10 +729,15 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
break; break;
} }
default: { case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
case OPR_MOD: case OPR_POW: {
if (!isnumeral(v)) luaK_exp2RK(fs, v); if (!isnumeral(v)) luaK_exp2RK(fs, v);
break; break;
} }
default: {
luaK_exp2RK(fs, v);
break;
}
} }
} }
@ -731,17 +747,15 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
case OPR_AND: { case OPR_AND: {
lua_assert(e1->t == NO_JUMP); /* list must be closed */ lua_assert(e1->t == NO_JUMP); /* list must be closed */
luaK_dischargevars(fs, e2); luaK_dischargevars(fs, e2);
luaK_concat(fs, &e1->f, e2->f); luaK_concat(fs, &e2->f, e1->f);
e1->k = e2->k; e1->u.s.info = e2->u.s.info; *e1 = *e2;
e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
break; break;
} }
case OPR_OR: { case OPR_OR: {
lua_assert(e1->f == NO_JUMP); /* list must be closed */ lua_assert(e1->f == NO_JUMP); /* list must be closed */
luaK_dischargevars(fs, e2); luaK_dischargevars(fs, e2);
luaK_concat(fs, &e1->t, e2->t); luaK_concat(fs, &e2->t, e1->t);
e1->k = e2->k; e1->u.s.info = e2->u.s.info; *e1 = *e2;
e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
break; break;
} }
case OPR_CONCAT: { case OPR_CONCAT: {
@ -750,7 +764,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
freeexp(fs, e1); freeexp(fs, e1);
SETARG_B(getcode(fs, e2), e1->u.s.info); SETARG_B(getcode(fs, e2), e1->u.s.info);
e1->k = e2->k; e1->u.s.info = e2->u.s.info; e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
} }
else { else {
luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lcode.h,v 1.47 2005/11/08 19:44:31 roberto Exp $ ** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $
** Code generator for Lua ** Code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -32,7 +32,6 @@ typedef enum BinOpr {
OPR_NOBINOPR OPR_NOBINOPR
} BinOpr; } BinOpr;
#define binopistest(op) ((op) >= OPR_NE)
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;

View file

@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $ ** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -432,14 +432,16 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
break; break;
} }
case OP_CLOSURE: { case OP_CLOSURE: {
int nup; int nup, j;
check(b < pt->sizep); check(b < pt->sizep);
nup = pt->p[b]->nups; nup = pt->p[b]->nups;
check(pc + nup < pt->sizecode); check(pc + nup < pt->sizecode);
for (; nup>0; nup--) { for (j = 1; j <= nup; j++) {
OpCode op1 = GET_OPCODE(pt->code[pc+nup]); OpCode op1 = GET_OPCODE(pt->code[pc + j]);
check(op1 == OP_GETUPVAL || op1 == OP_MOVE); check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
} }
if (reg != NO_REG) /* tracing? */
pc += nup; /* do not 'execute' these pseudo-instructions */
break; break;
} }
case OP_VARARG: { case OP_VARARG: {

View file

@ -1,5 +1,5 @@
/* /*
** $Id: ldo.c,v 2.37 2005/12/22 16:19:56 roberto Exp $ ** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 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
*/ */
@ -383,12 +383,14 @@ void luaD_call (lua_State *L, StkId func, int nResults) {
static void resume (lua_State *L, void *ud) { static void resume (lua_State *L, void *ud) {
StkId firstArg = cast(StkId, ud); StkId firstArg = cast(StkId, ud);
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (L->status != LUA_YIELD) { /* start coroutine */ if (L->status == 0) { /* start coroutine? */
lua_assert(ci == L->base_ci && firstArg > L->base); lua_assert(ci == L->base_ci && firstArg > L->base);
if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
return; return;
} }
else { /* resuming from previous yield */ else { /* resuming from previous yield */
lua_assert(L->status == LUA_YIELD);
L->status = 0;
if (!f_isLua(ci)) { /* `common' yield? */ if (!f_isLua(ci)) { /* `common' yield? */
/* finish interrupted execution of `OP_CALL' */ /* finish interrupted execution of `OP_CALL' */
lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
@ -399,7 +401,6 @@ static void resume (lua_State *L, void *ud) {
else /* yielded inside a hook: just continue its execution */ else /* yielded inside a hook: just continue its execution */
L->base = L->ci->base; L->base = L->ci->base;
} }
L->status = 0;
luaV_execute(L, cast_int(L->ci - L->base_ci)); luaV_execute(L, cast_int(L->ci - L->base_ci));
} }

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $ ** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures ** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -55,7 +55,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
GCObject **pp = &L->openupval; GCObject **pp = &L->openupval;
UpVal *p; UpVal *p;
UpVal *uv; UpVal *uv;
while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
lua_assert(p->v != &p->u.value); lua_assert(p->v != &p->u.value);
if (p->v == level) { /* found a corresponding upvalue? */ if (p->v == level) { /* found a corresponding upvalue? */
if (isdead(g, obj2gco(p))) /* is it dead? */ if (isdead(g, obj2gco(p))) /* is it dead? */
@ -96,7 +96,7 @@ void luaF_freeupval (lua_State *L, UpVal *uv) {
void luaF_close (lua_State *L, StkId level) { void luaF_close (lua_State *L, StkId level) {
UpVal *uv; UpVal *uv;
global_State *g = G(L); global_State *g = G(L);
while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
GCObject *o = obj2gco(uv); GCObject *o = obj2gco(uv);
lua_assert(!isblack(o) && uv->v != &uv->u.value); lua_assert(!isblack(o) && uv->v != &uv->u.value);
L->openupval = uv->next; /* remove from `open' list */ L->openupval = uv->next; /* remove from `open' list */

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 2.37 2005/12/22 16:19:56 roberto Exp $ ** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -320,8 +320,10 @@ static l_mem propagatemark (global_State *g) {
} }
static void propagateall (global_State *g) { static size_t propagateall (global_State *g) {
while (g->gray) propagatemark(g); size_t m = 0;
while (g->gray) m += propagatemark(g);
return m;
} }
@ -540,7 +542,7 @@ static void atomic (lua_State *L) {
propagateall(g); propagateall(g);
udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
marktmu(g); /* mark `preserved' userdata */ marktmu(g); /* mark `preserved' userdata */
propagateall(g); /* remark, to propagate `preserveness' */ udsize += propagateall(g); /* remark, to propagate `preserveness' */
cleartable(g->weak); /* remove collected objects from weak tables */ cleartable(g->weak); /* remove collected objects from weak tables */
/* flip current white */ /* flip current white */
g->currentwhite = cast_byte(otherwhite(g)); g->currentwhite = cast_byte(otherwhite(g));
@ -590,6 +592,8 @@ static l_mem singlestep (lua_State *L) {
case GCSfinalize: { case GCSfinalize: {
if (g->tmudata) { if (g->tmudata) {
GCTM(L); GCTM(L);
if (g->estimate > GCFINALIZECOST)
g->estimate -= GCFINALIZECOST;
return GCFINALIZECOST; return GCFINALIZECOST;
} }
else { else {

View file

@ -1,5 +1,5 @@
/* /*
** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp $ ** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 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
*/ */
@ -117,7 +117,7 @@ static FILE **newfile (lua_State *L) {
static int io_pclose (lua_State *L) { static int io_pclose (lua_State *L) {
FILE **p = topfile(L); FILE **p = topfile(L);
int ok = lua_pclose(L, *p); int ok = lua_pclose(L, *p);
if (ok) *p = NULL; *p = NULL;
return pushresult(L, ok, NULL); return pushresult(L, ok, NULL);
} }
@ -125,7 +125,7 @@ static int io_pclose (lua_State *L) {
static int io_fclose (lua_State *L) { static int io_fclose (lua_State *L) {
FILE **p = topfile(L); FILE **p = topfile(L);
int ok = (fclose(*p) == 0); int ok = (fclose(*p) == 0);
if (ok) *p = NULL; *p = NULL;
return pushresult(L, ok, NULL); return pushresult(L, ok, NULL);
} }

View file

@ -1,5 +1,5 @@
/* /*
** $Id: llex.c,v 2.19 2006/02/06 18:28:16 roberto Exp $ ** $Id: llex.c,v 2.20 2006/03/09 18:14:31 roberto Exp $
** Lexical Analyzer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -20,6 +20,7 @@
#include "lparser.h" #include "lparser.h"
#include "lstate.h" #include "lstate.h"
#include "lstring.h" #include "lstring.h"
#include "ltable.h"
#include "lzio.h" #include "lzio.h"

View file

@ -1,5 +1,5 @@
/* /*
** $Id: llex.h,v 1.57 2005/12/07 15:43:05 roberto Exp $ ** $Id: llex.h,v 1.58 2006/03/23 18:23:32 roberto Exp $
** Lexical Analyzer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -68,9 +68,9 @@ typedef struct LexState {
LUAI_FUNC void luaX_init (lua_State *L); LUAI_FUNC void luaX_init (lua_State *L);
LUAI_FUNC void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
TString *source); TString *source);
LUAI_FUNC TString *luaX_newstring (LexState *LS, const char *str, size_t l); LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
LUAI_FUNC void luaX_next (LexState *ls); LUAI_FUNC void luaX_next (LexState *ls);
LUAI_FUNC void luaX_lookahead (LexState *ls); LUAI_FUNC void luaX_lookahead (LexState *ls);
LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);

View file

@ -1,5 +1,5 @@
/* /*
** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp $ ** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $
** Dynamic library loader for Lua ** Dynamic library loader for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
** **
@ -16,16 +16,12 @@
#define loadlib_c #define loadlib_c
#define LUA_LIB #define LUA_LIB
#include "lauxlib.h"
#include "lobject.h"
#include "lua.h" #include "lua.h"
#include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
/* environment variables that hold the search path for packages */
#define LUA_PATH "LUA_PATH"
#define LUA_CPATH "LUA_CPATH"
/* prefix for open functions in C libraries */ /* prefix for open functions in C libraries */
#define LUA_POF "luaopen_" #define LUA_POF "luaopen_"
@ -375,15 +371,16 @@ static const char *findfile (lua_State *L, const char *name,
path = lua_tostring(L, -1); path = lua_tostring(L, -1);
if (path == NULL) if (path == NULL)
luaL_error(L, LUA_QL("package.%s") " must be a string", pname); luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
lua_pushstring(L, ""); /* error accumulator */ lua_pushliteral(L, ""); /* error accumulator */
while ((path = pushnexttemplate(L, path)) != NULL) { while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename; const char *filename;
filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
lua_remove(L, -2); /* remove path template */
if (readable(filename)) /* does file exist and is readable? */ if (readable(filename)) /* does file exist and is readable? */
return filename; /* return that file name */ return filename; /* return that file name */
lua_pop(L, 2); /* remove path template and file name */ lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); lua_remove(L, -2); /* remove file name */
lua_concat(L, 2); lua_concat(L, 2); /* add entry to possible error message */
} }
return NULL; /* not found */ return NULL; /* not found */
} }
@ -442,7 +439,7 @@ static int loader_Croot (lua_State *L) {
funcname = mkfuncname(L, name); funcname = mkfuncname(L, name);
if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
if (stat != ERRFUNC) loaderror(L, filename); /* real error */ if (stat != ERRFUNC) loaderror(L, filename); /* real error */
luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
name, filename); name, filename);
return 1; /* function not found */ return 1; /* function not found */
} }
@ -457,7 +454,7 @@ static int loader_preload (lua_State *L) {
luaL_error(L, LUA_QL("package.preload") " must be a table"); luaL_error(L, LUA_QL("package.preload") " must be a table");
lua_getfield(L, -1, name); lua_getfield(L, -1, name);
if (lua_isnil(L, -1)) /* not found? */ if (lua_isnil(L, -1)) /* not found? */
luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
return 1; return 1;
} }
@ -481,7 +478,7 @@ static int ll_require (lua_State *L) {
lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
luaL_error(L, LUA_QL("package.loaders") " must be a table"); luaL_error(L, LUA_QL("package.loaders") " must be a table");
lua_pushstring(L, ""); /* error message accumulator */ lua_pushliteral(L, ""); /* error message accumulator */
for (i=1; ; i++) { for (i=1; ; i++) {
lua_rawgeti(L, -2, i); /* get a loader */ lua_rawgeti(L, -2, i); /* get a loader */
if (lua_isnil(L, -1)) if (lua_isnil(L, -1))
@ -665,7 +662,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */
setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
/* store config information */ /* store config information */
lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
LUA_EXECDIR "\n" LUA_IGMARK); LUA_EXECDIR "\n" LUA_IGMARK);
lua_setfield(L, -2, "config"); lua_setfield(L, -2, "config");
/* set field `loaded' */ /* set field `loaded' */

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lopcodes.h,v 1.124 2005/12/02 18:42:08 roberto Exp $ ** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $
** Opcodes for Lua virtual machine ** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -197,8 +197,8 @@ OP_FORLOOP,/* A sBx R(A)+=R(A+2);
if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
OP_TFORLOOP,/* A C R(A+3), ... ,R(A+3+C) := R(A)(R(A+1), R(A+2)); OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
if R(A+3) ~= nil then { pc++; R(A+2)=R(A+3); } */ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/ OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/

View file

@ -1,5 +1,5 @@
/* /*
** $Id: loslib.c,v 1.17 2006/01/27 13:54:31 roberto Exp $ ** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $
** Standard Operating System library ** Standard Operating System library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -33,10 +33,7 @@ static int os_pushresult (lua_State *L, int i, const char *filename) {
} }
else { else {
lua_pushnil(L); lua_pushnil(L);
if (filename)
lua_pushfstring(L, "%s: %s", filename, strerror(en)); lua_pushfstring(L, "%s: %s", filename, strerror(en));
else
lua_pushfstring(L, "%s", strerror(en));
lua_pushinteger(L, en); lua_pushinteger(L, en);
return 3; return 3;
} }
@ -176,8 +173,7 @@ static int getfield (lua_State *L, const char *key, int d) {
static int os_date (lua_State *L) { static int os_date (lua_State *L) {
const char *s = luaL_optstring(L, 1, "%c"); const char *s = luaL_optstring(L, 1, "%c");
time_t t = lua_isnoneornil(L, 2) ? time(NULL) : time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
(time_t)luaL_checknumber(L, 2);
struct tm *stm; struct tm *stm;
if (*s == '!') { /* UTC? */ if (*s == '!') { /* UTC? */
stm = gmtime(&t); stm = gmtime(&t);
@ -200,11 +196,22 @@ static int os_date (lua_State *L) {
setboolfield(L, "isdst", stm->tm_isdst); setboolfield(L, "isdst", stm->tm_isdst);
} }
else { else {
char b[256]; char cc[3];
if (strftime(b, sizeof(b), s, stm)) // TODO: call widechar version on win32 luaL_Buffer b;
lua_pushstring(L, b); cc[0] = '%'; cc[2] = '\0';
else luaL_buffinit(L, &b);
return luaL_error(L, LUA_QL("date") " format too long"); for (; *s; s++) {
if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */
luaL_addchar(&b, *s);
else {
size_t reslen;
char buff[200]; /* should be big enough for any conversion result */
cc[1] = *(++s);
reslen = strftime(buff, sizeof(buff), cc, stm); // TODO, call W version on win32
luaL_addlstring(&b, buff, reslen);
}
}
luaL_pushresult(&b);
} }
return 1; return 1;
} }
@ -250,9 +257,8 @@ static int os_setlocale (lua_State *L) {
LC_NUMERIC, LC_TIME}; LC_NUMERIC, LC_TIME};
static const char *const catnames[] = {"all", "collate", "ctype", "monetary", static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
"numeric", "time", NULL}; "numeric", "time", NULL};
const char *l = lua_tostring(L, 1); const char *l = luaL_optstring(L, 1, NULL);
int op = luaL_checkoption(L, 2, "all", catnames); int op = luaL_checkoption(L, 2, "all", catnames);
luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected");
lua_pushstring(L, setlocale(cat[op], l)); lua_pushstring(L, setlocale(cat[op], l));
return 1; return 1;
} }

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 2.40 2005/12/22 16:19:56 roberto Exp $ ** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $
** Lua Parser ** Lua Parser
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -23,7 +23,7 @@
#include "lparser.h" #include "lparser.h"
#include "lstate.h" #include "lstate.h"
#include "lstring.h" #include "lstring.h"
#include "ltable.h"
@ -299,7 +299,8 @@ static void leaveblock (FuncState *fs) {
removevars(fs->ls, bl->nactvar); removevars(fs->ls, bl->nactvar);
if (bl->upval) if (bl->upval)
luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
lua_assert(!bl->isbreakable || !bl->upval); /* loops have no body */ /* a block either controls scope or breaks (never both) */
lua_assert(!bl->isbreakable || !bl->upval);
lua_assert(bl->nactvar == fs->nactvar); lua_assert(bl->nactvar == fs->nactvar);
fs->freereg = fs->nactvar; /* free registers */ fs->freereg = fs->nactvar; /* free registers */
luaK_patchtohere(fs, bl->breaklist); luaK_patchtohere(fs, bl->breaklist);
@ -444,6 +445,7 @@ static void recfield (LexState *ls, struct ConsControl *cc) {
FuncState *fs = ls->fs; FuncState *fs = ls->fs;
int reg = ls->fs->freereg; int reg = ls->fs->freereg;
expdesc key, val; expdesc key, val;
int rkkey;
if (ls->t.token == TK_NAME) { if (ls->t.token == TK_NAME) {
luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
checkname(ls, &key); checkname(ls, &key);
@ -452,10 +454,9 @@ static void recfield (LexState *ls, struct ConsControl *cc) {
yindex(ls, &key); yindex(ls, &key);
cc->nh++; cc->nh++;
checknext(ls, '='); checknext(ls, '=');
luaK_exp2RK(fs, &key); rkkey = luaK_exp2RK(fs, &key);
expr(ls, &val); expr(ls, &val);
luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, luaK_exp2RK(fs, &key), luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
luaK_exp2RK(fs, &val));
fs->freereg = reg; /* free registers */ fs->freereg = reg; /* free registers */
} }
@ -488,7 +489,7 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
static void listfield (LexState *ls, struct ConsControl *cc) { static void listfield (LexState *ls, struct ConsControl *cc) {
expr(ls, &cc->v); expr(ls, &cc->v);
luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor"); luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
cc->na++; cc->na++;
cc->tostore++; cc->tostore++;
} }

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lparser.h,v 1.56 2005/10/03 14:02:40 roberto Exp $ ** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
** Lua Parser ** Lua Parser
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -9,7 +9,6 @@
#include "llimits.h" #include "llimits.h"
#include "lobject.h" #include "lobject.h"
#include "ltable.h"
#include "lzio.h" #include "lzio.h"

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lstate.c,v 2.35 2005/10/06 20:46:25 roberto Exp $ ** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -198,7 +198,6 @@ static void callallgcTM (lua_State *L, void *ud) {
LUA_API void lua_close (lua_State *L) { LUA_API void lua_close (lua_State *L) {
L = G(L)->mainthread; /* only the main thread can be closed */ L = G(L)->mainthread; /* only the main thread can be closed */
luai_userstateclose(L);
lua_lock(L); lua_lock(L);
luaF_close(L, L->stack); /* close all upvalues for this thread */ luaF_close(L, L->stack); /* close all upvalues for this thread */
luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
@ -209,6 +208,7 @@ LUA_API void lua_close (lua_State *L) {
L->nCcalls = 0; L->nCcalls = 0;
} while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
lua_assert(G(L)->tmudata == NULL); lua_assert(G(L)->tmudata == NULL);
luai_userstateclose(L);
close_state(L); close_state(L);
} }

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lstrlib.c,v 1.130 2005/12/29 15:32:11 roberto Exp $ ** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 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
*/ */
@ -703,6 +703,10 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
luaL_addchar(b, *s); luaL_addchar(b, *s);
break; break;
} }
case '\r': {
luaL_addlstring(b, "\\r", 2);
break;
}
case '\0': { case '\0': {
luaL_addlstring(b, "\\000", 4); luaL_addlstring(b, "\\000", 4);
break; break;
@ -719,7 +723,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
const char *p = strfrmt; const char *p = strfrmt;
while (strchr(FLAGS, *p)) p++; /* skip flags */ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
luaL_error(L, "invalid format (repeated flags)"); luaL_error(L, "invalid format (repeated flags)");
if (isdigit(uchar(*p))) p++; /* skip width */ if (isdigit(uchar(*p))) p++; /* skip width */
@ -805,7 +809,8 @@ static int str_format (lua_State *L) {
} }
} }
default: { /* also treat cases `pnLlh' */ default: { /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option to " LUA_QL("format")); return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
LUA_QL("format"), *(strfrmt - 1));
} }
} }
luaL_addlstring(&b, buff, strlen(buff)); luaL_addlstring(&b, buff, strlen(buff));

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.216 2006/01/10 12:50:13 roberto Exp $ ** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension 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
@ -17,8 +17,9 @@
#define LUA_VERSION "Lua 5.1" #define LUA_VERSION "Lua 5.1"
#define LUA_RELEASE "Lua 5.1.2"
#define LUA_VERSION_NUM 501 #define LUA_VERSION_NUM 501
#define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" #define LUA_COPYRIGHT "Copyright (C) 1994-2007 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"
@ -358,7 +359,7 @@ struct lua_Debug {
/****************************************************************************** /******************************************************************************
* Copyright (C) 1994-2006 Lua.org, PUC-Rio. All rights reserved. * Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved.
* *
* 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

View file

@ -1,5 +1,5 @@
/* /*
** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp $ ** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $
** Configuration file for Lua ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -59,6 +59,18 @@
#endif #endif
/*
@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
@* Lua check to set its paths.
@@ LUA_INIT is the name of the environment variable that Lua
@* checks for initialization code.
** CHANGE them if you want different names.
*/
#define LUA_PATH "LUA_PATH"
#define LUA_CPATH "LUA_CPATH"
#define LUA_INIT "LUA_INIT"
/* /*
@@ 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.
@ -348,7 +360,7 @@
/* /*
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
@* behavior. @* behavior.
** CHANGE it to undefined as soon as you replace to 'luaL_registry' ** CHANGE it to undefined as soon as you replace to 'luaL_register'
** your uses of 'luaL_openlib' ** your uses of 'luaL_openlib'
*/ */
#define LUA_COMPAT_OPENLIB #define LUA_COMPAT_OPENLIB
@ -543,11 +555,25 @@
/* On a Pentium, resort to a trick */ /* On a Pentium, resort to a trick */
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
(defined(__i386) || defined (_M_IX86) || defined(__i386__)) (defined(__i386) || defined (_M_IX86) || defined(__i386__))
/* On a Microsoft compiler, use assembler */
#if defined(_MSC_VER)
#define lua_number2int(i,d) __asm fld d __asm fistp i
#define lua_number2integer(i,n) lua_number2int(i, n)
/* the next trick should work on any Pentium, but sometimes clashes
with a DirectX idiosyncrasy */
#else
union luai_Cast { double l_d; long l_l; }; union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \ #define lua_number2int(i,d) \
{ volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
#define lua_number2integer(i,n) lua_number2int(i, n) #define lua_number2integer(i,n) lua_number2int(i, n)
#endif
/* this option always works, but may be slow */ /* this option always works, but may be slow */
#else #else
#define lua_number2int(i,d) ((i)=(int)(d)) #define lua_number2int(i,d) ((i)=(int)(d))

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp $ ** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -165,7 +165,7 @@ static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
if (ttisnil(tm)) if (ttisnil(tm))
tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
if (!ttisfunction(tm)) return 0; if (ttisnil(tm)) return 0;
callTMres(L, res, tm, p1, p2); callTMres(L, res, tm, p1, p2);
return 1; return 1;
} }
@ -281,10 +281,12 @@ void luaV_concat (lua_State *L, int total, int last) {
do { do {
StkId top = L->base + last + 1; StkId top = L->base + last + 1;
int n = 2; /* number of elements handled in this pass (at least 2) */ int n = 2; /* number of elements handled in this pass (at least 2) */
if (!tostring(L, top-2) || !tostring(L, top-1)) { if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
luaG_concaterror(L, top-2, top-1); luaG_concaterror(L, top-2, top-1);
} else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
(void)tostring(L, top - 2); /* result is first op (as string) */
else {
/* at least two string values; get as many as possible */ /* at least two string values; get as many as possible */
size_t tl = tsvalue(top-1)->len; size_t tl = tsvalue(top-1)->len;
char *buffer; char *buffer;
@ -376,6 +378,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
TValue *k; TValue *k;
const Instruction *pc; const Instruction *pc;
reentry: /* entry point */ reentry: /* entry point */
lua_assert(isLua(L->ci));
pc = L->savedpc; pc = L->savedpc;
cl = &clvalue(L->ci->func)->l; cl = &clvalue(L->ci->func)->l;
base = L->base; base = L->base;