Updated Lua from 5.1.1 to 5.1.3.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 18 Mar 2008 02:05:22 +0000
changeset 499 96e88f292dc8
parent 498 29a6ea52610c
child 500 e6547667653a
Updated Lua from 5.1.1 to 5.1.3.
src/lua-5.1.1/COPYRIGHT
src/lua-5.1.1/HISTORY
src/lua-5.1.1/INSTALL
src/lua-5.1.1/Makefile
src/lua-5.1.1/README
src/lua-5.1.1/doc/amazon.gif
src/lua-5.1.1/doc/contents.html
src/lua-5.1.1/doc/cover.png
src/lua-5.1.1/doc/lua.css
src/lua-5.1.1/doc/manual.css
src/lua-5.1.1/doc/manual.html
src/lua-5.1.1/doc/readme.html
src/lua-5.1.1/etc/README
src/lua-5.1.1/etc/lua.pc
src/lua-5.1.1/etc/luavs.bat
src/lua-5.1.1/etc/min.c
src/lua-5.1.1/etc/strict.lua
src/lua-5.1.1/src/Makefile
src/lua-5.1.1/src/lapi.c
src/lua-5.1.1/src/lapi.h
src/lua-5.1.1/src/lauxlib.c
src/lua-5.1.1/src/lauxlib.h
src/lua-5.1.1/src/lbaselib.c
src/lua-5.1.1/src/lcode.c
src/lua-5.1.1/src/lcode.h
src/lua-5.1.1/src/ldblib.c
src/lua-5.1.1/src/ldebug.c
src/lua-5.1.1/src/ldebug.h
src/lua-5.1.1/src/ldo.c
src/lua-5.1.1/src/ldo.h
src/lua-5.1.1/src/ldump.c
src/lua-5.1.1/src/lfunc.c
src/lua-5.1.1/src/lfunc.h
src/lua-5.1.1/src/lgc.c
src/lua-5.1.1/src/lgc.h
src/lua-5.1.1/src/linit.c
src/lua-5.1.1/src/liolib.c
src/lua-5.1.1/src/llimits.h
src/lua-5.1.1/src/lmathlib.c
src/lua-5.1.1/src/lmem.c
src/lua-5.1.1/src/lmem.h
src/lua-5.1.1/src/loadlib.c
src/lua-5.1.1/src/lobject.c
src/lua-5.1.1/src/lobject.h
src/lua-5.1.1/src/lopcodes.c
src/lua-5.1.1/src/lopcodes.h
src/lua-5.1.1/src/loslib.c
src/lua-5.1.1/src/lparser.h
src/lua-5.1.1/src/lstate.c
src/lua-5.1.1/src/lstate.h
src/lua-5.1.1/src/lstring.c
src/lua-5.1.1/src/lstring.h
src/lua-5.1.1/src/lstrlib.c
src/lua-5.1.1/src/ltable.c
src/lua-5.1.1/src/ltable.h
src/lua-5.1.1/src/ltablib.c
src/lua-5.1.1/src/ltm.c
src/lua-5.1.1/src/ltm.h
src/lua-5.1.1/src/lua.c
src/lua-5.1.1/src/lua.h
src/lua-5.1.1/src/luaconf.h
src/lua-5.1.1/src/lualib.h
src/lua-5.1.1/src/lundump.c
src/lua-5.1.1/src/lundump.h
src/lua-5.1.1/src/lvm.c
src/lua-5.1.1/src/lvm.h
src/lua-5.1.1/src/lzio.c
src/lua-5.1.1/src/lzio.h
src/lua-5.1.1/src/print.c
src/toby_app.c
--- a/src/lua-5.1.1/COPYRIGHT	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/COPYRIGHT	Tue Mar 18 02:05:22 2008 +0000
@@ -9,7 +9,7 @@
 
 ===============================================================================
 
-Copyright (C) 1994-2006 Lua.org, PUC-Rio.
+Copyright (C) 1994-2008 Lua.org, PUC-Rio.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
--- a/src/lua-5.1.1/HISTORY	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/HISTORY	Tue Mar 18 02:05:22 2008 +0000
@@ -14,7 +14,7 @@
   API:
   + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
   + user supplies memory allocator (lua_open becomes lua_newstate).
-  + luaopen_* functionst must be called through Lua.
+  + luaopen_* functions must be called through Lua.
   Implementation:
   + new configuration scheme via luaconf.h.
   + incremental garbage collection.
--- a/src/lua-5.1.1/INSTALL	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/INSTALL	Tue Mar 18 02:05:22 2008 +0000
@@ -8,7 +8,10 @@
   Building Lua on Unix systems should be very easy. First do "make" and
   see if your platform is listed. If so, just do "make xxx", where xxx
   is your platform name. The platforms currently supported are:
-	ansi bsd generic linux macosx mingw posix solaris
+    aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+  If your platform is not listed, try the closest one or posix, generic,
+  ansi, in this order.
 
   See below for customization instructions and for instructions on how
   to build with other Windows compilers.
@@ -81,8 +84,8 @@
 
   compiler:	library, luac.c print.c
 
-  If you use Visual Studio .NET, you can use etc/luavs.bat
-  in its "Command Prompt".
+  If you use Visual Studio .NET, you can use etc/luavs.bat in its
+  "Command Prompt".
 
   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.
--- a/src/lua-5.1.1/Makefile	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/Makefile	Tue Mar 18 02:05:22 2008 +0000
@@ -9,7 +9,8 @@
 
 # Where to install. The installation starts in the src directory, so take care
 # if INSTALL_TOP is not an absolute path. (Man pages are installed from the
-# doc directory.)
+# doc directory.) You may want to make these paths consistent with LUA_ROOT,
+# LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
 #
 INSTALL_TOP= /usr/local
 INSTALL_BIN= $(INSTALL_TOP)/bin
@@ -19,25 +20,20 @@
 INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
 INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
 
-# How to install. You may prefer "install" instead of "cp" if you have it.
-# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
-#
-INSTALL_EXEC= $(CP)
-INSTALL_DATA= $(CP)
-#INSTALL_EXEC= $(INSTALL) -m 0755
-#INSTALL_DATA= $(INSTALL) -m 0644
+# How to install. If you don't have "install" (unlikely) then get install-sh at
+#	http://dev.w3.org/cvsweb/libwww/config/install-sh
+# or use cp instead.
+INSTALL_EXEC= $(INSTALL) -p -m 0755
+INSTALL_DATA= $(INSTALL) -p -m 0644
 
 # Utilities.
-CP= cp
-FIND= find
 INSTALL= install
 MKDIR= mkdir
-RANLIB= ranlib
 
 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
 
 # Convenience platforms targets.
-PLATS= aix ansi bsd generic linux macosx mingw posix solaris
+PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
 
 # What to install.
 TO_BIN= lua luac
@@ -47,7 +43,7 @@
 
 # Lua version and release.
 V= 5.1
-R= 5.1.1
+R= 5.1.3
 
 all:	$(PLAT)
 
@@ -63,10 +59,9 @@
 	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
 	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
 	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
-#	$(RANLIB) $(INSTALL_LIB)/$(TO_LIB)
 
 local:
-	$(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"
+	$(MAKE) install INSTALL_TOP=..
 
 none:
 	@echo "Please do"
@@ -119,11 +114,7 @@
 	@$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/'
 	@echo "-- EOF"
 
-# show what has changed since we unpacked
-newer:
-	@$(FIND) . -newer MANIFEST -type f
-
 # list targets that do not create files (but not all makes understand .PHONY)
-.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho newer
+.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
 
 # (end of Makefile)
--- a/src/lua-5.1.1/README	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/README	Tue Mar 18 02:05:22 2008 +0000
@@ -24,8 +24,8 @@
 * Installation
   ------------
   Lua is implemented in pure ANSI C, and compiles unmodified in all known
-  platforms that have an ANSI C compiler. Under Unix, simply typing "make"
-  should work. See INSTALL for detailed instructions.
+  platforms that have an ANSI C compiler. In most Unix-like platforms, simply
+  do "make" with a suitable target. See INSTALL for detailed instructions.
 
 * Origin
   ------
Binary file src/lua-5.1.1/doc/amazon.gif has changed
--- a/src/lua-5.1.1/doc/contents.html	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/doc/contents.html	Tue Mar 18 02:05:22 2008 +0000
@@ -1,33 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <HTML>
 <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">
-<style type="text/css">
+<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
+<STYLE TYPE="text/css">
 ul {
 	list-style-type: none ;
 	list-style-position: outside ;
 }
-</style>
+</STYLE>
 </HEAD>
 
 <BODY>
 
 <HR>
 <H1>
-<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
-Reference manual for Lua 5.1
+<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="" BORDER=0></A>
+Lua 5.1 Reference Manual
 </H1>
 
+This is an online version of
+<BLOCKQUOTE>
+<A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
+<IMG SRC="cover.png" ALT="" TITLE="buy from Amazon" BORDER=1 ALIGN="left" HSPACE=12>
+</A>
+<B>Lua 5.1 Reference Manual</B>
+<BR>by R. Ierusalimschy, L. H. de Figueiredo, W. Celes
+<BR>Lua.org, August 2006
+<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>
+
+Buy a copy of this book and 
+<A HREF="http://www.lua.org/donations.html">help to support</A>
+the Lua project.
+<P>
+
+The reference manual is the official definition of the Lua language.
+For a complete introduction to Lua programming, see the book
+<A HREF="http://www.lua.org/docs.html#books">Programming in Lua</A>.
+<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/pt/">portuguÍs</A>
+&middot;
+<A HREF="http://www.lua.org/manual/5.1/es/">espaŮol</A>
 <HR>
+<SMALL>
+Copyright &copy; 2006-2008 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">Top</A>
-<LI><A HREF="manual.html#1">1 - Introduction</A>
+<LI><A HREF="manual.html">1 - Introduction</A>
+<P>
 <LI><A HREF="manual.html#2">2 - The Language</A>
 <UL>
 <LI><A HREF="manual.html#2.1">2.1 - Lexical Conventions</A>
@@ -69,6 +107,7 @@
 </UL>
 <LI><A HREF="manual.html#2.11">2.11 - Coroutines</A>
 </UL>
+<P>
 <LI><A HREF="manual.html#3">3 - The Application Program Interface</A>
 <UL>
 <LI><A HREF="manual.html#3.1">3.1 - The Stack</A>
@@ -80,10 +119,12 @@
 <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>
 </UL>
+<P>
 <LI><A HREF="manual.html#4">4 - The Auxiliary Library</A>
 <UL>
 <LI><A HREF="manual.html#4.1">4.1 - Functions and Types</A>
 </UL>
+<P>
 <LI><A HREF="manual.html#5">5 - Standard Libraries</A>
 <UL>
 <LI><A HREF="manual.html#5.1">5.1 - Basic Functions</A>
@@ -99,21 +140,23 @@
 <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>
 </UL>
+<P>
 <LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
+<P>
 <LI><A HREF="manual.html#7">7 - Incompatibilities with the Previous Version</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>
+<P>
 <LI><A HREF="manual.html#8">8 - The Complete Syntax of Lua</A>
-
 </UL>
 
 <H2><A NAME="index">Index</A></H2>
-<TABLE>
+<TABLE WIDTH="100%">
 <TR VALIGN="top">
-<TD WIDTH="20%">
+<TD>
 <H3><A NAME="functions">Lua functions</A></H3>
 <A HREF="manual.html#pdf-_G">_G</A><BR>
 <A HREF="manual.html#pdf-_VERSION">_VERSION</A><BR>
@@ -144,16 +187,16 @@
 <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>
 
-</TD>
-<TD WIDTH="30%">
-<H3>&nbsp;</H3>
 <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>
 <A HREF="manual.html#pdf-coroutine.status">coroutine.status</A><BR>
 <A HREF="manual.html#pdf-coroutine.wrap">coroutine.wrap</A><BR>
 <A HREF="manual.html#pdf-coroutine.yield">coroutine.yield</A><BR>
+<P>
+
 <A HREF="manual.html#pdf-debug.debug">debug.debug</A><BR>
 <A HREF="manual.html#pdf-debug.getfenv">debug.getfenv</A><BR>
 <A HREF="manual.html#pdf-debug.gethook">debug.gethook</A><BR>
@@ -168,6 +211,10 @@
 <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>
+
+</TD>
+<TD>
+<H3>&nbsp;</H3>
 <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:lines">file:lines</A><BR>
@@ -175,6 +222,8 @@
 <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:write">file:write</A><BR>
+<P>
+
 <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.input">io.input</A><BR>
@@ -183,17 +232,22 @@
 <A HREF="manual.html#pdf-io.output">io.output</A><BR>
 <A HREF="manual.html#pdf-io.popen">io.popen</A><BR>
 <A HREF="manual.html#pdf-io.read">io.read</A><BR>
+<A HREF="manual.html#pdf-io.stderr">io.stderr</A><BR>
+<A HREF="manual.html#pdf-io.stdin">io.stdin</A><BR>
+<A HREF="manual.html#pdf-io.stdout">io.stdout</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.write">io.write</A><BR>
+<P>
+
 <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.asin">math.asin</A><BR>
+<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
 <A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
-<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
 <A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>
+<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
 <A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
-<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
 <A HREF="manual.html#pdf-math.deg">math.deg</A><BR>
 <A HREF="manual.html#pdf-math.exp">math.exp</A><BR>
 <A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
@@ -201,8 +255,8 @@
 <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.log">math.log</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.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>
@@ -211,11 +265,13 @@
 <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.randomseed">math.randomseed</A><BR>
+<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
 <A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
-<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
 <A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
+<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
 <A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
-<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
+<P>
+
 <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.difftime">os.difftime</A><BR>
@@ -227,12 +283,17 @@
 <A HREF="manual.html#pdf-os.setlocale">os.setlocale</A><BR>
 <A HREF="manual.html#pdf-os.time">os.time</A><BR>
 <A HREF="manual.html#pdf-os.tmpname">os.tmpname</A><BR>
+<P>
+
 <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.seeall">package.seeall</A><BR>
+<P>
+
 <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.dump">string.dump</A><BR>
@@ -247,6 +308,8 @@
 <A HREF="manual.html#pdf-string.reverse">string.reverse</A><BR>
 <A HREF="manual.html#pdf-string.sub">string.sub</A><BR>
 <A HREF="manual.html#pdf-string.upper">string.upper</A><BR>
+<P>
+
 <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>
@@ -254,7 +317,7 @@
 <A HREF="manual.html#pdf-table.sort">table.sort</A><BR>
 
 </TD>
-<TD WIDTH="25%">
+<TD>
 <H3>C API</H3>
 <A HREF="manual.html#lua_Alloc">lua_Alloc</A><BR>
 <A HREF="manual.html#lua_CFunction">lua_CFunction</A><BR>
@@ -265,6 +328,8 @@
 <A HREF="manual.html#lua_Reader">lua_Reader</A><BR>
 <A HREF="manual.html#lua_State">lua_State</A><BR>
 <A HREF="manual.html#lua_Writer">lua_Writer</A><BR>
+<P>
+
 <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_checkstack">lua_checkstack</A><BR>
@@ -296,6 +361,8 @@
 <A HREF="manual.html#lua_isfunction">lua_isfunction</A><BR>
 <A HREF="manual.html#lua_islightuserdata">lua_islightuserdata</A><BR>
 <A HREF="manual.html#lua_isnil">lua_isnil</A><BR>
+<A HREF="manual.html#lua_isnone">lua_isnone</A><BR>
+<A HREF="manual.html#lua_isnoneornil">lua_isnoneornil</A><BR>
 <A HREF="manual.html#lua_isnumber">lua_isnumber</A><BR>
 <A HREF="manual.html#lua_isstring">lua_isstring</A><BR>
 <A HREF="manual.html#lua_istable">lua_istable</A><BR>
@@ -317,6 +384,7 @@
 <A HREF="manual.html#lua_pushfstring">lua_pushfstring</A><BR>
 <A HREF="manual.html#lua_pushinteger">lua_pushinteger</A><BR>
 <A HREF="manual.html#lua_pushlightuserdata">lua_pushlightuserdata</A><BR>
+<A HREF="manual.html#lua_pushliteral">lua_pushliteral</A><BR>
 <A HREF="manual.html#lua_pushlstring">lua_pushlstring</A><BR>
 <A HREF="manual.html#lua_pushnil">lua_pushnil</A><BR>
 <A HREF="manual.html#lua_pushnumber">lua_pushnumber</A><BR>
@@ -364,6 +432,8 @@
 <H3>auxiliary library</H3>
 <A HREF="manual.html#luaL_Buffer">luaL_Buffer</A><BR>
 <A HREF="manual.html#luaL_Reg">luaL_Reg</A><BR>
+<P>
+
 <A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR>
 <A HREF="manual.html#luaL_addlstring">luaL_addlstring</A><BR>
 <A HREF="manual.html#luaL_addsize">luaL_addsize</A><BR>
@@ -419,10 +489,10 @@
 <HR>
 <SMALL>
 Last update:
-Tue Jun  6 14:55:31 BRT 2006
+Sat Jan 19 13:24:29 BRST 2008
 </SMALL>
 <!--
-Last change: reformatted index
+Last change: revised for Lua 5.1.3
 -->
 
 </BODY>
Binary file src/lua-5.1.1/doc/cover.png has changed
--- a/src/lua-5.1.1/doc/lua.css	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/doc/lua.css	Tue Mar 18 02:05:22 2008 +0000
@@ -2,16 +2,24 @@
 	color: #000000 ;
 	background-color: #FFFFFF ;
 	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 {
 	color: #000080 ;
-	background-color: #FFFFFF ;
+	background-color: inherit ;
 	text-decoration: none ;
 }
 
 a:visited {
-	background-color: #FFFFFF ;
+	background-color: inherit ;
 	text-decoration: none ;
 }
 
@@ -20,3 +28,14 @@
 	background-color: #E0E0FF ;
 }
 
+a:link:active, a:visited:active {
+	color: #FF0000 ;
+}
+
+hr {
+	border: 0 ;
+	height: 1px ;
+	color: #a0a0a0 ;
+	background-color: #a0a0a0 ;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lua-5.1.1/doc/manual.css	Tue Mar 18 02:05:22 2008 +0000
@@ -0,0 +1,13 @@
+h3 code {
+	font-family: inherit ;
+}
+
+pre {
+	font-size: 105% ;
+}
+
+span.apii {
+	float: right ;
+	font-family: inherit ;
+}
+
--- a/src/lua-5.1.1/doc/manual.html	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/doc/manual.html	Tue Mar 18 02:05:22 2008 +0000
@@ -1,9 +1,11 @@
-<!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.1 Reference Manual</title>
 <link rel="stylesheet" href="lua.css">
+<link rel="stylesheet" href="manual.css">
+<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
 </head>
 
 <body>
@@ -17,14 +19,21 @@
 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
 <p>
 <small>
-<a href="http://www.lua.org/copyright.html">Copyright</a>
-&copy; 2006 Lua.org, PUC-Rio.  All rights reserved.
+Copyright &copy; 2006-2008 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.45 2008/01/19 00:17:30 roberto Exp $ -->
 
 
 
@@ -71,7 +80,7 @@
 For a discussion of the decisions behind the design of Lua,
 see the technical papers available at Lua's web site.
 For a detailed introduction to programming in Lua,
-see Roberto's book, <em>Programming in Lua</em>.
+see Roberto's book, <em>Programming in Lua (Second Edition)</em>.
 
 
 
@@ -171,6 +180,7 @@
 
 <p>
 To put a double (single) quote, a newline, a backslash,
+a carriage return,
 or an embedded zero
 inside a literal string enclosed by double (single) quotes
 you must use an escape sequence.
@@ -390,8 +400,8 @@
 
 
 <p>
-Variables are assumed to be global unless explicitly declared local
-(see <a href="#2.4.7">&sect;2.4.7</a>).
+Any variable is assumed to be global unless explicitly declared
+as a local (see <a href="#2.4.7">&sect;2.4.7</a>).
 Local variables are <em>lexically scoped</em>:
 local variables can be freely accessed by functions
 defined inside their scope (see <a href="#2.6">&sect;2.6</a>).
@@ -547,9 +557,9 @@
 The elements in both lists are separated by commas:
 
 <pre>
-	stat ::= varlist1 `<b>=</b>&acute; explist1
-	varlist1 ::= var {`<b>,</b>&acute; var}
-	explist1 ::= exp {`<b>,</b>&acute; exp}
+	stat ::= varlist `<b>=</b>&acute; explist
+	varlist ::= var {`<b>,</b>&acute; var}
+	explist ::= exp {`<b>,</b>&acute; exp}
 </pre><p>
 Expressions are discussed in <a href="#2.5">&sect;2.5</a>.
 
@@ -656,7 +666,7 @@
 so the syntax for the <b>return</b> statement is
 
 <pre>
-	stat ::= <b>return</b> [explist1]
+	stat ::= <b>return</b> [explist]
 </pre>
 
 <p>
@@ -708,18 +718,18 @@
 More precisely, a <b>for</b> statement like
 
 <pre>
-     for var = e1, e2, e3 do block end
+     for v = <em>e1</em>, <em>e2</em>, <em>e3</em> do <em>block</em> end
 </pre><p>
 is equivalent to the code:
 
 <pre>
      do
-       local _var, _limit, _step = tonumber(e1), tonumber(e2), tonumber(e3)
-       if not (_var and _limit and _step) then error() end
-       while (_step&gt;0 and _var&lt;=_limit) or (_step&lt;=0 and _var&gt;=_limit) do
-         local var = _var
+       local <em>var</em>, <em>limit</em>, <em>step</em> = tonumber(<em>e1</em>), tonumber(<em>e2</em>), tonumber(<em>e3</em>)
+       if not (<em>var</em> and <em>limit</em> and <em>step</em>) then error() end
+       while (<em>step</em> &gt; 0 and <em>var</em> &lt;= <em>limit</em>) or (<em>step</em> &lt;= 0 and <em>var</em> &gt;= <em>limit</em>) do
+         local v = <em>var</em>
          <em>block</em>
-         _var = _var + _step
+         <em>var</em> = <em>var</em> + <em>step</em>
        end
      end
 </pre><p>
@@ -734,7 +744,7 @@
 </li>
 
 <li>
-<code>_var</code>, <code>_limit</code>, and <code>_step</code> are invisible variables.
+<code><em>var</em></code>, <code><em>limit</em></code>, and <code><em>step</em></code> are invisible variables.
 The names are here for explanatory purposes only.
 </li>
 
@@ -748,10 +758,10 @@
 </li>
 
 <li>
-The loop variable <code>var</code> is local to the loop;
+The loop variable <code>v</code> is local to the loop;
 you cannot use its value after the <b>for</b> ends or is broken.
-If you need the value of the loop variable <code>var</code>,
-then assign it to another variable before breaking or exiting the loop.
+If you need this value,
+assign it to another variable before breaking or exiting the loop.
 </li>
 
 </ul>
@@ -764,24 +774,24 @@
 The generic <b>for</b> loop has the following syntax:
 
 <pre>
-	stat ::= <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b>
+	stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
 	namelist ::= Name {`<b>,</b>&acute; Name}
 </pre><p>
 A <b>for</b> statement like
 
 <pre>
-     for var_1, &middot;&middot;&middot;, var_n in explist do block end
+     for <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> in <em>explist</em> do <em>block</em> end
 </pre><p>
 is equivalent to the code:
 
 <pre>
      do
-       local _f, _s, _var = explist
+       local <em>f</em>, <em>s</em>, <em>var</em> = <em>explist</em>
        while true do
-         local var_1, &middot;&middot;&middot;, var_n = _f(_s, _var)
-         _var = var_1
-         if _var == nil then break end
-         block
+         local <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> = <em>f</em>(<em>s</em>, <em>var</em>)
+         <em>var</em> = <em>var_1</em>
+         if <em>var</em> == nil then break end
+         <em>block</em>
        end
      end
 </pre><p>
@@ -790,13 +800,14 @@
 <ul>
 
 <li>
-<code>explist</code> is evaluated only once.
+<code><em>explist</em></code> is evaluated only once.
 Its results are an <em>iterator</em> function,
-a <em>state</em>, and an initial value for the first <em>iterator variable</em>.
+a <em>state</em>,
+and an initial value for the first <em>iterator variable</em>.
 </li>
 
 <li>
-<code>_f</code>, <code>_s</code>, and <code>_var</code> are invisible variables.
+<code><em>f</em></code>, <code><em>s</em></code>, and <code><em>var</em></code> are invisible variables.
 The names are here for explanatory purposes only.
 </li>
 
@@ -805,7 +816,7 @@
 </li>
 
 <li>
-The loop variables <code>var_i</code> are local to the loop;
+The loop variables <code><em>var_i</em></code> are local to the loop;
 you cannot use their values after the <b>for</b> ends.
 If you need these values,
 then assign them to other variables before breaking or exiting the loop.
@@ -835,7 +846,7 @@
 The declaration may include an initial assignment:
 
 <pre>
-	stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist1]
+	stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist]
 </pre><p>
 If present, an initial assignment has the same semantics
 of a multiple assignment (see <a href="#2.4.3">&sect;2.4.3</a>).
@@ -882,8 +893,8 @@
 function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>;
 table constructors are explained in <a href="#2.5.7">&sect;2.5.7</a>.
 Vararg expressions,
-denoted by three dots ('<code>...</code>'), can only be used inside
-vararg functions;
+denoted by three dots ('<code>...</code>'), can only be used when
+directly inside a vararg function;
 they are explained in <a href="#2.5.9">&sect;2.5.9</a>.
 
 
@@ -902,13 +913,13 @@
 (only possible for function calls),
 then its return list is adjusted to zero elements,
 thus discarding all returned values.
-If the expression is used inside another expression
-or in the middle of a list of expressions,
-then its result list is adjusted to one element,
-thus discarding all values except the first one.
-If the expression is used as the last element of a list of expressions,
-then no adjustment is made,
-unless the call is enclosed in parentheses.
+If the expression is used as the last (or the only) element
+of a list of expressions,
+then no adjustment is made
+(unless the call is enclosed in parentheses).
+In all other contexts,
+Lua adjusts the result list to one element,
+discarding all values except the first one.
 
 
 <p>
@@ -917,17 +928,18 @@
 <pre>
      f()                -- adjusted to 0 results
      g(f(), x)          -- f() is adjusted to 1 result
-     g(x, f())          -- g gets x plus all values returned by f()
+     g(x, f())          -- g gets x plus all results from f()
      a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)
      a,b = ...          -- a gets the first vararg parameter, b gets
-                        -- the second (both a and b may get nil if there is
-                        -- no corresponding vararg parameter)
+                        -- the second (both a and b may get nil if there
+                        -- is no corresponding vararg parameter)
+     
      a,b,c = x, f()     -- f() is adjusted to 2 results
      a,b,c = f()        -- f() is adjusted to 3 results
-     return f()         -- returns all values returned by f()
+     return f()         -- returns all results from f()
      return ...         -- returns all received vararg parameters
-     return x,y,f()     -- returns x, y, and all values returned by f()
-     {f()}              -- creates a list with all values returned by f()
+     return x,y,f()     -- returns x, y, and all results from f()
+     {f()}              -- creates a list with all results from f()
      {...}              -- creates a list with all vararg parameters
      {f(), nil}         -- f() is adjusted to 1 result
 </pre>
@@ -1212,7 +1224,7 @@
 Arguments have the following syntax:
 
 <pre>
-	args ::= `<b>(</b>&acute; [explist1] `<b>)</b>&acute;
+	args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute;
 	args ::= tableconstructor
 	args ::= String
 </pre><p>
@@ -1277,7 +1289,7 @@
 
 <pre>
 	function ::= <b>function</b> funcbody
-	funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
+	funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
 </pre>
 
 <p>
@@ -1346,7 +1358,7 @@
 initialized with the argument values:
 
 <pre>
-	parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
+	parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
 </pre><p>
 When a function is called,
 the list of arguments is adjusted to
@@ -1542,12 +1554,11 @@
 
 
 <p>
-Tables and userdata have individual metatables
-(although multiple tables and userdata can share
-a same table as their metatable);
+Tables and full userdata have individual metatables
+(although multiple tables and userdata can share their metatables);
 values of all other types share one single metatable per type.
 So, there is one single metatable for all numbers,
-and for all strings, etc.
+one for all strings, etc.
 
 
 <p>
@@ -1592,6 +1603,7 @@
 <pre>
      rawget(getmetatable(obj) or {}, event)
 </pre><p>
+
 That is, the access to a metamethod does not invoke other metamethods,
 and the access to objects with no metatables does not fail
 (it simply results in <b>nil</b>).
@@ -1629,7 +1641,7 @@
          local h = getbinhandler(op1, op2, "__add")
          if h then
            -- call the handler with both operands
-           return h(op1, op2)
+           return (h(op1, op2))
          else  -- no handler available: default behavior
            error(&middot;&middot;&middot;)
          end
@@ -1686,7 +1698,7 @@
          local h = metatable(op).__unm
          if h then
            -- call the handler with the operand
-           return h(op)
+           return (h(op))
          else  -- no handler available: default behavior
            error(&middot;&middot;&middot;)
          end
@@ -1707,7 +1719,7 @@
        else
          local h = getbinhandler(op1, op2, "__concat")
          if h then
-           return h(op1, op2)
+           return (h(op1, op2))
          else
            error(&middot;&middot;&middot;)
          end
@@ -1730,7 +1742,7 @@
          local h = metatable(op).__len
          if h then
            -- call the handler with the operand
-           return h(op)
+           return (h(op))
          else  -- no handler available: default behavior
            error(&middot;&middot;&middot;)
          end
@@ -1770,7 +1782,7 @@
        -- try metamethod
        local h = getcomphandler(op1, op2, "__eq")
        if h then
-         return h(op1, op2)
+         return (h(op1, op2))
        else
          return false
        end
@@ -1792,7 +1804,7 @@
        else
          local h = getcomphandler(op1, op2, "__lt")
          if h then
-           return h(op1, op2)
+           return (h(op1, op2))
          else
            error(&middot;&middot;&middot;);
          end
@@ -1815,7 +1827,7 @@
        else
          local h = getcomphandler(op1, op2, "__le")
          if h then
-           return h(op1, op2)
+           return (h(op1, op2))
          else
            h = getcomphandler(op1, op2, "__lt")
            if h then
@@ -1852,8 +1864,8 @@
          end
        end
        if type(h) == "function" then
-         return h(table, key)      -- call the handler
-       else return h[key]          -- or repeat operation on it
+         return (h(table, key))     -- call the handler
+       else return h[key]           -- or repeat operation on it
        end
      end
 </pre><p>
@@ -1878,7 +1890,7 @@
          end
        end
        if type(h) == "function" then
-         return h(table, key,value)    -- call the handler
+         h(table, key,value)           -- call the handler
        else h[key] = value             -- or repeat operation on it
        end
      end
@@ -2053,6 +2065,7 @@
 among those collected in that cycle.
 That is, the first finalizer to be called is the one associated
 with the userdata created last in the program.
+The userdata itself is freed only in the next garbage-collection cycle.
 
 
 
@@ -2077,7 +2090,7 @@
 both keys and values.
 In any case, if either the key or the value is collected,
 the whole pair is removed from the table.
-The weakness of a table is controlled by the value of the
+The weakness of a table is controlled by the
 <code>__mode</code> field of its metatable.
 If the <code>__mode</code> field is a string containing the character&nbsp;'<code>k</code>',
 the keys in the table are weak.
@@ -2156,8 +2169,8 @@
 
 
 <p>
-The <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function creates a coroutine,
-just like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
+Like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
+the <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function also creates a coroutine,
 but instead of returning the coroutine itself,
 it returns a function that, when called, resumes the coroutine.
 Any arguments passed to this function
@@ -2198,6 +2211,7 @@
 <pre>
      co-body 1       10
      foo     2
+     
      main    true    4
      co-body r
      main    true    11      -9
@@ -2268,7 +2282,7 @@
 and
 index&nbsp;<em>n</em> represents the last element;
 index&nbsp;-1 also represents the last element
-(that is, the element at the top)
+(that is, the element at the&nbsp;top)
 and index <em>-n</em> represents the first element.
 We say that an index is <em>valid</em>
 if it lies between&nbsp;1 and the stack top
@@ -2417,17 +2431,14 @@
 
 
 <p>
-Almost any function in the API may raise an error,
+Most functions in the API may throw an error,
 for instance due to a memory allocation error.
-The following functions run in protected mode
-(that is, they create a protected environment to run),
-so they never raise an error:
-<a href="#lua_newstate"><code>lua_newstate</code></a>, <a href="#lua_close"><code>lua_close</code></a>, <a href="#lua_load"><code>lua_load</code></a>,
-<a href="#lua_pcall"><code>lua_pcall</code></a>, and <a href="#lua_cpcall"><code>lua_cpcall</code></a>.
-
-
-<p>
-Inside a C&nbsp;function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
+The documentation for each function indicates whether
+it can throw errors.
+
+
+<p>
+Inside a C&nbsp;function you can throw an error by calling <a href="#lua_error"><code>lua_error</code></a>.
 
 
 
@@ -2438,6 +2449,30 @@
 <p>
 Here we list all functions and types from the C&nbsp;API in
 alphabetical order.
+Each function has an indicator like this:
+<span class="apii">[-o, +p, <em>x</em>]</span>
+
+
+<p>
+The first field, <code>o</code>,
+is how many elements the function pops from the stack.
+The second field, <code>p</code>,
+is how many elements the function pushes onto the stack.
+(Any function always pushes its results after popping its arguments.)
+A field in the form <code>x|y</code> means the function may push (or pop)
+<code>x</code> or <code>y</code> elements,
+depending on the situation;
+an interrogation mark '<code>?</code>' means that
+we cannot know how many elements the function pops/pushes
+by looking only at its arguments
+(e.g., they may depend on what is on the stack).
+The third field, <code>x</code>,
+tells whether the function may throw errors:
+'<code>-</code>' means the function never throws any error;
+'<code>m</code>' means the function may throw an error
+only due to not enough memory;
+'<code>e</code>' means the function may throw other kinds of errors;
+'<code>v</code>' means the function may throw an error on purpose.
 
 
 
@@ -2473,26 +2508,31 @@
 
 <p>
 Here is a simple implementation for the allocator function.
-It is used in the auxiliary library by <a href="#lua_newstate"><code>lua_newstate</code></a>.
+It is used in the auxiliary library by <a href="#luaL_newstate"><code>luaL_newstate</code></a>.
 
 <pre>
-     static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
-       (void)ud;     /* not used */
-       (void)osize;  /* not used */
+     static void *l_alloc (void *ud, void *ptr, size_t osize,
+                                                size_t nsize) {
+       (void)ud;  (void)osize;  /* not used */
        if (nsize == 0) {
-         free(ptr);  /* ANSI requires that free(NULL) has no effect */
+         free(ptr);
          return NULL;
        }
        else
-         /* ANSI requires that realloc(NULL, size) == malloc(size) */
          return realloc(ptr, nsize);
      }
-</pre>
-
-
-
-
-<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3>
+</pre><p>
+This code assumes
+that <code>free(NULL)</code> has no effect and that
+<code>realloc(NULL, size)</code> is equivalent to <code>malloc(size)</code>.
+ANSI&nbsp;C ensures both behaviors.
+
+
+
+
+
+<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
 
 <p>
@@ -2515,7 +2555,8 @@
 
 
 
-<hr><h3><a name="lua_call"><code>lua_call</code></a></h3>
+<hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
+<span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
 <pre>void lua_call (lua_State *L, int nargs, int nresults);</pre>
 
 <p>
@@ -2557,14 +2598,14 @@
 Here it is in&nbsp;C:
 
 <pre>
-     lua_getfield(L, LUA_GLOBALSINDEX, "f");          /* function to be called */
-     lua_pushstring(L, "how");                                 /* 1st argument */
-     lua_getfield(L, LUA_GLOBALSINDEX, "t");            /* table to be indexed */
-     lua_getfield(L, -1, "x");                 /* push result of t.x (2nd arg) */
-     lua_remove(L, -2);                           /* remove 't' from the stack */
-     lua_pushinteger(L, 14);                                   /* 3rd argument */
-     lua_call(L, 3, 1);         /* call function with 3 arguments and 1 result */
-     lua_setfield(L, LUA_GLOBALSINDEX, "a");        /* set global variable 'a' */
+     lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* function to be called */
+     lua_pushstring(L, "how");                        /* 1st argument */
+     lua_getfield(L, LUA_GLOBALSINDEX, "t");   /* table to be indexed */
+     lua_getfield(L, -1, "x");        /* push result of t.x (2nd arg) */
+     lua_remove(L, -2);                  /* remove 't' from the stack */
+     lua_pushinteger(L, 14);                          /* 3rd argument */
+     lua_call(L, 3, 1);     /* call 'f' with 3 arguments and 1 result */
+     lua_setfield(L, LUA_GLOBALSINDEX, "a");        /* set global 'a' */
 </pre><p>
 Note that the code above is "balanced":
 at its end, the stack is back to its original configuration.
@@ -2611,7 +2652,7 @@
        int i;
        for (i = 1; i &lt;= n; i++) {
          if (!lua_isnumber(L, i)) {
-           lua_pushstring(L, "incorrect argument to function 'average'");
+           lua_pushstring(L, "incorrect argument");
            lua_error(L);
          }
          sum += lua_tonumber(L, i);
@@ -2625,7 +2666,8 @@
 
 
 
-<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3>
+<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>int lua_checkstack (lua_State *L, int extra);</pre>
 
 <p>
@@ -2639,7 +2681,8 @@
 
 
 
-<hr><h3><a name="lua_close"><code>lua_close</code></a></h3>
+<hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>void lua_close (lua_State *L);</pre>
 
 <p>
@@ -2657,23 +2700,25 @@
 
 
 
-<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3>
+<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
+<span class="apii">[-n, +1, <em>e</em>]</span>
 <pre>void lua_concat (lua_State *L, int n);</pre>
 
 <p>
 Concatenates the <code>n</code> values at the top of the stack,
 pops them, and leaves the result at the top.
-If <code>n</code>&nbsp;is&nbsp;1, the result is the single string on the stack
+If <code>n</code>&nbsp;is&nbsp;1, the result is the single value on the stack
 (that is, the function does nothing);
 if <code>n</code> is 0, the result is the empty string.
-Concatenation is done following the usual semantics of Lua
+Concatenation is performed following the usual semantics of Lua
 (see <a href="#2.5.4">&sect;2.5.4</a>).
 
 
 
 
 
-<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3>
+<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
 <pre>int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);</pre>
 
 <p>
@@ -2690,7 +2735,8 @@
 
 
 
-<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3>
+<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void lua_createtable (lua_State *L, int narr, int nrec);</pre>
 
 <p>
@@ -2705,7 +2751,8 @@
 
 
 
-<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3>
+<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>int lua_dump (lua_State *L, lua_Writer writer, void *data);</pre>
 
 <p>
@@ -2723,7 +2770,7 @@
 <p>
 The value returned is the error code returned by the last
 call to the writer;
-0 means no errors.
+0&nbsp;means no errors.
 
 
 <p>
@@ -2733,7 +2780,8 @@
 
 
 
-<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3>
+<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
 <pre>int lua_equal (lua_State *L, int index1, int index2);</pre>
 
 <p>
@@ -2748,7 +2796,8 @@
 
 
 
-<hr><h3><a name="lua_error"><code>lua_error</code></a></h3>
+<hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
+<span class="apii">[-1, +0, <em>v</em>]</span>
 <pre>int lua_error (lua_State *L);</pre>
 
 <p>
@@ -2763,7 +2812,8 @@
 
 
 
-<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3>
+<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
 <pre>int lua_gc (lua_State *L, int what, int data);</pre>
 
 <p>
@@ -2814,7 +2864,7 @@
 </li>
 
 <li><b><code>LUA_GCSETSTEPMUL</code>:</b>
-sets <code>arg</code>/100 as the new value for the <em>step multiplier</em> of
+sets <code>data</code>/100 as the new value for the <em>step multiplier</em> of
 the collector (see <a href="#2.10">&sect;2.10</a>).
 The function returns the previous value of the step multiplier.
 </li>
@@ -2824,7 +2874,8 @@
 
 
 
-<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3>
+<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
 
 <p>
@@ -2836,7 +2887,8 @@
 
 
 
-<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3>
+<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_getfenv (lua_State *L, int index);</pre>
 
 <p>
@@ -2847,12 +2899,13 @@
 
 
 
-<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3>
+<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
+<span class="apii">[-0, +1, <em>e</em>]</span>
 <pre>void lua_getfield (lua_State *L, int index, const char *k);</pre>
 
 <p>
 Pushes onto the stack the value <code>t[k]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>.
+where <code>t</code> is the value at the given valid index.
 As in Lua, this function may trigger a metamethod
 for the "index" event (see <a href="#2.8">&sect;2.8</a>).
 
@@ -2860,7 +2913,8 @@
 
 
 
-<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3>
+<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
+<span class="apii">[-0, +1, <em>e</em>]</span>
 <pre>void lua_getglobal (lua_State *L, const char *name);</pre>
 
 <p>
@@ -2874,7 +2928,8 @@
 
 
 
-<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3>
+<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
 <pre>int lua_getmetatable (lua_State *L, int index);</pre>
 
 <p>
@@ -2888,12 +2943,13 @@
 
 
 
-<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3>
+<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
+<span class="apii">[-1, +1, <em>e</em>]</span>
 <pre>void lua_gettable (lua_State *L, int index);</pre>
 
 <p>
 Pushes onto the stack the value <code>t[k]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
+where <code>t</code> is the value at the given valid index
 and <code>k</code> is the value at the top of the stack.
 
 
@@ -2907,7 +2963,8 @@
 
 
 
-<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3>
+<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_gettop (lua_State *L);</pre>
 
 <p>
@@ -2920,7 +2977,8 @@
 
 
 
-<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3>
+<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
+<span class="apii">[-1, +1, <em>-</em>]</span>
 <pre>void lua_insert (lua_State *L, int index);</pre>
 
 <p>
@@ -2942,126 +3000,164 @@
 
 <p>
 By default it is a <code>ptrdiff_t</code>,
-which is usually the largest integral type the machine handles
+which is usually the largest signed integral type the machine handles
 "comfortably".
 
 
 
 
 
-<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3>
+<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isboolean (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index has type boolean,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_iscfunction (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a C&nbsp;function,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isfunction (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a function
-(either C or Lua), and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3>
+(either C or Lua), and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_islightuserdata (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a light userdata,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isnil (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is <b>nil</b>,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>int lua_isnone (lua_State *L, int index);</pre>
+
+<p>
+Returns 1 if the given acceptable index is not valid
+(that is, it refers to an element outside the current stack),
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>int lua_isnoneornil (lua_State *L, int index);</pre>
+
+<p>
+Returns 1 if the given acceptable index is not valid
+(that is, it refers to an element outside the current stack)
+or if the value at this index is <b>nil</b>,
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isnumber (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a number
 or a string convertible to a number,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isstring (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a string
 or a number (which is always convertible to a string),
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_istable (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a table,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isthread (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a thread,
-and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3>
+and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_isuserdata (lua_State *L, int index);</pre>
 
 <p>
 Returns 1 if the value at the given acceptable index is a userdata
-(either full or light), and 0 otherwise.
-
-
-
-
-
-<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3>
+(either full or light), and 0&nbsp;otherwise.
+
+
+
+
+
+<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
 <pre>int lua_lessthan (lua_State *L, int index1, int index2);</pre>
 
 <p>
@@ -3076,7 +3172,8 @@
 
 
 
-<hr><h3><a name="lua_load"><code>lua_load</code></a></h3>
+<hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>int lua_load (lua_State *L,
               lua_Reader reader,
               void *data,
@@ -3113,8 +3210,8 @@
 
 
 <p>
-<a href="#lua_load"><code>lua_load</code></a> uses a user-supplied <code>reader</code> function to read the chunk
-(see <a href="#lua_Reader"><code>lua_Reader</code></a>).
+The <a href="#lua_load"><code>lua_load</code></a> function uses a user-supplied <code>reader</code> function
+to read the chunk (see <a href="#lua_Reader"><code>lua_Reader</code></a>).
 The <code>data</code> argument is an opaque value passed to the reader function.
 
 
@@ -3126,7 +3223,8 @@
 
 
 
-<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3>
+<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_State *lua_newstate (lua_Alloc f, void *ud);</pre>
 
 <p>
@@ -3142,7 +3240,8 @@
 
 
 
-<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3>
+<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void lua_newtable (lua_State *L);</pre>
 
 <p>
@@ -3153,7 +3252,8 @@
 
 
 
-<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3>
+<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>lua_State *lua_newthread (lua_State *L);</pre>
 
 <p>
@@ -3173,7 +3273,8 @@
 
 
 
-<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3>
+<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void *lua_newuserdata (lua_State *L, size_t size);</pre>
 
 <p>
@@ -3183,7 +3284,7 @@
 
 
 <p>
-Userdata represents C&nbsp;values in Lua.
+Userdata represent C&nbsp;values in Lua.
 A <em>full userdata</em> represents a block of memory.
 It is an object (like a table):
 you must create it, it can have its own metatable,
@@ -3201,7 +3302,8 @@
 
 
 
-<hr><h3><a name="lua_next"><code>lua_next</code></a></h3>
+<hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
+<span class="apii">[-1, +(2|0), <em>e</em>]</span>
 <pre>int lua_next (lua_State *L, int index);</pre>
 
 <p>
@@ -3219,10 +3321,12 @@
      /* table is in the stack at index 't' */
      lua_pushnil(L);  /* first key */
      while (lua_next(L, t) != 0) {
-       /* 'key' is at index -2 and 'value' at index -1 */
+       /* uses 'key' (at index -2) and 'value' (at index -1) */
        printf("%s - %s\n",
-         lua_typename(L, lua_type(L, -2)), lua_typename(L, lua_type(L, -1)));
-       lua_pop(L, 1);  /* removes 'value'; keeps 'key' for next iteration */
+              lua_typename(L, lua_type(L, -2)),
+              lua_typename(L, lua_type(L, -1)));
+       /* removes 'value'; keeps 'key' for next iteration */
+       lua_pop(L, 1);
      }
 </pre>
 
@@ -3254,7 +3358,8 @@
 
 
 
-<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3>
+<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>size_t lua_objlen (lua_State *L, int index);</pre>
 
 <p>
@@ -3269,8 +3374,9 @@
 
 
 
-<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3>
-<pre>lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);</pre>
+<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
+<span class="apii">[-(nargs + 1), +(nresults|1), <em>-</em>]</span>
+<pre>int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);</pre>
 
 <p>
 Calls a function in protected mode.
@@ -3334,7 +3440,8 @@
 
 
 
-<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3>
+<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
+<span class="apii">[-n, +0, <em>-</em>]</span>
 <pre>void lua_pop (lua_State *L, int n);</pre>
 
 <p>
@@ -3344,7 +3451,8 @@
 
 
 
-<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3>
+<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushboolean (lua_State *L, int b);</pre>
 
 <p>
@@ -3354,7 +3462,8 @@
 
 
 
-<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3>
+<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
+<span class="apii">[-n, +1, <em>m</em>]</span>
 <pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
 
 <p>
@@ -3379,7 +3488,8 @@
 
 
 
-<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3>
+<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
 
 <p>
@@ -3396,14 +3506,17 @@
 
 
 <p>
-The call <code>lua_pushcfunction(L, f)</code> is equivalent to
-<code>lua_pushcclosure(L, f, 0)</code>.
-
-
-
-
-
-<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3>
+<code>lua_pushcfunction</code> is defined as a macro:
+
+<pre>
+     #define lua_pushcfunction(L,f)  lua_pushcclosure(L,f,0)
+</pre>
+
+
+
+
+<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
 
 <p>
@@ -3437,7 +3550,8 @@
 
 
 
-<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3>
+<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
 
 <p>
@@ -3447,7 +3561,8 @@
 
 
 
-<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3>
+<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushlightuserdata (lua_State *L, void *p);</pre>
 
 <p>
@@ -3455,7 +3570,7 @@
 
 
 <p>
-Userdata represents C&nbsp;values in Lua.
+Userdata represent C&nbsp;values in Lua.
 A <em>light userdata</em> represents a pointer.
 It is a value (like a number):
 you do not create it, it has no individual metatable,
@@ -3467,7 +3582,21 @@
 
 
 
-<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3>
+<hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
+<pre>void lua_pushliteral (lua_State *L, const char *s);</pre>
+
+<p>
+This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,
+but can be used only when <code>s</code> is a literal string.
+In these cases, it automatically provides the string length.
+
+
+
+
+
+<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
 
 <p>
@@ -3482,7 +3611,8 @@
 
 
 
-<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3>
+<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushnil (lua_State *L);</pre>
 
 <p>
@@ -3492,7 +3622,8 @@
 
 
 
-<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3>
+<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushnumber (lua_State *L, lua_Number n);</pre>
 
 <p>
@@ -3502,7 +3633,8 @@
 
 
 
-<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3>
+<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void lua_pushstring (lua_State *L, const char *s);</pre>
 
 <p>
@@ -3518,7 +3650,8 @@
 
 
 
-<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3>
+<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>int lua_pushthread (lua_State *L);</pre>
 
 <p>
@@ -3529,7 +3662,8 @@
 
 
 
-<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3>
+<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_pushvalue (lua_State *L, int index);</pre>
 
 <p>
@@ -3540,7 +3674,8 @@
 
 
 
-<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3>
+<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>const char *lua_pushvfstring (lua_State *L,
                               const char *fmt,
                               va_list argp);</pre>
@@ -3553,7 +3688,8 @@
 
 
 
-<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3>
+<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
 
 <p>
@@ -3567,7 +3703,8 @@
 
 
 
-<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3>
+<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
+<span class="apii">[-1, +1, <em>-</em>]</span>
 <pre>void lua_rawget (lua_State *L, int index);</pre>
 
 <p>
@@ -3578,12 +3715,13 @@
 
 
 
-<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3>
+<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void lua_rawgeti (lua_State *L, int index, int n);</pre>
 
 <p>
 Pushes onto the stack the value <code>t[n]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>.
+where <code>t</code> is the value at the given valid index.
 The access is raw;
 that is, it does not invoke metamethods.
 
@@ -3591,7 +3729,8 @@
 
 
 
-<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3>
+<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
+<span class="apii">[-2, +0, <em>m</em>]</span>
 <pre>void lua_rawset (lua_State *L, int index);</pre>
 
 <p>
@@ -3602,13 +3741,14 @@
 
 
 
-<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3>
+<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
 <pre>void lua_rawseti (lua_State *L, int index, int n);</pre>
 
 <p>
 Does the equivalent of <code>t[n] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
-and <code>v</code> is the value at the top of the stack,
+where <code>t</code> is the value at the given valid index
+and <code>v</code> is the value at the top of the stack.
 
 
 <p>
@@ -3641,21 +3781,26 @@
 
 
 
-<hr><h3><a name="lua_register"><code>lua_register</code></a></h3>
-<pre>void lua_register (lua_State *L, const char *name, lua_CFunction f);</pre>
+<hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
+<pre>void lua_register (lua_State *L,
+                   const char *name,
+                   lua_CFunction f);</pre>
 
 <p>
 Sets the C function <code>f</code> as the new value of global <code>name</code>.
 It is defined as a macro:
 
 <pre>
-     #define lua_register(L,n,f)  (lua_pushcfunction(L, f), lua_setglobal(L, n))
+     #define lua_register(L,n,f) \
+            (lua_pushcfunction(L, f), lua_setglobal(L, n))
 </pre>
 
 
 
 
-<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3>
+<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
 <pre>void lua_remove (lua_State *L, int index);</pre>
 
 <p>
@@ -3668,7 +3813,8 @@
 
 
 
-<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3>
+<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
 <pre>void lua_replace (lua_State *L, int index);</pre>
 
 <p>
@@ -3680,7 +3826,8 @@
 
 
 
-<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3>
+<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
 <pre>int lua_resume (lua_State *L, int narg);</pre>
 
 <p>
@@ -3713,7 +3860,8 @@
 
 
 
-<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3>
+<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
 
 <p>
@@ -3724,7 +3872,8 @@
 
 
 
-<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3>
+<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
 <pre>int lua_setfenv (lua_State *L, int index);</pre>
 
 <p>
@@ -3739,13 +3888,14 @@
 
 
 
-<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3>
+<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
+<span class="apii">[-1, +0, <em>e</em>]</span>
 <pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
 
 <p>
 Does the equivalent to <code>t[k] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
-and <code>v</code> is the value at the top of the stack,
+where <code>t</code> is the value at the given valid index
+and <code>v</code> is the value at the top of the stack.
 
 
 <p>
@@ -3757,7 +3907,8 @@
 
 
 
-<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3>
+<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
+<span class="apii">[-1, +0, <em>e</em>]</span>
 <pre>void lua_setglobal (lua_State *L, const char *name);</pre>
 
 <p>
@@ -3772,7 +3923,8 @@
 
 
 
-<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3>
+<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
 <pre>int lua_setmetatable (lua_State *L, int index);</pre>
 
 <p>
@@ -3784,12 +3936,13 @@
 
 
 
-<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3>
+<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
+<span class="apii">[-2, +0, <em>e</em>]</span>
 <pre>void lua_settable (lua_State *L, int index);</pre>
 
 <p>
 Does the equivalent to <code>t[k] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>,
+where <code>t</code> is the value at the given valid index,
 <code>v</code> is the value at the top of the stack,
 and <code>k</code> is the value just below the top.
 
@@ -3803,7 +3956,8 @@
 
 
 
-<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3>
+<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
 <pre>void lua_settop (lua_State *L, int index);</pre>
 
 <p>
@@ -3836,7 +3990,8 @@
 
 
 
-<hr><h3><a name="lua_status"><code>lua_status</code></a></h3>
+<hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_status (lua_State *L);</pre>
 
 <p>
@@ -3852,7 +4007,8 @@
 
 
 
-<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3>
+<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_toboolean (lua_State *L, int index);</pre>
 
 <p>
@@ -3870,7 +4026,8 @@
 
 
 
-<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3>
+<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
 
 <p>
@@ -3882,8 +4039,9 @@
 
 
 
-<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3>
-<pre>lua_Integer lua_tointeger (lua_State *L, int idx);</pre>
+<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
 
 <p>
 Converts the Lua value at the given acceptable index
@@ -3901,12 +4059,12 @@
 
 
 
-<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3>
+<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
 
 <p>
-Converts the Lua value at the given acceptable index to a string
-(<code>const char*</code>).
+Converts the Lua value at the given acceptable index to a C&nbsp;string.
 If <code>len</code> is not <code>NULL</code>,
 it also sets <code>*len</code> with the string length.
 The Lua value must be a string or a number;
@@ -3932,12 +4090,13 @@
 
 
 
-<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3>
+<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
 
 <p>
 Converts the Lua value at the given acceptable index
-to a number (see <a href="#lua_Number"><code>lua_Number</code></a>).
+to the C&nbsp;type <a href="#lua_Number"><code>lua_Number</code></a> (see <a href="#lua_Number"><code>lua_Number</code></a>).
 The Lua value must be a number or a string convertible to a number
 (see <a href="#2.2.1">&sect;2.2.1</a>);
 otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns&nbsp;0.
@@ -3946,7 +4105,8 @@
 
 
 
-<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3>
+<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>const void *lua_topointer (lua_State *L, int index);</pre>
 
 <p>
@@ -3965,7 +4125,8 @@
 
 
 
-<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3>
+<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>const char *lua_tostring (lua_State *L, int index);</pre>
 
 <p>
@@ -3975,7 +4136,8 @@
 
 
 
-<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3>
+<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
 
 <p>
@@ -3988,7 +4150,8 @@
 
 
 
-<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3>
+<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>void *lua_touserdata (lua_State *L, int index);</pre>
 
 <p>
@@ -4002,7 +4165,8 @@
 
 
 
-<hr><h3><a name="lua_type"><code>lua_type</code></a></h3>
+<hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_type (lua_State *L, int index);</pre>
 
 <p>
@@ -4026,7 +4190,8 @@
 
 
 
-<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3>
+<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>const char *lua_typename  (lua_State *L, int tp);</pre>
 
 <p>
@@ -4044,7 +4209,7 @@
                            void* ud);</pre>
 
 <p>
-The writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
+The type of the writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
 Every time it produces another piece of chunk,
 <a href="#lua_dump"><code>lua_dump</code></a> calls the writer,
 passing along the buffer to be written (<code>p</code>),
@@ -4054,7 +4219,7 @@
 
 <p>
 The writer returns an error code:
-0 means no errors;
+0&nbsp;means no errors;
 any other value means an error and stops <a href="#lua_dump"><code>lua_dump</code></a> from
 calling the writer again.
 
@@ -4062,7 +4227,8 @@
 
 
 
-<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3>
+<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
 <pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
 
 <p>
@@ -4077,7 +4243,8 @@
 
 
 
-<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3>
+<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
 <pre>int lua_yield  (lua_State *L, int nresults);</pre>
 
 <p>
@@ -4209,7 +4376,8 @@
 
 
 
-<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3>
+<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_Hook lua_gethook (lua_State *L);</pre>
 
 <p>
@@ -4219,7 +4387,8 @@
 
 
 
-<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3>
+<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_gethookcount (lua_State *L);</pre>
 
 <p>
@@ -4229,7 +4398,8 @@
 
 
 
-<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3>
+<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_gethookmask (lua_State *L);</pre>
 
 <p>
@@ -4239,7 +4409,8 @@
 
 
 
-<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3>
+<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
+<span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
 <pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
 
 <p>
@@ -4279,8 +4450,8 @@
 </li>
 
 <li><b>'<code>S</code>':</b>
-fills in the fields <code>source</code>, <code>linedefined</code>,
-<code>lastlinedefined</code>, <code>what</code>, and <code>short_src</code>;
+fills in the fields <code>source</code>, <code>short_src</code>,
+<code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;
 </li>
 
 <li><b>'<code>l</code>':</b> fills in the field <code>currentline</code>;
@@ -4312,8 +4483,9 @@
 
 
 
-<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3>
-<pre>const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
+<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
+<pre>const char *lua_getlocal (lua_State *L, lua_Debug *ar, int n);</pre>
 
 <p>
 Gets information about a local variable of a given activation record.
@@ -4342,7 +4514,8 @@
 
 
 
-<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3>
+<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
 
 <p>
@@ -4363,7 +4536,8 @@
 
 
 
-<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3>
+<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
 <pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
 
 <p>
@@ -4423,15 +4597,16 @@
 
 
 
-<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3>
-<pre>int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);</pre>
+<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
 
 <p>
 Sets the debugging hook function.
 
 
 <p>
-<code>func</code> is the hook function.
+Argument <code>f</code> is the hook function.
 <code>mask</code> specifies on which events the hook will be called:
 it is formed by a bitwise or of the constants
 <a name="pdf-LUA_MASKCALL"><code>LUA_MASKCALL</code></a>,
@@ -4474,8 +4649,9 @@
 
 
 
-<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3>
-<pre>const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);</pre>
+<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
+<pre>const char *lua_setlocal (lua_State *L, lua_Debug *ar, int n);</pre>
 
 <p>
 Sets the value of a local variable of a given activation record.
@@ -4495,16 +4671,17 @@
 
 
 
-<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3>
+<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
 <pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
 
 <p>
 Sets the value of a closure's upvalue.
-Parameters <code>funcindex</code> and <code>n</code> are as in <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>
-(see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>).
 It assigns the value at the top of the stack
 to the upvalue and returns its name.
 It also pops the value from the stack.
+Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>
+(see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>).
 
 
 <p>
@@ -4545,7 +4722,7 @@
 Several functions in the auxiliary library are used to
 check C&nbsp;function arguments.
 Their names are always <code>luaL_check*</code> or <code>luaL_opt*</code>.
-All of these functions raise an error if the check is not satisfied.
+All of these functions throw an error if the check is not satisfied.
 Because the error message is formatted for arguments
 (e.g., "<code>bad argument #1</code>"),
 you should not use these functions for other stack values.
@@ -4560,7 +4737,8 @@
 
 
 
-<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3>
+<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
 
 <p>
@@ -4571,7 +4749,8 @@
 
 
 
-<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3>
+<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
 
 <p>
@@ -4584,19 +4763,21 @@
 
 
 
-<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3>
+<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
 
 <p>
-Adds a string of length <code>n</code> previously copied to the
-buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>) to the buffer <code>B</code>
-(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
-
-
-
-
-
-<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3>
+Adds to the buffer <code>B</code> (see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>)
+a string of length <code>n</code> previously copied to the
+buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>).
+
+
+
+
+
+<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
 
 <p>
@@ -4609,7 +4790,8 @@
 
 
 
-<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3>
+<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
 <pre>void luaL_addvalue (luaL_Buffer *B);</pre>
 
 <p>
@@ -4628,10 +4810,11 @@
 
 
 
-<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3>
+<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>void luaL_argcheck (lua_State *L,
                     int cond,
-                    int numarg,
+                    int narg,
                     const char *extramsg);</pre>
 
 <p>
@@ -4640,21 +4823,22 @@
 where <code>func</code> is retrieved from the call stack:
 
 <pre>
-     bad argument #&lt;numarg&gt; to &lt;func&gt; (&lt;extramsg&gt;)
+     bad argument #&lt;narg&gt; to &lt;func&gt; (&lt;extramsg&gt;)
 </pre>
 
 
 
 
-<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3>
-<pre>int luaL_argerror (lua_State *L, int numarg, const char *extramsg);</pre>
+<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
+<pre>int luaL_argerror (lua_State *L, int narg, const char *extramsg);</pre>
 
 <p>
 Raises an error with the following message,
 where <code>func</code> is retrieved from the call stack:
 
 <pre>
-     bad argument #&lt;numarg&gt; to &lt;func&gt; (&lt;extramsg&gt;)
+     bad argument #&lt;narg&gt; to &lt;func&gt; (&lt;extramsg&gt;)
 </pre>
 
 <p>
@@ -4715,7 +4899,8 @@
 
 
 
-<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3>
+<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
 
 <p>
@@ -4728,7 +4913,8 @@
 
 
 
-<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3>
+<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>e</em>]</span>
 <pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
 
 <p>
@@ -4748,7 +4934,8 @@
 
 
 
-<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3>
+<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>void luaL_checkany (lua_State *L, int narg);</pre>
 
 <p>
@@ -4759,7 +4946,8 @@
 
 
 
-<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3>
+<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>int luaL_checkint (lua_State *L, int narg);</pre>
 
 <p>
@@ -4770,7 +4958,8 @@
 
 
 
-<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3>
+<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>lua_Integer luaL_checkinteger (lua_State *L, int narg);</pre>
 
 <p>
@@ -4781,7 +4970,8 @@
 
 
 
-<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3>
+<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>long luaL_checklong (lua_State *L, int narg);</pre>
 
 <p>
@@ -4792,7 +4982,8 @@
 
 
 
-<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3>
+<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>const char *luaL_checklstring (lua_State *L, int narg, size_t *l);</pre>
 
 <p>
@@ -4802,10 +4993,16 @@
 with the string's length.
 
 
-
-
-
-<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3>
+<p>
+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
+so all conversions and caveats of that function apply here.
+
+
+
+
+
+<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>lua_Number luaL_checknumber (lua_State *L, int narg);</pre>
 
 <p>
@@ -4816,7 +5013,8 @@
 
 
 
-<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3>
+<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>int luaL_checkoption (lua_State *L,
                       int narg,
                       const char *def,
@@ -4846,7 +5044,8 @@
 
 
 
-<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3>
+<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
 
 <p>
@@ -4858,7 +5057,8 @@
 
 
 
-<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3>
+<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>const char *luaL_checkstring (lua_State *L, int narg);</pre>
 
 <p>
@@ -4866,20 +5066,28 @@
 and returns this string.
 
 
-
-
-
-<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3>
+<p>
+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
+so all conversions and caveats of that function apply here.
+
+
+
+
+
+<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>void luaL_checktype (lua_State *L, int narg, int t);</pre>
 
 <p>
 Checks whether the function argument <code>narg</code> has type <code>t</code>.
-
-
-
-
-
-<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3>
+See <a href="#lua_type"><code>lua_type</code></a> for the encoding of types for <code>t</code>.
+
+
+
+
+
+<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>void *luaL_checkudata (lua_State *L, int narg, const char *tname);</pre>
 
 <p>
@@ -4890,7 +5098,8 @@
 
 
 
-<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3>
+<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
+<span class="apii">[-0, +?, <em>m</em>]</span>
 <pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
 
 <p>
@@ -4907,7 +5116,8 @@
 
 
 
-<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3>
+<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
+<span class="apii">[-0, +?, <em>m</em>]</span>
 <pre>int luaL_dostring (lua_State *L, const char *str);</pre>
 
 <p>
@@ -4924,7 +5134,8 @@
 
 
 
-<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3>
+<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
 
 <p>
@@ -4946,7 +5157,8 @@
 
 
 
-<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3>
+<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>m</em>]</span>
 <pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
 
 <p>
@@ -4960,7 +5172,8 @@
 
 
 
-<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3>
+<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
 <pre>void luaL_getmetatable (lua_State *L, const char *tname);</pre>
 
 <p>
@@ -4971,7 +5184,8 @@
 
 
 
-<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3>
+<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>const char *luaL_gsub (lua_State *L,
                        const char *s,
                        const char *p,
@@ -4987,7 +5201,8 @@
 
 
 
-<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3>
+<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>int luaL_loadbuffer (lua_State *L,
                      const char *buff,
                      size_t sz,
@@ -5008,7 +5223,8 @@
 
 
 
-<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3>
+<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
 
 <p>
@@ -5034,7 +5250,8 @@
 
 
 
-<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3>
+<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
 
 <p>
@@ -5055,7 +5272,8 @@
 
 
 
-<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3>
+<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
 
 <p>
@@ -5075,13 +5293,15 @@
 
 
 
-<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3>
+<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>lua_State *luaL_newstate (void);</pre>
 
 <p>
-Creates a new Lua state, calling <a href="#lua_newstate"><code>lua_newstate</code></a> with an
-allocation function based on the standard&nbsp;C <code>realloc</code> function
-and setting a panic function (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>) that prints
+Creates a new Lua state.
+It calls <a href="#lua_newstate"><code>lua_newstate</code></a> with an
+allocator based on the standard&nbsp;C <code>realloc</code> function
+and then sets a panic function (see <a href="#lua_atpanic"><code>lua_atpanic</code></a>) that prints
 an error message to the standard error output in case of fatal
 errors.
 
@@ -5094,7 +5314,8 @@
 
 
 
-<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3>
+<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
 <pre>void luaL_openlibs (lua_State *L);</pre>
 
 <p>
@@ -5104,7 +5325,8 @@
 
 
 
-<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3>
+<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>int luaL_optint (lua_State *L, int narg, int d);</pre>
 
 <p>
@@ -5118,8 +5340,11 @@
 
 
 
-<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3>
-<pre>lua_Integer luaL_optinteger (lua_State *L, int narg, lua_Integer d);</pre>
+<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
+<pre>lua_Integer luaL_optinteger (lua_State *L,
+                             int narg,
+                             lua_Integer d);</pre>
 
 <p>
 If the function argument <code>narg</code> is a number,
@@ -5132,7 +5357,8 @@
 
 
 
-<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3>
+<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>long luaL_optlong (lua_State *L, int narg, long d);</pre>
 
 <p>
@@ -5146,7 +5372,8 @@
 
 
 
-<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3>
+<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>const char *luaL_optlstring (lua_State *L,
                              int narg,
                              const char *d,
@@ -5168,7 +5395,8 @@
 
 
 
-<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3>
+<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);</pre>
 
 <p>
@@ -5182,8 +5410,11 @@
 
 
 
-<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3>
-<pre>const char *luaL_optstring (lua_State *L, int narg, const char *d);</pre>
+<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
+<pre>const char *luaL_optstring (lua_State *L,
+                            int narg,
+                            const char *d);</pre>
 
 <p>
 If the function argument <code>narg</code> is a string,
@@ -5196,7 +5427,8 @@
 
 
 
-<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3>
+<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
 
 <p>
@@ -5211,7 +5443,8 @@
 
 
 
-<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3>
+<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
+<span class="apii">[-?, +1, <em>m</em>]</span>
 <pre>void luaL_pushresult (luaL_Buffer *B);</pre>
 
 <p>
@@ -5222,7 +5455,8 @@
 
 
 
-<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3>
+<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
 <pre>int luaL_ref (lua_State *L, int t);</pre>
 
 <p>
@@ -5268,7 +5502,8 @@
 
 
 
-<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3>
+<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3><p>
+<span class="apii">[-(0|1), +1, <em>m</em>]</span>
 <pre>void luaL_register (lua_State *L,
                     const char *libname,
                     const luaL_Reg *l);</pre>
@@ -5285,7 +5520,7 @@
 
 <p>
 When called with a non-null <code>libname</code>,
-creates a new table <code>t</code>,
+<code>luaL_register</code> creates a new table <code>t</code>,
 sets it as the value of the global variable <code>libname</code>,
 sets it as the value of <code>package.loaded[libname]</code>,
 and registers on it all functions in the list <code>l</code>.
@@ -5302,34 +5537,37 @@
 
 
 
-<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3>
-<pre>const char *luaL_typename (lua_State *L, int idx);</pre>
-
-<p>
-Returns the name of the type of the value at index <code>idx</code>.
-
-
-
-
-
-<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3>
+<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>const char *luaL_typename (lua_State *L, int index);</pre>
+
+<p>
+Returns the name of the type of the value at the given index.
+
+
+
+
+
+<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
 <pre>int luaL_typerror (lua_State *L, int narg, const char *tname);</pre>
 
 <p>
-Generates an error with a message like
+Generates an error with a message like the following:
 
 <pre>
-     &lt;location&gt;: bad argument &lt;narg&gt; to &lt;function&gt; (&lt;tname&gt; expected, got &lt;realt&gt;)
+     <em>location</em>: bad argument <em>narg</em> to '<em>func</em>' (<em>tname</em> expected, got <em>rt</em>)
 </pre><p>
-where <code>&lt;location&gt;</code> is produced by <a href="#luaL_where"><code>luaL_where</code></a>,
-<code>&lt;function&gt;</code> is the name of the current function,
-and <code>&lt;realt&gt;</code> is the type name of the actual argument.
-
-
-
-
-
-<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3>
+where <code><em>location</em></code> is produced by <a href="#luaL_where"><code>luaL_where</code></a>,
+<code><em>func</em></code> is the name of the current function,
+and <code><em>rt</em></code> is the type name of the actual argument.
+
+
+
+
+
+<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
 <pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
 
 <p>
@@ -5348,13 +5586,18 @@
 
 
 
-<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3>
+<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
 <pre>void luaL_where (lua_State *L, int lvl);</pre>
 
 <p>
 Pushes onto the stack a string identifying the current position
 of the control at level <code>lvl</code> in the call stack.
-Typically this string has the format <code>&lt;chunkname&gt;:&lt;currentline&gt;:</code>.
+Typically this string has the following format:
+
+<pre>
+     <em>chunkname</em>:<em>currentline</em>:
+</pre><p>
 Level&nbsp;0 is the running function,
 level&nbsp;1 is the function that called the running function,
 etc.
@@ -5379,7 +5622,7 @@
 others provide access to "outside" services (e.g., I/O);
 and others could be implemented in Lua itself,
 but are quite useful or have critical performance requirements that
-deserve an implementation in C (e.g., <code>sort</code>).
+deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
 
 
 <p>
@@ -5413,9 +5656,8 @@
 
 <p>
 To have access to these libraries,
-the C&nbsp;host program must call
-<a href="#luaL_openlibs"><code>luaL_openlibs</code></a>,
-which open all standard libraries.
+the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function,
+which opens all standard libraries.
 Alternatively,
 it can open them individually by calling
 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
@@ -5423,7 +5665,8 @@
 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
-<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O and the Operating System libraries),
+<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
+<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>
 and should not be called directly:
@@ -5547,7 +5790,7 @@
 
 
 <p>
-<hr><h3><a name="pdf-getfenv"><code>getfenv (f)</code></a></h3>
+<hr><h3><a name="pdf-getfenv"><code>getfenv ([f])</code></a></h3>
 Returns the current environment in use by the function.
 <code>f</code> can be a Lua function or a number
 that specifies the function at that stack level:
@@ -5589,10 +5832,6 @@
 up to the first integer key absent from the table.
 
 
-<p>
-See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
-
-
 
 
 <p>
@@ -5616,6 +5855,8 @@
 <p>
 <code>chunkname</code> is used as the chunk name for error messages
 and debug information.
+When absent,
+it defaults to "<code>=(load)</code>".
 
 
 
@@ -5649,6 +5890,11 @@
      assert(loadstring(s))()
 </pre>
 
+<p>
+When absent,
+<code>chunkname</code> defaults to the given string.
+
+
 
 
 <p>
@@ -5704,7 +5950,8 @@
 
 
 <p>
-See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
+See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
+the table during its traversal.
 
 
 
@@ -5911,7 +6158,7 @@
 
 
 <p>
-This function is similar to <code>pcall</code>,
+This function is similar to <a href="#pdf-pcall"><code>pcall</code></a>,
 except that you can set a new error handler.
 
 
@@ -6101,7 +6348,7 @@
 
 <p>
 Loads the given module.
-The function starts by looking into the table <a href="#pdf-package.loaded"><code>package.loaded</code></a>
+The function starts by looking into the <a href="#pdf-package.loaded"><code>package.loaded</code></a> table
 to determine whether <code>modname</code> is already loaded.
 If it is, then <code>require</code> returns the value stored
 at <code>package.loaded[modname]</code>.
@@ -6110,7 +6357,15 @@
 
 <p>
 To find a loader,
-first <code>require</code> queries <code>package.preload[modname]</code>.
+<code>require</code> is guided by the <a href="#pdf-package.loaders"><code>package.loaders</code></a> array.
+By changing this array,
+we can change how <code>require</code> looks for a module.
+The following explanation is based on the default configuration
+for <a href="#pdf-package.loaders"><code>package.loaders</code></a>.
+
+
+<p>
+First <code>require</code> queries <code>package.preload[modname]</code>.
 If it has a value,
 this value (which should be a function) is the loader.
 Otherwise <code>require</code> searches for a Lua loader using the
@@ -6118,14 +6373,123 @@
 If that also fails, it searches for a C&nbsp;loader using the
 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
 If that also fails,
-it tries an <em>all-in-one</em> loader (see below).
-
-
-<p>
-When loading a C&nbsp;library,
-<code>require</code> first uses a dynamic link facility to link the
+it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.loaders"><code>package.loaders</code></a>).
+
+
+<p>
+Once a loader is found,
+<code>require</code> calls the loader with a single argument, <code>modname</code>.
+If the loader returns any value,
+<code>require</code> assigns the returned value to <code>package.loaded[modname]</code>.
+If the loader returns no value and
+has not assigned any value to <code>package.loaded[modname]</code>,
+then <code>require</code> assigns <b>true</b> to this entry.
+In any case, <code>require</code> returns the
+final value of <code>package.loaded[modname]</code>.
+
+
+<p>
+If there is any error loading or running the module,
+or if it cannot find any loader for the module,
+then <code>require</code> signals an error. 
+
+
+
+
+<p>
+<hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
+
+
+<p>
+The path used by <a href="#pdf-require"><code>require</code></a> to search for a C&nbsp;loader.
+
+
+<p>
+Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
+it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
+using the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
+or a default path defined in <code>luaconf.h</code>.
+
+
+
+
+<p>
+
+<hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
+
+
+<p>
+A table used by <a href="#pdf-require"><code>require</code></a> to control which
+modules are already loaded.
+When you require a module <code>modname</code> and
+<code>package.loaded[modname]</code> is not false,
+<a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
+
+
+
+
+<p>
+<hr><h3><a name="pdf-package.loaders"><code>package.loaders</code></a></h3>
+
+
+<p>
+A table used by <a href="#pdf-require"><code>require</code></a> to control how to load modules.
+
+
+<p>
+Each entry in this table is a <em>searcher function</em>.
+When looking for a module,
+<a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
+with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
+sole parameter.
+The function may return another function (the module <em>loader</em>)
+or a string explaining why it did not find that module
+(or <b>nil</b> if it has nothing to say).
+Lua initializes this table with four functions.
+
+
+<p>
+The first searcher simply looks for a loader in the
+<a href="#pdf-package.preload"><code>package.preload</code></a> table.
+
+
+<p>
+The second searcher looks for a loader as a Lua library,
+using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
+A path is a sequence of <em>templates</em> separated by semicolons.
+For each template,
+the searcher will change each interrogation
+mark in the template by <code>filename</code>,
+which is the module name with each dot replaced by a
+"directory separator" (such as "<code>/</code>" in Unix);
+then it will try to open the resulting file name.
+So, for instance, if the Lua path is the string
+
+<pre>
+     "./?.lua;./?.lc;/usr/local/?/init.lua"
+</pre><p>
+the search for a Lua file for module <code>foo</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.
+
+
+<p>
+The third searcher looks for a loader as a C&nbsp;library,
+using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
+For instance,
+if the C&nbsp;path is the string
+
+<pre>
+     "./?.so;./?.dll;/usr/local/?/init.so"
+</pre><p>
+the searcher for module <code>foo</code>
+will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>,
+and <code>/usr/local/foo/init.so</code>, in that order.
+Once it finds a C&nbsp;library,
+this searcher first uses a dynamic link facility to link the
 application with the library.
-Then it tries to find a C&nbsp;function inside this library to
+Then it tries to find a C&nbsp;function inside the library to
 be used as the loader.
 The name of this C&nbsp;function is the string "<code>luaopen_</code>"
 concatenated with a copy of the module name where each dot
@@ -6137,10 +6501,8 @@
 
 
 <p>
-If <code>require</code> finds neither a Lua library nor a
-C&nbsp;library for a module,
-it calls the <em>all-in-one loader</em>.
-This loader searches the C&nbsp;path for a library for
+The fourth searcher tries an <em>all-in-one loader</em>.
+It searches the C&nbsp;path for a library for
 the root name of the given module.
 For instance, when requiring <code>a.b.c</code>,
 it will search for a C&nbsp;library for <code>a</code>.
@@ -6152,55 +6514,6 @@
 with each submodule keeping its original open function.
 
 
-<p>
-Once a loader is found,
-<code>require</code> calls the loader with a single argument, <code>modname</code>.
-If the loader returns any value,
-<code>require</code> assigns it to <code>package.loaded[modname]</code>.
-If the loader returns no value and
-has not assigned any value to <code>package.loaded[modname]</code>,
-then <code>require</code> assigns <b>true</b> to this entry.
-In any case, <code>require</code> returns the
-final value of <code>package.loaded[modname]</code>.
-
-
-<p>
-If there is any error loading or running the module,
-or if it cannot find any loader for the module,
-then <code>require</code> signals an error. 
-
-
-
-
-<p>
-<hr><h3><a name="pdf-package.cpath"><code>package.cpath</code></a></h3>
-
-
-<p>
-The path used by <a href="#pdf-require"><code>require</code></a> to search for a C&nbsp;loader.
-
-
-<p>
-Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
-it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
-using the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
-(plus another default path defined in <code>luaconf.h</code>).
-
-
-
-
-<p>
-<hr><h3><a name="pdf-package.loaded"><code>package.loaded</code></a></h3>
-
-
-<p>
-A table used by <a href="#pdf-require"><code>require</code></a> to control which
-modules are already loaded.
-When you require a module <code>modname</code> and
-<code>package.loaded[modname]</code> is not false,
-<a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
-
-
 
 
 <p>
@@ -6252,24 +6565,6 @@
 is replaced by the default path.
 
 
-<p>
-A path is a sequence of <em>templates</em> separated by semicolons.
-For each template, <a href="#pdf-require"><code>require</code></a> will change each interrogation
-mark in the template by <code>filename</code>,
-which is <code>modname</code> with each dot replaced by a
-"directory separator" (such as "<code>/</code>" in Unix);
-then it will try to load the resulting file name.
-So, for instance, if the Lua path is
-
-<pre>
-     "./?.lua;./?.lc;/usr/local/?/init.lua"
-</pre><p>
-the search for a Lua loader for module <code>foo</code>
-will try to load the files
-<code>./foo.lua</code>, <code>./foo.lc</code>, and
-<code>/usr/local/foo/init.lua</code>, in that order.
-
-
 
 
 <p>
@@ -6426,7 +6721,8 @@
 
 <p>
 This function does not accept string values
-containing embedded zeros.
+containing embedded zeros,
+except as arguments to the <code>q</code> option.
 
 
 
@@ -6436,9 +6732,6 @@
 Returns an iterator function that,
 each time it is called,
 returns the next captures from <code>pattern</code> over string <code>s</code>.
-
-
-<p>
 If <code>pattern</code> specifies no captures,
 then the whole match is produced in each call.
 
@@ -6465,16 +6758,22 @@
      end
 </pre>
 
+<p>
+For this function, a '<code>^</code>' at the start of a pattern does not
+work as an anchor, as this would prevent the iteration.
+
+
 
 
 <p>
 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
 Returns a copy of <code>s</code>
-in which all occurrences of the <code>pattern</code> have been
+in which all (or the first <code>n</code>, if given)
+occurrences of the <code>pattern</code> have been
 replaced by a replacement string specified by <code>repl</code>,
 which may be a string, a table, or a function.
 <code>gsub</code> also returns, as its second value,
-the total number of substitutions made.
+the total number of matches that occurred.
 
 
 <p>
@@ -6512,13 +6811,6 @@
 
 
 <p>
-The optional last parameter <code>n</code> limits
-the maximum number of substitutions to occur.
-For instance, when <code>n</code> is 1 only the first occurrence of
-<code>pattern</code> is replaced.
-
-
-<p>
 Here are some examples:
 
 <pre>
@@ -6540,7 +6832,7 @@
      --&gt; x="4+5 = 9"
      
      local t = {name="lua", version="5.1"}
-     x = string.gsub("$name%-$version.tar.gz", "%$(%w+)", t)
+     x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
      --&gt; x="lua-5.1.tar.gz"
 </pre>
 
@@ -6824,7 +7116,8 @@
 
 <p>
 <hr><h3><a name="pdf-table.concat"><code>table.concat (table [, sep [, i [, j]]])</code></a></h3>
-Returns <code>table[i]..sep..table[i+1] &middot;&middot;&middot; sep..table[j]</code>.
+Given an array where all elements are strings or numbers,
+returns <code>table[i]..sep..table[i+1] &middot;&middot;&middot; sep..table[j]</code>.
 The default value for <code>sep</code> is the empty string,
 the default for <code>i</code> is 1,
 and the default for <code>j</code> is the length of the table.
@@ -6950,14 +7243,14 @@
 
 
 <p>
-<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (x, y)</code></a></h3>
-
-
-<p>
-Returns the arc tangent of <code>x/y</code> (in radians),
+<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (y, x)</code></a></h3>
+
+
+<p>
+Returns the arc tangent of <code>y/x</code> (in radians),
 but uses the signs of both parameters to find the
 quadrant of the result.
-(It also handles correctly the case of <code>y</code> being zero.)
+(It also handles correctly the case of <code>x</code> being zero.)
 
 
 
@@ -7007,7 +7300,7 @@
 
 
 <p>
-Returns the the value <em>e<sup>x</sup></em>.
+Returns the value <em>e<sup>x</sup></em>.
 
 
 
@@ -7122,7 +7415,7 @@
 
 
 <p>
-The value PI.
+The value of <em>pi</em>.
 
 
 
@@ -7160,13 +7453,13 @@
 
 <p>
 When called without arguments,
-returns a pseudo-random real number
+returns a uniform pseudo-random real number
 in the range <em>[0,1)</em>.  
-When called with a number <code>m</code>,
+When called with an integer number <code>m</code>,
 <code>math.random</code> returns
-a pseudo-random integer in the range <em>[1, m]</em>.
-When called with two numbers <code>m</code> and <code>n</code>,
-<code>math.random</code> returns a pseudo-random
+a uniform pseudo-random integer in the range <em>[1, m]</em>.
+When called with two integer numbers <code>m</code> and <code>n</code>,
+<code>math.random</code> returns a uniform pseudo-random
 integer in the range <em>[m, n]</em>.
 
 
@@ -7261,12 +7554,14 @@
 The table <code>io</code> also provides
 three predefined file descriptors with their usual meanings from C:
 <a name="pdf-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a>, and <a name="pdf-io.stderr"><code>io.stderr</code></a>.
+The I/O library never closes these files.
 
 
 <p>
 Unless otherwise stated,
 all I/O functions return <b>nil</b> on failure
-(plus an error message as a second result)
+(plus an error message as a second result and
+a system-dependent error code as a third result)
 and some value different from <b>nil</b> on success.
 
 
@@ -7331,7 +7626,7 @@
 
 
 <p>
-The call <code>io.lines()</code> (without a file name) is equivalent
+The call <code>io.lines()</code> (with no file name) is equivalent
 to <code>io.input():lines()</code>;
 that is, it iterates over the lines of the default input file.
 In this case it does not close the file when the loop ends.
@@ -7381,7 +7676,7 @@
 
 
 <p>
-<hr><h3><a name="pdf-io.popen"><code>io.popen ([prog [, mode]])</code></a></h3>
+<hr><h3><a name="pdf-io.popen"><code>io.popen (prog [, mode])</code></a></h3>
 
 
 <p>
@@ -7596,7 +7891,7 @@
 </li>
 
 </ul><p>
-For the last two cases, <code>sizes</code>
+For the last two cases, <code>size</code>
 specifies the size of the buffer, in bytes.
 The default is an appropriate size.
 
@@ -7657,7 +7952,7 @@
 If <code>format</code> starts with '<code>!</code>',
 then the date is formatted in Coordinated Universal Time.
 After this optional character,
-if <code>format</code> is <code>*t</code>,
+if <code>format</code> is the string "<code>*t</code>",
 then <code>date</code> returns a table with the following fields:
 <code>year</code> (four digits), <code>month</code> (1--12), <code>day</code> (1--31),
 <code>hour</code> (0--23), <code>min</code> (0--59), <code>sec</code> (0--61),
@@ -7667,7 +7962,7 @@
 
 
 <p>
-If <code>format</code> is not <code>*t</code>,
+If <code>format</code> is not "<code>*t</code>",
 then <code>date</code> returns the date as a string,
 formatted according to the same rules as the C&nbsp;function <code>strftime</code>.
 
@@ -7772,6 +8067,13 @@
 
 
 <p>
+If <code>locale</code> is the empty string,
+the current locale is set to an implementation-defined native locale.
+If <code>locale</code> is the string "<code>C</code>",
+the current locale is set to the standard C locale.
+
+
+<p>
 When called with <b>nil</b> as the first argument,
 this function only returns the name of the current locale
 for the given category.
@@ -7829,7 +8131,7 @@
 Please resist the temptation to use them as a
 usual programming tool:
 they can be very slow.
-Moreover, several of its functions
+Moreover, several of these functions
 violate some assumptions about Lua code
 (e.g., that variables local to a function
 cannot be accessed from outside or
@@ -7920,8 +8222,10 @@
 
 <p>
 For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
-a name of the current function, if a reasonable name can be found,
-and <code>debug.getinfo(print)</code> returns a table with all available information
+a table with a name for the current function,
+if a reasonable name can be found,
+and the expression <code>debug.getinfo(print)</code>
+returns a table with all available information
 about the <a href="#pdf-print"><code>print</code></a> function.
 
 
@@ -8006,9 +8310,9 @@
 with the given meaning:
 
 <ul>
-<li><b><code>"c"</code>:</b> The hook is called every time Lua calls a function;</li>
-<li><b><code>"r"</code>:</b> The hook is called every time Lua returns from a function;</li>
-<li><b><code>"l"</code>:</b> The hook is called every time Lua enters a new line of code.</li>
+<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li>
+<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li>
+<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li>
 </ul><p>
 With a <code>count</code> different from zero,
 the hook is called after every <code>count</code> instructions.
@@ -8080,15 +8384,16 @@
 
 
 <p>
-<hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message])</code></a></h3>
+<hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message] [, level])</code></a></h3>
 
 
 <p>
 Returns a string with a traceback of the call stack.
 An optional <code>message</code> string is appended
-at the beginning of the traceback. 
-This function is typically used with <a href="#pdf-xpcall"><code>xpcall</code></a> to produce
-better error messages.
+at the beginning of the traceback.
+An optional <code>level</code> number tells at which level
+to start the traceback
+(default is 1, the function calling <code>traceback</code>).
 
 
 
@@ -8192,17 +8497,19 @@
 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a string,
 its value is used as the secondary prompt
 (issued during incomplete statements).
-Therefore, both prompts can be changed directly on the command line.
-For instance,
+Therefore, both prompts can be changed directly on the command line
+or in any Lua programs by assigning to <code>_PROMPT</code>.
+See the next example:
 
 <pre>
      $ lua -e"_PROMPT='myprompt&gt; '" -i
 </pre><p>
-(the outer pair of quotes is for the shell,
-the inner pair is for Lua),
-or in any Lua programs by assigning to <code>_PROMPT</code>.
-Note the use of <code>-i</code> to enter interactive mode; otherwise,
-the program would just end silently right after the assignment to <code>_PROMPT</code>.
+(The outer pair of quotes is for the shell,
+the inner pair is for Lua.)
+Note the use of <code>-i</code> to enter interactive mode;
+otherwise,
+the program would just end silently
+right after the assignment to <code>_PROMPT</code>.
 
 
 <p>
@@ -8232,7 +8539,7 @@
 <h1>7 - <a name="7">Incompatibilities with the Previous Version</a></h1>
 
 <p>
-Here we list the incompatibilities that may be found when moving a program
+Here we list the incompatibilities that you may find when moving a program
 from Lua&nbsp;5.0 to Lua&nbsp;5.1.
 You can avoid most of the incompatibilities compiling Lua with
 appropriate options (see file <code>luaconf.h</code>).
@@ -8247,7 +8554,7 @@
 <li>
 The vararg system changed from the pseudo-argument <code>arg</code> with a
 table with the extra arguments to the vararg expression.
-(Option <code>LUA_COMPAT_VARARG</code> in <code>luaconf.h</code>.)
+(See compile-time option <code>LUA_COMPAT_VARARG</code> in <code>luaconf.h</code>.)
 </li>
 
 <li>
@@ -8259,7 +8566,7 @@
 The long string/long comment syntax (<code>[[<em>string</em>]]</code>)
 does not allow nesting.
 You can use the new syntax (<code>[=[<em>string</em>]=]</code>) in these cases.
-(Option <code>LUA_COMPAT_LSTR</code> in <code>luaconf.h</code>.)
+(See compile-time option <code>LUA_COMPAT_LSTR</code> in <code>luaconf.h</code>.)
 </li>
 
 </ul>
@@ -8272,7 +8579,7 @@
 
 <li>
 Function <code>string.gfind</code> was renamed <a href="#pdf-string.gmatch"><code>string.gmatch</code></a>.
-(Option <code>LUA_COMPAT_GFIND</code>)
+(See compile-time option <code>LUA_COMPAT_GFIND</code> in <code>luaconf.h</code>.)
 </li>
 
 <li>
@@ -8288,17 +8595,17 @@
 Function <code>table.getn</code> corresponds
 to the new length operator (<code>#</code>);
 use the operator instead of the function.
-(Option <code>LUA_COMPAT_GETN</code>)
+(See compile-time option <code>LUA_COMPAT_GETN</code> in <code>luaconf.h</code>.)
 </li>
 
 <li>
 Function <code>loadlib</code> was renamed <a href="#pdf-package.loadlib"><code>package.loadlib</code></a>.
-(Option <code>LUA_COMPAT_LOADLIB</code>)
+(See compile-time option <code>LUA_COMPAT_LOADLIB</code> in <code>luaconf.h</code>.)
 </li>
 
 <li>
 Function <code>math.mod</code> was renamed <a href="#pdf-math.fmod"><code>math.fmod</code></a>.
-(Option <code>LUA_COMPAT_MOD</code>)
+(See compile-time option <code>LUA_COMPAT_MOD</code> in <code>luaconf.h</code>.)
 </li>
 
 <li>
@@ -8381,29 +8688,29 @@
 
 	block ::= chunk
 
-	stat ::=  varlist1 `<b>=</b>&acute; explist1 | 
+	stat ::=  varlist `<b>=</b>&acute; explist | 
 		 functioncall | 
 		 <b>do</b> block <b>end</b> | 
 		 <b>while</b> exp <b>do</b> block <b>end</b> | 
 		 <b>repeat</b> block <b>until</b> exp | 
 		 <b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b> | 
 		 <b>for</b> Name `<b>=</b>&acute; exp `<b>,</b>&acute; exp [`<b>,</b>&acute; exp] <b>do</b> block <b>end</b> | 
-		 <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b> | 
+		 <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b> | 
 		 <b>function</b> funcname funcbody | 
 		 <b>local</b> <b>function</b> Name funcbody | 
-		 <b>local</b> namelist [`<b>=</b>&acute; explist1] 
-
-	laststat ::= <b>return</b> [explist1] | <b>break</b>
+		 <b>local</b> namelist [`<b>=</b>&acute; explist] 
+
+	laststat ::= <b>return</b> [explist] | <b>break</b>
 
 	funcname ::= Name {`<b>.</b>&acute; Name} [`<b>:</b>&acute; Name]
 
-	varlist1 ::= var {`<b>,</b>&acute; var}
+	varlist ::= var {`<b>,</b>&acute; var}
 
 	var ::=  Name | prefixexp `<b>[</b>&acute; exp `<b>]</b>&acute; | prefixexp `<b>.</b>&acute; Name 
 
 	namelist ::= Name {`<b>,</b>&acute; Name}
 
-	explist1 ::= {exp `<b>,</b>&acute;} exp
+	explist ::= {exp `<b>,</b>&acute;} exp
 
 	exp ::=  <b>nil</b> | <b>false</b> | <b>true</b> | Number | String | `<b>...</b>&acute; | function | 
 		 prefixexp | tableconstructor | exp binop exp | unop exp 
@@ -8412,13 +8719,13 @@
 
 	functioncall ::=  prefixexp args | prefixexp `<b>:</b>&acute; Name args 
 
-	args ::=  `<b>(</b>&acute; [explist1] `<b>)</b>&acute; | tableconstructor | String 
+	args ::=  `<b>(</b>&acute; [explist] `<b>)</b>&acute; | tableconstructor | String 
 
 	function ::= <b>function</b> funcbody
 
-	funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
-
-	parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
+	funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
+
+	parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
 
 	tableconstructor ::= `<b>{</b>&acute; [fieldlist] `<b>}</b>&acute;
 
@@ -8443,13 +8750,14 @@
 
 
 
+
 <HR>
 <SMALL>
 Last update:
-Mon Jun  5 17:05:27 BRT 2006
+Fri Jan 18 22:32:24 BRST 2008
 </SMALL>
 <!--
-Last change: ready for Lua 5.1.1
+Last change: revised for Lua 5.1.3
 -->
 
 </body></html>
--- a/src/lua-5.1.1/doc/readme.html	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/doc/readme.html	Tue Mar 18 02:05:22 2008 +0000
@@ -4,7 +4,7 @@
 <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
 </HEAD>
 
-<BODY BGCOLOR="#FFFFFF">
+<BODY>
 
 <HR>
 <H1>
@@ -12,8 +12,9 @@
 Documentation
 </H1>
 
+This is the documentation included in the source distribution of Lua 5.1.3.
+
 <UL>
-<LI><A HREF="http://www.lua.org/">Official web site</A>
 <LI><A HREF="contents.html">Reference manual</A>
 <LI><A HREF="lua.html">lua man page</A>
 <LI><A HREF="luac.html">luac man page</A>
@@ -22,10 +23,17 @@
 <LI><A HREF="../test/README">lua/test/README</A>
 </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>
 <SMALL>
 Last update:
-Wed Sep  7 12:57:50 BRST 2005
+Wed Dec 19 13:59:14 BRST 2007
 </SMALL>
 
 </BODY>
--- a/src/lua-5.1.1/etc/README	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/etc/README	Tue Mar 18 02:05:22 2008 +0000
@@ -20,6 +20,7 @@
 
 luavs.bat
 	Script to build Lua under "Visual Studio .NET Command Prompt".
+	Run it from the toplevel as etc\luavs.bat.
 
 min.c
 	A minimal Lua interpreter.
--- a/src/lua-5.1.1/etc/lua.pc	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/etc/lua.pc	Tue Mar 18 02:05:22 2008 +0000
@@ -5,7 +5,7 @@
 # grep '^V=' ../Makefile
 V= 5.1
 # grep '^R=' ../Makefile
-R= 5.1.1
+R= 5.1.3
 
 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
 prefix= /usr/local
--- a/src/lua-5.1.1/etc/luavs.bat	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/etc/luavs.bat	Tue Mar 18 02:05:22 2008 +0000
@@ -1,7 +1,28 @@
+@rem Script to build Lua 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 (contributed by David Manura and Mike Pall)
+
+@setlocal
+@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
+@set MYLINK=link /nologo
+@set MYMT=mt /nologo
+
 cd src
-cl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.c
+%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c
 del lua.obj luac.obj
-link /DLL /out:lua51.dll l*.obj
-cl /O2 /W3 /c /DLUA_BUILD_AS_DLL lua.c
-link /out:lua.exe lua.obj lua51.lib
+%MYLINK% /DLL /out:lua51.dll l*.obj
+if exist lua51.dll.manifest^
+  %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2
+%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c
+%MYLINK% /out:lua.exe lua.obj lua51.lib
+if exist lua.exe.manifest^
+  %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe
+%MYCOMPILE% l*.c print.c
+del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^
+    loslib.obj ltablib.obj lstrlib.obj loadlib.obj
+%MYLINK% /out:luac.exe *.obj
+if exist luac.exe.manifest^
+  %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe
+del *.obj *.manifest
 cd ..
--- a/src/lua-5.1.1/etc/min.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/etc/min.c	Tue Mar 18 02:05:22 2008 +0000
@@ -18,7 +18,7 @@
   if (i>1) printf("\t");
   if (lua_isstring(L,i))
    printf("%s",lua_tostring(L,i));
-  else if (lua_isnil(L,i)==2)
+  else if (lua_isnil(L,i))
    printf("%s","nil");
   else if (lua_isboolean(L,i))
    printf("%s",lua_toboolean(L,i) ? "true" : "false");
--- a/src/lua-5.1.1/etc/strict.lua	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/etc/strict.lua	Tue Mar 18 02:05:22 2008 +0000
@@ -6,6 +6,8 @@
 -- anywhere or assigned to inside a function.
 --
 
+local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
+
 local mt = getmetatable(_G)
 if mt == nil then
   mt = {}
@@ -14,9 +16,14 @@
 
 mt.__declared = {}
 
+local function what ()
+  local d = getinfo(3, "S")
+  return d and d.what or "C"
+end
+
 mt.__newindex = function (t, n, v)
   if not mt.__declared[n] then
-    local w = debug.getinfo(2, "S").what
+    local w = what()
     if w ~= "main" and w ~= "C" then
       error("assign to undeclared variable '"..n.."'", 2)
     end
@@ -26,7 +33,7 @@
 end
   
 mt.__index = function (t, n)
-  if not mt.__declared[n] and debug.getinfo(2, "S").what ~= "C" then
+  if not mt.__declared[n] and what() ~= "C" then
     error("variable '"..n.."' is not declared", 2)
   end
   return rawget(t, n)
--- a/src/lua-5.1.1/src/Makefile	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/Makefile	Tue Mar 18 02:05:22 2008 +0000
@@ -8,7 +8,7 @@
 PLAT= none
 
 CC= gcc
-CFLAGS= -O0 -g -Wall $(MYCFLAGS)
+CFLAGS= -O2 -Wall $(MYCFLAGS)
 AR= ar rcu
 RANLIB= ranlib
 RM= rm -f
@@ -20,7 +20,7 @@
 
 # == 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
 CORE_O=	lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
@@ -77,7 +77,8 @@
 # convenience targets for popular platforms
 
 none:
-	@echo "Please choose a platform: $(PLATS)"
+	@echo "Please choose a platform:"
+	@echo "   $(PLATS)"
 
 aix:
 	$(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
@@ -88,6 +89,9 @@
 bsd:
 	$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
 
+freebsd:
+	$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
+
 generic:
 	$(MAKE) all MYCFLAGS=
 
@@ -95,14 +99,15 @@
 	$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
 
 macosx:
-	$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
-# use this on Mac OS X 10.4
-#	$(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
+	$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
+# use this on Mac OS X 10.3-
+#	$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
 
 mingw:
 	$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
 	"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
 	"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
+	$(MAKE) "LUAC_T=luac.exe" luac.exe
 
 posix:
 	$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
@@ -143,8 +148,7 @@
 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 \
   ltm.h lzio.h lmem.h ldo.h
-loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
-  lualib.h
+loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
 lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
   ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
 lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
--- a/src/lua-5.1.1/src/lapi.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lapi.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $
+** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -123,6 +123,11 @@
 }
 
 
+LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
+  to->nCcalls = from->nCcalls;
+}
+
+
 LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
   lua_CFunction old;
   lua_lock(L);
@@ -749,7 +754,7 @@
       res = 0;
       break;
   }
-  luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+  if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
   L->top--;
   lua_unlock(L);
   return res;
--- a/src/lua-5.1.1/src/lapi.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lapi.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions from Lua API
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lauxlib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lauxlib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $
+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -244,7 +244,7 @@
   if (libname) {
     int size = libsize(l);
     /* check whether lib already exists */
-    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
+    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
     lua_getfield(L, -1, libname);  /* get _LOADED[libname] */
     if (!lua_istable(L, -1)) {  /* not found? */
       lua_pop(L, 1);  /* remove previous result */
@@ -535,7 +535,7 @@
     return "\n";
   }
   if (feof(lf->f)) return NULL;
-  *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
+  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
   return (*size > 0) ? lf->buff : NULL;
 }
 
@@ -570,9 +570,8 @@
     while ((c = getc(lf.f)) != EOF && c != '\n') ;  /* skip first line */
     if (c == '\n') c = getc(lf.f);
   }
-  if (c == LUA_SIGNATURE[0] && lf.f != stdin) {  /* binary file? */
-    fclose(lf.f);
-    lf.f = fopen(filename, "rb");  /* reopen in binary mode */
+  if (c == LUA_SIGNATURE[0] && filename) {  /* binary file? */
+    lf.f = freopen(filename, "rb", lf.f);  /* reopen in binary mode */
     if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
     /* skip eventual `#!...' */
    while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
@@ -581,7 +580,7 @@
   ungetc(c, lf.f);
   status = lua_load(L, getF, &lf, lua_tostring(L, -1));
   readstatus = ferror(lf.f);
-  if (lf.f != stdin) fclose(lf.f);  /* close file (even in case of errors) */
+  if (filename) fclose(lf.f);  /* close file (even in case of errors) */
   if (readstatus) {
     lua_settop(L, fnameindex);  /* ignore results from `lua_load' */
     return errfile(L, "read", fnameindex);
--- a/src/lua-5.1.1/src/lauxlib.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lauxlib.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 roberto Exp $
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lbaselib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lbaselib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $
+** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -114,11 +114,11 @@
 }
 
 
-static void getfunc (lua_State *L) {
+static void getfunc (lua_State *L, int opt) {
   if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
   else {
     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");
     if (lua_getstack(L, level, &ar) == 0)
       luaL_argerror(L, 1, "invalid level");
@@ -131,7 +131,7 @@
 
 
 static int luaB_getfenv (lua_State *L) {
-  getfunc(L);
+  getfunc(L, 1);
   if (lua_iscfunction(L, -1))  /* is a C function? */
     lua_pushvalue(L, LUA_GLOBALSINDEX);  /* return the thread's global env. */
   else
@@ -142,7 +142,7 @@
 
 static int luaB_setfenv (lua_State *L) {
   luaL_checktype(L, 2, LUA_TTABLE);
-  getfunc(L);
+  getfunc(L, 0);
   lua_pushvalue(L, 2);
   if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
     /* change environment of current thread */
@@ -477,15 +477,52 @@
 ** =======================================================
 */
 
+#define CO_RUN	0	/* running */
+#define CO_SUS	1	/* suspended */
+#define CO_NOR	2	/* 'normal' (it resumed another coroutine) */
+#define CO_DEAD	3
+
+static const char *const statnames[] =
+    {"running", "suspended", "normal", "dead"};
+
+static int costatus (lua_State *L, lua_State *co) {
+  if (L == co) return CO_RUN;
+  switch (lua_status(co)) {
+    case LUA_YIELD:
+      return CO_SUS;
+    case 0: {
+      lua_Debug ar;
+      if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */
+        return CO_NOR;  /* it is running */
+      else if (lua_gettop(co) == 0)
+          return CO_DEAD;
+      else
+        return CO_SUS;  /* initial state */
+    }
+    default:  /* some error occured */
+      return CO_DEAD;
+  }
+}
+
+
+static int luaB_costatus (lua_State *L) {
+  lua_State *co = lua_tothread(L, 1);
+  luaL_argcheck(L, co, 1, "coroutine expected");
+  lua_pushstring(L, statnames[costatus(L, co)]);
+  return 1;
+}
+
+
 static int auxresume (lua_State *L, lua_State *co, int narg) {
-  int status;
+  int status = costatus(L, co);
   if (!lua_checkstack(co, narg))
     luaL_error(L, "too many arguments to resume");
-  if (lua_status(co) == 0 && lua_gettop(co) == 0) {
-    lua_pushliteral(L, "cannot resume dead coroutine");
+  if (status != CO_SUS) {
+    lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
     return -1;  /* error flag */
   }
   lua_xmove(L, co, narg);
+  lua_setlevel(L, co);
   status = lua_resume(co, narg);
   if (status == 0 || status == LUA_YIELD) {
     int nres = lua_gettop(co);
@@ -556,39 +593,10 @@
 }
 
 
-static int luaB_costatus (lua_State *L) {
-  lua_State *co = lua_tothread(L, 1);
-  luaL_argcheck(L, co, 1, "coroutine expected");
-  if (L == co) lua_pushliteral(L, "running");
-  else {
-    switch (lua_status(co)) {
-      case LUA_YIELD:
-        lua_pushliteral(L, "suspended");
-        break;
-      case 0: {
-        lua_Debug ar;
-        if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */
-          lua_pushliteral(L, "normal");  /* it is running */
-        else if (lua_gettop(co) == 0)
-            lua_pushliteral(L, "dead");
-        else
-          lua_pushliteral(L, "suspended");  /* initial state */
-        break;
-      }
-      default:  /* some error occured */
-        lua_pushliteral(L, "dead");
-        break;
-    }
-  }
-  return 1;
-}
-
-
 static int luaB_corunning (lua_State *L) {
   if (lua_pushthread(L))
-    return 0;  /* main thread is not a coroutine */
-  else
-    return 1;
+    lua_pushnil(L);  /* main thread is not a coroutine */
+  return 1;
 }
 
 
--- a/src/lua-5.1.1/src/lcode.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lcode.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp $
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -35,15 +35,20 @@
 void luaK_nil (FuncState *fs, int from, int n) {
   Instruction *previous;
   if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
-    if (fs->pc == 0)  /* function start? */
-      return;  /* positions are already clean */
-    if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) {
-      int pfrom = GETARG_A(*previous);
-      int pto = GETARG_B(*previous);
-      if (pfrom <= from && from <= pto+1) {  /* can connect both? */
-        if (from+n-1 > pto)
-          SETARG_B(*previous, from+n-1);
-        return;
+    if (fs->pc == 0) {  /* function start? */
+      if (from >= fs->nactvar)
+        return;  /* positions are already clean */
+    }
+    else {
+      previous = &fs->f->code[fs->pc-1];
+      if (GET_OPCODE(*previous) == OP_LOADNIL) {
+        int pfrom = GETARG_A(*previous);
+        int pto = GETARG_B(*previous);
+        if (pfrom <= from && from <= pto+1) {  /* can connect both? */
+          if (from+n-1 > pto)
+            SETARG_B(*previous, from+n-1);
+          return;
+        }
       }
     }
   }
@@ -657,10 +662,16 @@
   if (constfolding(op, e1, e2))
     return;
   else {
+    int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
     int o1 = luaK_exp2RK(fs, e1);
-    int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
-    freeexp(fs, e2);
-    freeexp(fs, e1);
+    if (o1 > o2) {
+      freeexp(fs, e1);
+      freeexp(fs, e2);
+    }
+    else {
+      freeexp(fs, e2);
+      freeexp(fs, e1);
+    }
     e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
     e1->k = VRELOCABLE;
   }
@@ -688,7 +699,7 @@
   e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
   switch (op) {
     case OPR_MINUS: {
-      if (e->k == VK)
+      if (!isnumeral(e))
         luaK_exp2anyreg(fs, e);  /* cannot operate on non-numeric constants */
       codearith(fs, OP_UNM, e, &e2);
       break;
@@ -718,8 +729,13 @@
       luaK_exp2nextreg(fs, v);  /* operand must be on the `stack' */
       break;
     }
+    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);
+      break;
+    }
     default: {
-      if (!isnumeral(v)) luaK_exp2RK(fs, v);
+      luaK_exp2RK(fs, v);
       break;
     }
   }
--- a/src/lua-5.1.1/src/lcode.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lcode.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $
+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/ldblib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldblib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -255,24 +255,25 @@
 
 
 static int db_sethook (lua_State *L) {
-  int arg;
+  int arg, mask, count;
+  lua_Hook func;
   lua_State *L1 = getthread(L, &arg);
   if (lua_isnoneornil(L, arg+1)) {
     lua_settop(L, arg+1);
-    lua_sethook(L1, NULL, 0, 0);  /* turn off hooks */
+    func = NULL; mask = 0; count = 0;  /* turn off hooks */
   }
   else {
     const char *smask = luaL_checkstring(L, arg+2);
-    int count = luaL_optint(L, arg+3, 0);
     luaL_checktype(L, arg+1, LUA_TFUNCTION);
-    lua_sethook(L1, hookf, makemask(smask, count), count);
+    count = luaL_optint(L, arg+3, 0);
+    func = hookf; mask = makemask(smask, count);
   }
-  gethooktable(L1);
-  lua_pushlightuserdata(L1, L1);
+  gethooktable(L);
+  lua_pushlightuserdata(L, L1);
   lua_pushvalue(L, arg+1);
-  lua_xmove(L, L1, 1);
-  lua_rawset(L1, -3);  /* set new hook */
-  lua_pop(L1, 1);  /* remove hook table */
+  lua_rawset(L, -3);  /* set new hook */
+  lua_pop(L, 1);  /* remove hook table */
+  lua_sethook(L1, func, mask, count);  /* set hooks */
   return 0;
 }
 
@@ -286,11 +287,10 @@
   if (hook != NULL && hook != hookf)  /* external hook? */
     lua_pushliteral(L, "external hook");
   else {
-    gethooktable(L1);
-    lua_pushlightuserdata(L1, L1);
-    lua_rawget(L1, -2);   /* get hook */
-    lua_remove(L1, -2);  /* remove hook table */
-    lua_xmove(L1, L, 1);
+    gethooktable(L);
+    lua_pushlightuserdata(L, L1);
+    lua_rawget(L, -2);   /* get hook */
+    lua_remove(L, -2);  /* remove hook table */
   }
   lua_pushstring(L, unmakemask(mask, buff));
   lua_pushinteger(L, lua_gethookcount(L1));
--- a/src/lua-5.1.1/src/ldebug.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldebug.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $
+** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -432,14 +432,16 @@
         break;
       }
       case OP_CLOSURE: {
-        int nup;
+        int nup, j;
         check(b < pt->sizep);
         nup = pt->p[b]->nups;
         check(pc + nup < pt->sizecode);
-        for (; nup>0; nup--) {
-          OpCode op1 = GET_OPCODE(pt->code[pc+nup]);
+        for (j = 1; j <= nup; j++) {
+          OpCode op1 = GET_OPCODE(pt->code[pc + j]);
           check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
         }
+        if (reg != NO_REG)  /* tracing? */
+          pc += nup;  /* do not 'execute' these pseudo-instructions */
         break;
       }
       case OP_VARARG: {
@@ -561,8 +563,8 @@
 
 
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
-  if (ttisstring(p1)) p1 = p2;
-  lua_assert(!ttisstring(p1));
+  if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+  lua_assert(!ttisstring(p1) && !ttisnumber(p1));
   luaG_typeerror(L, p1, "concatenate");
 }
 
--- a/src/lua-5.1.1/src/ldebug.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldebug.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $
+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions from Debug Interface module
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/ldo.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldo.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -83,7 +83,7 @@
   L->base = L->ci->base;
   luaF_close(L, L->base);  /* close eventual pending closures */
   luaD_seterrorobj(L, status, L->base);
-  L->nCcalls = 0;
+  L->nCcalls = L->baseCcalls;
   L->allowhook = 1;
   restore_stack_limit(L);
   L->errfunc = 0;
@@ -332,7 +332,7 @@
   ptrdiff_t fr = savestack(L, firstResult);  /* next call may change stack */
   luaD_callhook(L, LUA_HOOKRET, -1);
   if (f_isLua(L->ci)) {  /* Lua function? */
-    while (L->ci->tailcalls--)  /* call hook for eventual tail calls */
+    while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
       luaD_callhook(L, LUA_HOOKTAILRET, -1);
   }
   return restorestack(L, fr);
@@ -417,22 +417,24 @@
 LUA_API int lua_resume (lua_State *L, int nargs) {
   int status;
   lua_lock(L);
-  if (L->status != LUA_YIELD) {
-    if (L->status != 0)
-      return resume_error(L, "cannot resume dead coroutine");
-    else if (L->ci != L->base_ci)
+  if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
       return resume_error(L, "cannot resume non-suspended coroutine");
-  }
+  if (L->nCcalls >= LUAI_MAXCCALLS)
+    return resume_error(L, "C stack overflow");
   luai_userstateresume(L, nargs);
-  lua_assert(L->errfunc == 0 && L->nCcalls == 0);
+  lua_assert(L->errfunc == 0);
+  L->baseCcalls = ++L->nCcalls;
   status = luaD_rawrunprotected(L, resume, L->top - nargs);
   if (status != 0) {  /* error? */
     L->status = cast_byte(status);  /* mark thread as `dead' */
     luaD_seterrorobj(L, status, L->top);
     L->ci->top = L->top;
   }
-  else
+  else {
+    lua_assert(L->nCcalls == L->baseCcalls);
     status = L->status;
+  }
+  --L->nCcalls;
   lua_unlock(L);
   return status;
 }
@@ -441,7 +443,7 @@
 LUA_API int lua_yield (lua_State *L, int nresults) {
   luai_userstateyield(L, nresults);
   lua_lock(L);
-  if (L->nCcalls > 0)
+  if (L->nCcalls > L->baseCcalls)
     luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
   L->base = L->top - nresults;  /* protect stack slots below */
   L->status = LUA_YIELD;
--- a/src/lua-5.1.1/src/ldo.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldo.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $
+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/ldump.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ldump.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $
+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** save precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lfunc.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lfunc.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $
+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */
@@ -55,7 +55,7 @@
   GCObject **pp = &L->openupval;
   UpVal *p;
   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);
     if (p->v == level) {  /* found a corresponding upvalue? */
       if (isdead(g, obj2gco(p)))  /* is it dead? */
@@ -96,7 +96,7 @@
 void luaF_close (lua_State *L, StkId level) {
   UpVal *uv;
   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);
     lua_assert(!isblack(o) && uv->v != &uv->u.value);
     L->openupval = uv->next;  /* remove from `open' list */
--- a/src/lua-5.1.1/src/lfunc.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lfunc.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $
+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lgc.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lgc.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lgc.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lgc.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $
+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/linit.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/linit.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $
+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Initialization of libraries for lua.c
 ** See Copyright Notice in lua.h
 */
@@ -13,6 +13,7 @@
 #include "lualib.h"
 #include "lauxlib.h"
 
+
 static const luaL_Reg lualibs[] = {
   {"", luaopen_base},
   {LUA_LOADLIBNAME, luaopen_package},
--- a/src/lua-5.1.1/src/liolib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/liolib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -51,7 +51,7 @@
 }
 
 
-#define topfile(L)	((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+#define tofilep(L)	((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
 
 
 static int io_type (lua_State *L) {
@@ -70,7 +70,7 @@
 
 
 static FILE *tofile (lua_State *L) {
-  FILE **f = topfile(L);
+  FILE **f = tofilep(L);
   if (*f == NULL)
     luaL_error(L, "attempt to use a closed file");
   return *f;
@@ -93,19 +93,31 @@
 
 
 /*
-** this function has a separated environment, which defines the
-** correct __close for 'popen' files
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+  lua_pushnil(L);
+  lua_pushliteral(L, "cannot close standard file");
+  return 2;
+}
+
+
+/*
+** function to close 'popen' files
 */
 static int io_pclose (lua_State *L) {
-  FILE **p = topfile(L);
+  FILE **p = tofilep(L);
   int ok = lua_pclose(L, *p);
   *p = NULL;
   return pushresult(L, ok, NULL);
 }
 
 
+/*
+** function to close regular files
+*/
 static int io_fclose (lua_State *L) {
-  FILE **p = topfile(L);
+  FILE **p = tofilep(L);
   int ok = (fclose(*p) == 0);
   *p = NULL;
   return pushresult(L, ok, NULL);
@@ -128,18 +140,18 @@
 
 
 static int io_gc (lua_State *L) {
-  FILE *f = *topfile(L);
-  /* ignore closed files and standard files */
-  if (f != NULL && f != stdin && f != stdout && f != stderr)
+  FILE *f = *tofilep(L);
+  /* ignore closed files */
+  if (f != NULL)
     aux_close(L);
   return 0;
 }
 
 
 static int io_tostring (lua_State *L) {
-  FILE *f = *topfile(L);
+  FILE *f = *tofilep(L);
   if (f == NULL)
-    lua_pushstring(L, "file (closed)");
+    lua_pushliteral(L, "file (closed)");
   else
     lua_pushfstring(L, "file (%p)", f);
   return 1;
@@ -155,6 +167,10 @@
 }
 
 
+/*
+** this function has a separated environment, which defines the
+** correct __close for 'popen' files
+*/
 static int io_popen (lua_State *L) {
   const char *filename = luaL_checkstring(L, 1);
   const char *mode = luaL_optstring(L, 2, "r");
@@ -280,7 +296,7 @@
     char *p = luaL_prepbuffer(&b);
     if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) {  /* eof? */
       luaL_pushresult(&b);  /* close buffer */
-      return (lua_strlen(L, -1) > 0);  /* check whether read something */
+      return (lua_objlen(L, -1) > 0);  /* check whether read something */
     }
     l = strlen(p);
     if (l == 0 || p[l-1] != '\n')
@@ -308,7 +324,7 @@
     n -= nr;  /* still have to read `n' chars */
   } while (n > 0 && nr == rlen);  /* until end of count or eof */
   luaL_pushresult(&b);  /* close buffer */
-  return (n == 0 || lua_strlen(L, -1) > 0);
+  return (n == 0 || lua_objlen(L, -1) > 0);
 }
 
 
@@ -502,31 +518,36 @@
     lua_pushvalue(L, -1);
     lua_rawseti(L, LUA_ENVIRONINDEX, k);
   }
-  lua_setfield(L, -2, fname);
+  lua_pushvalue(L, -2);  /* copy environment */
+  lua_setfenv(L, -2);  /* set it */
+  lua_setfield(L, -3, fname);
+}
+
+
+static void newfenv (lua_State *L, lua_CFunction cls) {
+  lua_createtable(L, 0, 1);
+  lua_pushcfunction(L, cls);
+  lua_setfield(L, -2, "__close");
 }
 
 
 LUALIB_API int luaopen_io (lua_State *L) {
   createmeta(L);
   /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
-  lua_createtable(L, 2, 1);
+  newfenv(L, io_fclose);
   lua_replace(L, LUA_ENVIRONINDEX);
   /* open library */
   luaL_register(L, LUA_IOLIBNAME, iolib);
   /* create (and set) default files */
+  newfenv(L, io_noclose);  /* close function for default files */
   createstdfile(L, stdin, IO_INPUT, "stdin");
   createstdfile(L, stdout, IO_OUTPUT, "stdout");
   createstdfile(L, stderr, 0, "stderr");
-  /* create environment for 'popen' */
+  lua_pop(L, 1);  /* pop environment for default files */
   lua_getfield(L, -1, "popen");
-  lua_createtable(L, 0, 1);
-  lua_pushcfunction(L, io_pclose);
-  lua_setfield(L, -2, "__close");
-  lua_setfenv(L, -2);
+  newfenv(L, io_pclose);  /* create environment for 'popen' */
+  lua_setfenv(L, -2);  /* set fenv for 'popen' */
   lua_pop(L, 1);  /* pop 'popen' */
-  /* set default close function */
-  lua_pushcfunction(L, io_fclose);
-  lua_setfield(L, LUA_ENVIRONINDEX, "__close");
   return 1;
 }
 
--- a/src/lua-5.1.1/src/llimits.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/llimits.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Limits, basic types, and some other `installation-dependent' definitions
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lmathlib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lmathlib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $
+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Standard mathematical library
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lmem.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lmem.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $
+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lmem.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lmem.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $
+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/loadlib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/loadlib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $
 ** Dynamic library loader for Lua
 ** See Copyright Notice in lua.h
 **
@@ -16,9 +16,9 @@
 #define loadlib_c
 #define LUA_LIB
 
+#include "lua.h"
+
 #include "lauxlib.h"
-#include "lobject.h"
-#include "lua.h"
 #include "lualib.h"
 
 
@@ -98,7 +98,7 @@
   char buff[MAX_PATH + 1];
   char *lb;
   DWORD nsize = sizeof(buff)/sizeof(char);
-  DWORD n = GetModuleFileName(NULL, buff, nsize);
+  DWORD n = GetModuleFileNameA(NULL, buff, nsize);
   if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
     luaL_error(L, "unable to get ModuleFileName");
   else {
@@ -112,7 +112,7 @@
 static void pusherror (lua_State *L) {
   int error = GetLastError();
   char buffer[128];
-  if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+  if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
       NULL, error, 0, buffer, sizeof(buffer), NULL))
     lua_pushstring(L, buffer);
   else
@@ -125,7 +125,7 @@
 
 
 static void *ll_load (lua_State *L, const char *path) {
-  HINSTANCE lib = LoadLibrary(path);
+  HINSTANCE lib = LoadLibraryA(path);
   if (lib == NULL) pusherror(L);
   return lib;
 }
@@ -356,15 +356,16 @@
   path = lua_tostring(L, -1);
   if (path == NULL)
     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) {
     const char *filename;
     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? */
       return filename;  /* return that file name */
-    lua_pop(L, 2);  /* remove path template and file name */ 
-    luaO_pushfstring(L, "\n\tno file " LUA_QS, filename);
-    lua_concat(L, 2);
+    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
+    lua_remove(L, -2);  /* remove file name */
+    lua_concat(L, 2);  /* add entry to possible error message */
   }
   return NULL;  /* not found */
 }
@@ -423,8 +424,8 @@
   funcname = mkfuncname(L, name);
   if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
     if (stat != ERRFUNC) loaderror(L, filename);  /* real error */
-    luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
-                        name, filename);
+    lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
+                       name, filename);
     return 1;  /* function not found */
   }
   return 1;
@@ -438,7 +439,7 @@
     luaL_error(L, LUA_QL("package.preload") " must be a table");
   lua_getfield(L, -1, name);
   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;
 }
 
@@ -462,7 +463,7 @@
   lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
   if (!lua_istable(L, -1))
     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++) {
     lua_rawgeti(L, -2, i);  /* get a loader */
     if (lua_isnil(L, -1))
@@ -646,8 +647,8 @@
   setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT);  /* set field `path' */
   setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
   /* store config information */
-  lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
-                    LUA_EXECDIR "\n" LUA_IGMARK);
+  lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
+                     LUA_EXECDIR "\n" LUA_IGMARK);
   lua_setfield(L, -2, "config");
   /* set field `loaded' */
   luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);
--- a/src/lua-5.1.1/src/lobject.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lobject.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $
+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lobject.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lobject.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
+** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lopcodes.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lopcodes.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $
+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
 ** See Copyright Notice in lua.h
 */
 
--- a/src/lua-5.1.1/src/lopcodes.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lopcodes.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $
+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Opcodes for Lua virtual machine
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/loslib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/loslib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: loslib.c,v 1.19 2006/04/26 18:19:49 roberto Exp $
+** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
 ** Standard Operating System library
 ** See Copyright Notice in lua.h
 */
@@ -146,11 +146,22 @@
     setboolfield(L, "isdst", stm->tm_isdst);
   }
   else {
-    char b[256];
-    if (strftime(b, sizeof(b), s, stm))
-      lua_pushstring(L, b);
-    else
-      return luaL_error(L, LUA_QL("date") " format too long");
+    char cc[3];
+    luaL_Buffer b;
+    cc[0] = '%'; cc[2] = '\0';
+    luaL_buffinit(L, &b);
+    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);
+        luaL_addlstring(&b, buff, reslen);
+      }
+    }
+    luaL_pushresult(&b);
   }
   return 1;
 }
@@ -204,7 +215,6 @@
 
 static int os_exit (lua_State *L) {
   exit(luaL_optint(L, 1, EXIT_SUCCESS));
-  return 0;  /* to avoid warnings */
 }
 
 static const luaL_Reg syslib[] = {
--- a/src/lua-5.1.1/src/lparser.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lparser.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lstate.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lstate.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $
+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -93,7 +93,7 @@
   resethookcount(L);
   L->openupval = NULL;
   L->size_ci = 0;
-  L->nCcalls = 0;
+  L->nCcalls = L->baseCcalls = 0;
   L->status = 0;
   L->base_ci = L->ci = NULL;
   L->savedpc = NULL;
@@ -205,7 +205,7 @@
   do {  /* repeat until no more errors */
     L->ci = L->base_ci;
     L->base = L->top = L->ci->base;
-    L->nCcalls = 0;
+    L->nCcalls = L->baseCcalls = 0;
   } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
   lua_assert(G(L)->tmudata == NULL);
   luai_userstateclose(L);
--- a/src/lua-5.1.1/src/lstate.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lstate.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -112,6 +112,7 @@
   int stacksize;
   int size_ci;  /* size of array `base_ci' */
   unsigned short nCcalls;  /* number of nested C calls */
+  unsigned short baseCcalls;  /* nested C calls when resuming coroutine */
   lu_byte hookmask;
   lu_byte allowhook;
   int basehookcount;
--- a/src/lua-5.1.1/src/lstring.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lstring.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $
+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** String table (keeps all strings handled by Lua)
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lstring.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lstring.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $
+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
 ** String table (keep all strings handled by Lua)
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lstrlib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lstrlib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -629,10 +629,6 @@
       lua_gettable(L, 3);
       break;
     }
-    default: {
-      luaL_argerror(L, 3, "string/function/table expected"); 
-      return;
-    }
   }
   if (!lua_toboolean(L, -1)) {  /* nil or false? */
     lua_pop(L, 1);
@@ -648,11 +644,15 @@
   size_t srcl;
   const char *src = luaL_checklstring(L, 1, &srcl);
   const char *p = luaL_checkstring(L, 2);
+  int  tr = lua_type(L, 3);
   int max_s = luaL_optint(L, 4, srcl+1);
   int anchor = (*p == '^') ? (p++, 1) : 0;
   int n = 0;
   MatchState ms;
   luaL_Buffer b;
+  luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+                   tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+                      "string/function/table expected");
   luaL_buffinit(L, &b);
   ms.L = L;
   ms.src_init = src;
@@ -723,7 +723,7 @@
 
 static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
   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))
     luaL_error(L, "invalid format (repeated flags)");
   if (isdigit(uchar(*p))) p++;  /* skip width */
--- a/src/lua-5.1.1/src/ltable.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ltable.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -84,8 +84,8 @@
 static Node *hashnum (const Table *t, lua_Number n) {
   unsigned int a[numints];
   int i;
-  n += 1;  /* normalize number (avoid -0) */
-  lua_assert(sizeof(a) <= sizeof(n));
+  if (luai_numeq(n, 0))  /* avoid problems with -0 */
+    return gnode(t, 0);
   memcpy(a, &n, sizeof(a));
   for (i = 1; i < numints; i++) a[0] += a[i];
   return hashmod(t, a[0]);
--- a/src/lua-5.1.1/src/ltable.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ltable.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $
+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/ltablib.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ltablib.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $
+** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Library for Table Manipulation
 ** See Copyright Notice in lua.h
 */
@@ -118,7 +118,8 @@
 static int tremove (lua_State *L) {
   int e = aux_getn(L, 1);
   int pos = luaL_optint(L, 2, e);
-  if (e == 0) return 0;  /* table is `empty' */
+  if (!(1 <= pos && pos <= e))  /* position is outside bounds? */
+   return 0;  /* nothing to remove */
   luaL_setn(L, 1, e - 1);  /* t.n = n-1 */
   lua_rawgeti(L, 1, pos);  /* result = t[pos] */
   for ( ;pos<e; pos++) {
--- a/src/lua-5.1.1/src/ltm.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ltm.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $
+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/ltm.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/ltm.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $
+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lua.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lua.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 */
@@ -74,6 +74,8 @@
 
 
 static int traceback (lua_State *L) {
+  if (!lua_isstring(L, 1))  /* 'message' not a string? */
+    return 1;  /* keep it intact */
   lua_getfield(L, LUA_GLOBALSINDEX, "debug");
   if (!lua_istable(L, -1)) {
     lua_pop(L, 1);
@@ -144,7 +146,7 @@
 static int dolibrary (lua_State *L, const char *name) {
   lua_getglobal(L, "require");
   lua_pushstring(L, name);
-  return report(L, lua_pcall(L, 1, 0, 0));
+  return report(L, docall(L, 1, 1));
 }
 
 
--- a/src/lua-5.1.1/src/lua.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lua.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,9 +1,8 @@
 /*
-** $Id: lua.h,v 1.218 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
 ** Lua - An Extensible Extension Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
-** Please refer to LICENSE.txt in the root directory of the Toby source
-**  distribution for licensing details, including original Lua license.
+** See Copyright Notice at the end of this file
 */
 
 
@@ -18,9 +17,9 @@
 
 
 #define LUA_VERSION	"Lua 5.1"
-#define LUA_RELEASE	"Lua 5.1.1"
+#define LUA_RELEASE	"Lua 5.1.3"
 #define LUA_VERSION_NUM	501
-#define LUA_COPYRIGHT	"Copyright (C) 1994-2006 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT	"Copyright (C) 1994-2008 Lua.org, PUC-Rio"
 #define LUA_AUTHORS 	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
 
 
@@ -295,6 +294,9 @@
 #define lua_Chunkwriter		lua_Writer
 
 
+/* hack */
+LUA_API void lua_setlevel	(lua_State *from, lua_State *to);
+
 
 /*
 ** {======================================================================
@@ -360,7 +362,7 @@
 
 
 /******************************************************************************
-* Copyright (C) 1994-2006 Lua.org, PUC-Rio.  All rights reserved.
+* Copyright (C) 1994-2008 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
--- a/src/lua-5.1.1/src/luaconf.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/luaconf.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $
+** $Id: luaconf.h,v 1.82.1.6 2008/01/18 17:07:48 roberto Exp $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -360,7 +360,7 @@
 /*
 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
 @* 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'
 */
 #define LUA_COMPAT_OPENLIB
@@ -442,7 +442,8 @@
 ** functions. This limit is arbitrary; its only purpose is to stop C
 ** functions to consume unlimited stack space.
 */
-#define LUAI_MAXCSTACK	2048
+#define LUAI_MCS_AUX	((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
+#define LUAI_MAXCSTACK	(LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
 
 
 
@@ -666,7 +667,7 @@
 */
 #if defined(LUA_USE_POPEN)
 
-#define lua_popen(L,c,m)	((void)L, popen(c,m))
+#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
 #define lua_pclose(L,file)	((void)L, (pclose(file) != -1))
 
 #elif defined(LUA_WIN)
--- a/src/lua-5.1.1/src/lualib.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lualib.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua standard libraries
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lundump.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lundump.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
+** $Id: lundump.c,v 2.7.1.2 2008/01/18 16:39:11 roberto Exp $
 ** load precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -29,6 +29,7 @@
 
 #ifdef LUAC_TRUST_BINARIES
 #define IF(c,s)
+#define error(S,s)
 #else
 #define IF(c,s)		if (c) error(S,s)
 
@@ -47,6 +48,7 @@
 static void LoadBlock(LoadState* S, void* b, size_t size)
 {
  size_t r=luaZ_read(S->Z,b,size);
+ UNUSED(r);
  IF (r!=0, "unexpected end");
 }
 
@@ -122,7 +124,7 @@
 	setsvalue2n(S->L,o,LoadString(S));
 	break;
    default:
-	IF (1, "bad constant");
+	error(S,"bad constant");
 	break;
   }
  }
--- a/src/lua-5.1.1/src/lundump.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lundump.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
 ** load precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lvm.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lvm.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 roberto Exp $
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -61,11 +61,9 @@
   lu_byte mask = L->hookmask;
   const Instruction *oldpc = L->savedpc;
   L->savedpc = pc;
-  if (mask > LUA_MASKLINE) {  /* instruction-hook set? */
-    if (L->hookcount == 0) {
-      resethookcount(L);
-      luaD_callhook(L, LUA_HOOKCOUNT, -1);
-    }
+  if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
+    resethookcount(L);
+    luaD_callhook(L, LUA_HOOKCOUNT, -1);
   }
   if (mask & LUA_MASKLINE) {
     Proto *p = ci_func(L->ci)->l.p;
@@ -165,7 +163,7 @@
   const TValue *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */
   if (ttisnil(tm))
     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);
   return 1;
 }
@@ -281,10 +279,12 @@
   do {
     StkId top = L->base + last + 1;
     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))
         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 */
       size_t tl = tsvalue(top-1)->len;
       char *buffer;
--- a/src/lua-5.1.1/src/lvm.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lvm.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $
+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lzio.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lzio.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $
+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
 ** a generic input stream interface
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/lzio.h	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/lzio.h	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Buffered streams
 ** See Copyright Notice in lua.h
 */
--- a/src/lua-5.1.1/src/print.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/lua-5.1.1/src/print.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1,5 +1,5 @@
 /*
-** $Id: print.c,v 1.55 2006/05/31 13:30:05 lhf Exp $
+** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $
 ** print bytecodes
 ** See Copyright Notice in lua.h
 */
@@ -23,8 +23,7 @@
 static void PrintString(const TString* ts)
 {
  const char* s=getstr(ts);
- int n=ts->tsv.len;
- int i;
+ size_t i,n=ts->tsv.len;
  putchar('"');
  for (i=0; i<n; i++)
  {
@@ -32,6 +31,7 @@
   switch (c)
   {
    case '"': printf("\\\""); break;
+   case '\\': printf("\\\\"); break;
    case '\a': printf("\\a"); break;
    case '\b': printf("\\b"); break;
    case '\f': printf("\\f"); break;
--- a/src/toby_app.c	Tue Mar 18 01:07:01 2008 +0000
+++ b/src/toby_app.c	Tue Mar 18 02:05:22 2008 +0000
@@ -1370,7 +1370,7 @@
 "\n"
 "Toby uses code from Lua. The Lua copyright follows.\n"
 "\n"
-"Copyright (C) 1994-2006 Lua.org, PUC-Rio.\n"
+"Copyright (C) 1994-2008 Lua.org, PUC-Rio.\n"
 "\n"
 "Permission is hereby granted, free of charge, to any person obtaining a copy "
 "of this software and associated documentation files (the \"Software\"), to deal "