summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2006-02-07 12:00:00 +0000
committerrepogen <>2006-02-07 12:00:00 +0000
commit43fb64048e381a76d6cd363dedd9ccc8a85b9b31 (patch)
tree98ca9eb0375499f20a4ca13d2cbbc4451f6e9477
parentb487a3dce43e449acf3852ec56345e2860cfeab7 (diff)
downloadlua-github-43fb64048e381a76d6cd363dedd9ccc8a85b9b31.tar.gz
Lua 5.1-rc35.1-rc3
-rw-r--r--HISTORY2
-rw-r--r--INSTALL3
-rw-r--r--MANIFEST28
-rw-r--r--Makefile35
-rw-r--r--doc/contents.html28
-rw-r--r--doc/lua.html2
-rw-r--r--doc/luac.html10
-rw-r--r--doc/manual.html668
-rw-r--r--etc/Makefile21
-rw-r--r--etc/README9
-rw-r--r--etc/lua.pc18
-rw-r--r--src/Makefile2
-rw-r--r--src/liolib.c4
-rw-r--r--src/llex.c4
-rw-r--r--src/loslib.c9
-rw-r--r--src/lstate.h10
-rw-r--r--src/luaconf.h4
17 files changed, 480 insertions, 377 deletions
diff --git a/HISTORY b/HISTORY
index 122f6563..885c35ba 100644
--- a/HISTORY
+++ b/HISTORY
@@ -14,7 +14,7 @@ HISTORY for Lua 5.1
API:
+ new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
+ user supplies memory allocator (lua_open becomes lua_newstate).
- + luaopen_* functionst be called through Lua.
+ + luaopen_* functionst must be called through Lua.
Implementation:
+ new configuration scheme via luaconf.h.
+ incremental garbage collection.
diff --git a/INSTALL b/INSTALL
index 293b44ea..65f6f1eb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -23,6 +23,9 @@ INSTALL for Lua 5.1
place and the way to install files are defined in Makefile. You must
have the right permissions to install files.
+ If you want to build and install Lua in one step, do "make xxx install",
+ where xxx is your platform name.
+
If you want to install Lua locally, then do "make local". This will
create directories bin, include, lib, man, and install Lua there as
follows:
diff --git a/MANIFEST b/MANIFEST
index a554dc12..1f70c5e8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,33 +1,34 @@
-MANIFEST contents of Lua 5.1 distribution on Tue Jan 24 16:12:03 BRST 2006
+MANIFEST contents of Lua 5.1 distribution on Tue Feb 7 15:05:04 BRST 2006
lua-5.1
lua-5.1/COPYRIGHT
+lua-5.1/HISTORY
+lua-5.1/INSTALL
+lua-5.1/MANIFEST
+lua-5.1/Makefile
+lua-5.1/README
lua-5.1/doc
lua-5.1/doc/contents.html
lua-5.1/doc/logo.gif
lua-5.1/doc/lua.1
-lua-5.1/doc/luac.1
-lua-5.1/doc/luac.html
lua-5.1/doc/lua.css
lua-5.1/doc/lua.html
+lua-5.1/doc/luac.1
+lua-5.1/doc/luac.html
lua-5.1/doc/manual.html
lua-5.1/doc/readme.html
lua-5.1/etc
+lua-5.1/etc/Makefile
+lua-5.1/etc/README
lua-5.1/etc/all.c
lua-5.1/etc/lua.hpp
lua-5.1/etc/lua.ico
lua-5.1/etc/lua.pc
lua-5.1/etc/luavs.bat
-lua-5.1/etc/Makefile
lua-5.1/etc/min.c
lua-5.1/etc/noparser.c
-lua-5.1/etc/README
lua-5.1/etc/strict.lua
-lua-5.1/HISTORY
-lua-5.1/INSTALL
-lua-5.1/Makefile
-lua-5.1/MANIFEST
-lua-5.1/README
lua-5.1/src
+lua-5.1/src/Makefile
lua-5.1/src/lapi.c
lua-5.1/src/lapi.h
lua-5.1/src/lauxlib.c
@@ -72,9 +73,9 @@ lua-5.1/src/ltablib.c
lua-5.1/src/ltm.c
lua-5.1/src/ltm.h
lua-5.1/src/lua.c
+lua-5.1/src/lua.h
lua-5.1/src/luac.c
lua-5.1/src/luaconf.h
-lua-5.1/src/lua.h
lua-5.1/src/lualib.h
lua-5.1/src/lundump.c
lua-5.1/src/lundump.h
@@ -82,22 +83,21 @@ lua-5.1/src/lvm.c
lua-5.1/src/lvm.h
lua-5.1/src/lzio.c
lua-5.1/src/lzio.h
-lua-5.1/src/Makefile
lua-5.1/src/print.c
lua-5.1/test
+lua-5.1/test/README
lua-5.1/test/bisect.lua
lua-5.1/test/cf.lua
lua-5.1/test/echo.lua
lua-5.1/test/env.lua
lua-5.1/test/factorial.lua
-lua-5.1/test/fibfor.lua
lua-5.1/test/fib.lua
+lua-5.1/test/fibfor.lua
lua-5.1/test/globals.lua
lua-5.1/test/hello.lua
lua-5.1/test/life.lua
lua-5.1/test/luac.lua
lua-5.1/test/printf.lua
-lua-5.1/test/README
lua-5.1/test/readonly.lua
lua-5.1/test/sieve.lua
lua-5.1/test/sort.lua
diff --git a/Makefile b/Makefile
index db9bb3d9..682256b4 100644
--- a/Makefile
+++ b/Makefile
@@ -22,10 +22,17 @@ 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
+INSTALL_EXEC= $(CP)
+INSTALL_DATA= $(CP)
+#INSTALL_EXEC= $(INSTALL) -m 0755
+#INSTALL_DATA= $(INSTALL) -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 =========
@@ -46,15 +53,16 @@ all: $(PLAT)
$(PLATS) clean:
cd src; $(MAKE) $@
-test: all
+test: dummy
src/lua test/hello.lua
-install:
- cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+install: dummy
+ cd src; $(MKDIR) -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc; $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+# $(RANLIB) $(INSTALL_LIB)/$(TO_LIB)
local:
$(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"
@@ -62,6 +70,9 @@ local:
none:
@echo "Please choose a platform: $(PLATS)"
+# make may get confused with test/ and INSTALL in a case-insensitive OS
+dummy:
+
# echo config parameters
echo:
@echo ""
@@ -77,11 +88,10 @@ echo:
@echo "INSTALL_INC = $(INSTALL_INC)"
@echo "INSTALL_LIB = $(INSTALL_LIB)"
@echo "INSTALL_MAN = $(INSTALL_MAN)"
- @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
- @echo "INSTALL_DATA = $(INSTALL_DATA)"
@echo "INSTALL_LMOD = $(INSTALL_LMOD)"
@echo "INSTALL_CMOD = $(INSTALL_CMOD)"
- @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
+ @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
+ @echo "INSTALL_DATA = $(INSTALL_DATA)"
@echo ""
@echo "See also src/luaconf.h ."
@echo ""
@@ -104,6 +114,9 @@ lecho:
# show what has changed since we unpacked
newer:
- @find . -newer MANIFEST -type f
+ @$(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
# (end of Makefile)
diff --git a/doc/contents.html b/doc/contents.html
index 7b890342..323bfaef 100644
--- a/doc/contents.html
+++ b/doc/contents.html
@@ -154,24 +154,31 @@ Lua 5.1 Reference Manual
<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.def">math.def</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>
<A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR>
+<A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
<A HREF="manual.html#pdf-math.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>
<A HREF="manual.html#pdf-math.pow">math.pow</A><BR>
-<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
+<A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
+<A HREF="manual.html#pdf-math.random">math.random</A><BR>
+<A HREF="manual.html#pdf-math.randomseed">math.randomseed</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>
<A HREF="manual.html#pdf-module">module</A><BR>
<A HREF="manual.html#pdf-next">next</A><BR>
<A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
@@ -225,6 +232,7 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#pdf-type">type</A><BR>
<A HREF="manual.html#pdf-unpack">unpack</A><BR>
<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
+
</TD>
<TD>
<H3>API</H3>
@@ -251,6 +259,7 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#lua_getallocf">lua_getallocf</A><BR>
<A HREF="manual.html#lua_getfenv">lua_getfenv</A><BR>
<A HREF="manual.html#lua_getfield">lua_getfield</A><BR>
+<A HREF="manual.html#lua_getglobal">lua_getglobal</A><BR>
<A HREF="manual.html#lua_gethook">lua_gethook</A><BR>
<A HREF="manual.html#lua_gethookcount">lua_gethookcount</A><BR>
<A HREF="manual.html#lua_gethookmask">lua_gethookmask</A><BR>
@@ -300,12 +309,14 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>
<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>
<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>
+<A HREF="manual.html#lua_register">lua_register</A><BR>
<A HREF="manual.html#lua_remove">lua_remove</A><BR>
<A HREF="manual.html#lua_replace">lua_replace</A><BR>
<A HREF="manual.html#lua_resume">lua_resume</A><BR>
<A HREF="manual.html#lua_setallocf">lua_setallocf</A><BR>
<A HREF="manual.html#lua_setfenv">lua_setfenv</A><BR>
<A HREF="manual.html#lua_setfield">lua_setfield</A><BR>
+<A HREF="manual.html#lua_setglobal">lua_setglobal</A><BR>
<A HREF="manual.html#lua_sethook">lua_sethook</A><BR>
<A HREF="manual.html#lua_setlocal">lua_setlocal</A><BR>
<A HREF="manual.html#lua_setmetatable">lua_setmetatable</A><BR>
@@ -326,6 +337,7 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#lua_typename">lua_typename</A><BR>
<A HREF="manual.html#lua_xmove">lua_xmove</A><BR>
<A HREF="manual.html#lua_yield">lua_yield</A><BR>
+
</TD>
<TD>
<H3>Auxiliary library</H3>
@@ -360,6 +372,7 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#luaL_loadstring">luaL_loadstring</A><BR>
<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>
<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>
+<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>
<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
<A HREF="manual.html#luaL_optlong">luaL_optlong</A><BR>
@@ -374,6 +387,7 @@ Lua 5.1 Reference Manual
<A HREF="manual.html#luaL_typerror">luaL_typerror</A><BR>
<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>
<A HREF="manual.html#luaL_where">luaL_where</A><BR>
+
</TD>
</TR>
</TABLE>
@@ -382,7 +396,7 @@ Lua 5.1 Reference Manual
<HR>
<SMALL>
Last update:
-Tue Jan 10 10:10:22 BRST 2006
+Tue Feb 7 14:37:59 BRST 2006
</SMALL>
</BODY>
diff --git a/doc/lua.html b/doc/lua.html
index 5900321f..1d435ab0 100644
--- a/doc/lua.html
+++ b/doc/lua.html
@@ -149,7 +149,7 @@ is executed.
<P>
<B>-l </B><I>name</I>
call
-<B>require(' name</B><I>')</I>
+<B>require</B>('<I>name</I>')
before executing
<I>script</I>.
Typically used to load libraries.
diff --git a/doc/luac.html b/doc/luac.html
index 3ecdfdf0..7b7e0f70 100644
--- a/doc/luac.html
+++ b/doc/luac.html
@@ -28,13 +28,13 @@ protecting source code from accidental user changes,
and
off-line syntax checking.
<P>
-Pre-compiling does not imply faster execution
+Precompiling does not imply faster execution
because in Lua chunks are always compiled into bytecodes before being executed.
<B>luac</B>
simply allows those bytecodes to be saved in a file for later execution.
<P>
-Pre-compiled chunks are not necessarily smaller than the corresponding source.
-The main goal in pre-compiling is faster loading.
+Precompiled chunks are not necessarily smaller than the corresponding source.
+The main goal in precompiling is faster loading.
<P>
The binary files created by
<B>luac</B>
@@ -54,9 +54,9 @@ In the command line,
you can mix
text files containing Lua source and
binary files containing precompiled chunks.
-This is useful to combine several precompiled chunks,
+This is useful because several precompiled chunks,
even from different (but compatible) platforms,
-into a single precompiled chunk.
+can be combined into a single precompiled chunk.
<P>
You can use
<B>'-'</B>
diff --git a/doc/manual.html b/doc/manual.html
index 9a115e74..e7a3cfa4 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -8,9 +8,9 @@
<body bgcolor="#FFFFFF">
-<hr />
+<hr></hr>
<h1>
-<a href="http://www.lua.org/home.html"><img src="logo.gif" alt="[Lua logo]" border="0" /></a>
+<a href="http://www.lua.org/home.html"><img src="logo.gif" alt="[Lua logo]" border="0"></img></a>
Lua 5.1 Reference Manual
</h1>
@@ -20,7 +20,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
<a href="http://www.lua.org/copyright.html">Copyright</a>
&copy; 2006 Lua.org, PUC-Rio. All rights reserved.
</small>
-<hr />
+<hr></hr>
<p>
<p>
@@ -302,7 +302,7 @@ Any arithmetic operation applied to a string tries to convert
that string to a number, following the usual conversion rules.
Conversely, whenever a number is used where a string is expected,
the number is converted to a string, in a reasonable format.
-For complete control of how numbers are converted to strings,
+For complete control over how numbers are converted to strings,
use the <code>format</code> function from the string library
(see <a href="#pdf-string.format"><code>string.format</code></a>).
@@ -1554,9 +1554,9 @@ They are used as the default environment for other Lua functions
created by that function.
<p>You can change the environment of a Lua function or the
-running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
+running thread by calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
You can get the environment of a Lua function or the running thread
-calling <a href="#pdf-getfenv"><code>getfenv</code></a>.
+by calling <a href="#pdf-getfenv"><code>getfenv</code></a>.
To manipulate the environment of other objects
(userdata, C functions, other threads) you must
use the C API.
@@ -1565,7 +1565,7 @@ use the C API.
<p>Lua performs automatic memory management.
That means that
-you do not have to worry neither about allocating memory for new objects
+you have to worry neither about allocating memory for new objects
nor about freeing it when the objects are no longer needed.
Lua manages memory automatically by running
a <em>garbage collector</em> from time to time
@@ -1577,7 +1577,7 @@ tables, userdata, functions, threads, and strings.
<p>Lua implements an incremental mark-and-sweep collector.
It uses two numbers to control its garbage-collection cycles:
the <em>garbage-collector pause</em> and
-the <em>garbage-collector multiplier</em>.
+the <em>garbage-collector step multiplier</em>.
<p>The garbage-collector pause
controls how long the collector waits before starting a new cycle.
@@ -1587,7 +1587,7 @@ start a new cycle.
A value of 2 means that the collector waits more or less to double
the total memory in use before starting a new cycle.
-<p>The garbage-collector multiplier
+<p>The step multiplier
controls the relative speed of the collector relative to
memory allocation.
Larger values make the collector more aggressive but also increases
@@ -1898,7 +1898,7 @@ or a light userdata with the address of a C object in your code.
<p>The integer keys in the registry are used by the reference mechanism,
implemented by the auxiliary library,
-and therefore should not be used by other purposes.
+and therefore should not be used for other purposes.
<p><a name="3.6"></a><h2>3.6 - Error Handling in C</h2>
@@ -1930,7 +1930,7 @@ so they never raise an error:
alphabetical order.
<p><a name="lua_Alloc"></a>
-<hr /><h3><code>lua_Alloc</code></h3>
+<hr></hr><h3><code>lua_Alloc</code></h3>
<pre>
typedef void * (*lua_Alloc) (void *ud,
void *ptr,
@@ -1979,7 +1979,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
</pre>
<p><a name="lua_atpanic"></a>
-<hr /><h3><code>lua_atpanic</code></h3>
+<hr></hr><h3><code>lua_atpanic</code></h3>
<pre>
lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
</pre>
@@ -1997,7 +1997,7 @@ never returning (e.g., doing a long jump).
<p>The panic function can access the error message at the top of the stack.
<p><a name="lua_call"></a>
-<hr /><h3><code>lua_call</code></h3>
+<hr></hr><h3><code>lua_call</code></h3>
<pre>
void lua_call (lua_State *L, int nargs, int nresults);
</pre>
@@ -2047,7 +2047,7 @@ at its end, the stack is back to its original configuration.
This is considered good programming practice.
<p><a name="lua_CFunction"></a>
-<hr /><h3><code>lua_CFunction</code></h3>
+<hr></hr><h3><code>lua_CFunction</code></h3>
<pre>
typedef int (*lua_CFunction) (lua_State *L);
</pre>
@@ -2093,20 +2093,20 @@ of numerical arguments and returns their average and sum:
</pre>
<p><a name="lua_checkstack"></a>
-<hr /><h3><code>lua_checkstack</code></h3>
+<hr></hr><h3><code>lua_checkstack</code></h3>
<pre>
int lua_checkstack (lua_State *L, int extra);
</pre>
<p>Ensures that there are at least <code>extra</code> free stack slots in the stack.
-it returns false if it cannot grow the stack to that size.
+It returns false if it cannot grow the stack to that size.
This function never shrinks the stack;
if the stack is already larger than the new size,
it is left unchanged.
<p><a name="lua_close"></a>
-<hr /><h3><code>lua_close</code></h3>
+<hr></hr><h3><code>lua_close</code></h3>
<pre>
void lua_close (lua_State *L);
</pre>
@@ -2123,7 +2123,7 @@ might need to release states as soon as they are not needed,
to avoid growing too large.
<p><a name="lua_concat"></a>
-<hr /><h3><code>lua_concat</code></h3>
+<hr></hr><h3><code>lua_concat</code></h3>
<pre>
void lua_concat (lua_State *L, int n);
</pre>
@@ -2138,7 +2138,7 @@ Concatenation is done following the usual semantics of Lua
(see <a href="#concat">2.5.4</a>).
<p><a name="lua_cpcall"></a>
-<hr /><h3><code>lua_cpcall</code></h3>
+<hr></hr><h3><code>lua_cpcall</code></h3>
<pre>
int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);
</pre>
@@ -2154,7 +2154,7 @@ otherwise, it returns zero, and does not change the stack.
All values returned by <code>func</code> are discarded.
<p><a name="lua_createtable"></a>
-<hr /><h3><code>lua_createtable</code></h3>
+<hr></hr><h3><code>lua_createtable</code></h3>
<pre>
void lua_createtable (lua_State *L, int narr, int nrec);
</pre>
@@ -2168,7 +2168,7 @@ the table will have.
Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</code></a>.
<p><a name="lua_dump"></a>
-<hr /><h3><code>lua_dump</code></h3>
+<hr></hr><h3><code>lua_dump</code></h3>
<pre>
int lua_dump (lua_State *L, lua_Writer writer, void *data);
</pre>
@@ -2191,7 +2191,7 @@ call to the writer;
<p>This function does not pop the function from the stack.
<p><a name="lua_equal"></a>
-<hr /><h3><code>lua_equal</code></h3>
+<hr></hr><h3><code>lua_equal</code></h3>
<pre>
int lua_equal (lua_State *L, int index1, int index2);
</pre>
@@ -2205,7 +2205,7 @@ Otherwise returns 0.
Also returns 0 if any of the indices is non valid.
<p><a name="lua_error"></a>
-<hr /><h3><code>lua_error</code></h3>
+<hr></hr><h3><code>lua_error</code></h3>
<pre>
int lua_error (lua_State *L);
</pre>
@@ -2219,7 +2219,7 @@ and therefore never returns.
(see <a href="#pdf-luaL_error"><code>luaL_error</code></a>).
<p><a name="lua_gc"></a>
-<hr /><h3><code>lua_gc</code></h3>
+<hr></hr><h3><code>lua_gc</code></h3>
<pre>
int lua_gc (lua_State *L, int what, int data);
</pre>
@@ -2257,7 +2257,7 @@ The function returns the previous value of the step multiplier.
</ul>
<p><a name="lua_getallocf"></a>
-<hr /><h3><code>lua_getallocf</code></h3>
+<hr></hr><h3><code>lua_getallocf</code></h3>
<pre>
lua_Alloc lua_getallocf (lua_State *L, void **ud);
</pre>
@@ -2268,7 +2268,7 @@ If <code>ud</code> is not <code>NULL</code>, Lua stores in <code>*ud</code> the
opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.
<p><a name="lua_getfenv"></a>
-<hr /><h3><code>lua_getfenv</code></h3>
+<hr></hr><h3><code>lua_getfenv</code></h3>
<pre>
void lua_getfenv (lua_State *L, int index);
</pre>
@@ -2278,7 +2278,7 @@ opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.
the value at the given index.
<p><a name="lua_getfield"></a>
-<hr /><h3><code>lua_getfield</code></h3>
+<hr></hr><h3><code>lua_getfield</code></h3>
<pre>
void lua_getfield (lua_State *L, int index, const char *k);
</pre>
@@ -2289,8 +2289,21 @@ where <code>t</code> is the value at the given valid index <code>index</code>.
As in Lua, this function may trigger a metamethod
for the "index" event (see <a href="#metatable">2.8</a>).
+<p><a name="lua_getglobal"></a>
+<hr></hr><h3><code>lua_getglobal</code></h3>
+<pre>
+ void lua_getglobal (lua_State *L, const char *name);
+</pre>
+
+
+<p>Pushes onto the stack the value of the global <code>name</code>.
+It is defined as a macro:
+<pre>
+#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s)
+</pre>
+
<p><a name="lua_getmetatable"></a>
-<hr /><h3><code>lua_getmetatable</code></h3>
+<hr></hr><h3><code>lua_getmetatable</code></h3>
<pre>
int lua_getmetatable (lua_State *L, int index);
</pre>
@@ -2300,10 +2313,10 @@ for the "index" event (see <a href="#metatable">2.8</a>).
acceptable index.
If the index is not valid,
or if the value does not have a metatable,
-returns 0 and pushes nothing on the stack.
+the function returns 0 and pushes nothing on the stack.
<p><a name="lua_gettable"></a>
-<hr /><h3><code>lua_gettable</code></h3>
+<hr></hr><h3><code>lua_gettable</code></h3>
<pre>
void lua_gettable (lua_State *L, int index);
</pre>
@@ -2319,7 +2332,7 @@ As in Lua, this function may trigger a metamethod
for the "index" event (see <a href="#metatable">2.8</a>).
<p><a name="lua_gettop"></a>
-<hr /><h3><code>lua_gettop</code></h3>
+<hr></hr><h3><code>lua_gettop</code></h3>
<pre>
int lua_gettop (lua_State *L);
</pre>
@@ -2331,7 +2344,7 @@ that result is equal to the number of elements in the stack
(and so 0 means an empty stack).
<p><a name="lua_insert"></a>
-<hr /><h3><code>lua_insert</code></h3>
+<hr></hr><h3><code>lua_insert</code></h3>
<pre>
void lua_insert (lua_State *L, int index);
</pre>
@@ -2343,7 +2356,7 @@ Cannot be called with a pseudo-index,
because a pseudo-index is not an actual stack position.
<p><a name="lua_Integer"></a>
-<hr /><h3><code>lua_Integer</code></h3>
+<hr></hr><h3><code>lua_Integer</code></h3>
<pre>
typedef ptrdiff_t lua_Integer;
</pre>
@@ -2356,7 +2369,7 @@ which is usually the largest integral type the machine handles
"comfortably".
<p><a name="lua_isboolean"></a>
-<hr /><h3><code>lua_isboolean</code></h3>
+<hr></hr><h3><code>lua_isboolean</code></h3>
<pre>
int lua_isboolean (lua_State *L, int index);
</pre>
@@ -2366,7 +2379,7 @@ which is usually the largest integral type the machine handles
and 0 otherwise.
<p><a name="lua_iscfunction"></a>
-<hr /><h3><code>lua_iscfunction</code></h3>
+<hr></hr><h3><code>lua_iscfunction</code></h3>
<pre>
int lua_iscfunction (lua_State *L, int index);
</pre>
@@ -2376,7 +2389,7 @@ and 0 otherwise.
and 0 otherwise.
<p><a name="lua_isfunction"></a>
-<hr /><h3><code>lua_isfunction</code></h3>
+<hr></hr><h3><code>lua_isfunction</code></h3>
<pre>
int lua_isfunction (lua_State *L, int index);
</pre>
@@ -2386,7 +2399,7 @@ and 0 otherwise.
(either C or Lua), and 0 otherwise.
<p><a name="lua_islightuserdata"></a>
-<hr /><h3><code>lua_islightuserdata</code></h3>
+<hr></hr><h3><code>lua_islightuserdata</code></h3>
<pre>
int lua_islightuserdata (lua_State *L, int index);
</pre>
@@ -2396,7 +2409,7 @@ and 0 otherwise.
and 0 otherwise.
<p><a name="lua_isnil"></a>
-<hr /><h3><code>lua_isnil</code></h3>
+<hr></hr><h3><code>lua_isnil</code></h3>
<pre>
int lua_isnil (lua_State *L, int index);
</pre>
@@ -2406,7 +2419,7 @@ and 0 otherwise.
and 0 otherwise.
<p><a name="lua_isnumber"></a>
-<hr /><h3><code>lua_isnumber</code></h3>
+<hr></hr><h3><code>lua_isnumber</code></h3>
<pre>
int lua_isnumber (lua_State *L, int index);
</pre>
@@ -2417,7 +2430,7 @@ or a string convertible to a number,
and 0 otherwise.
<p><a name="lua_isstring"></a>
-<hr /><h3><code>lua_isstring</code></h3>
+<hr></hr><h3><code>lua_isstring</code></h3>
<pre>
int lua_isstring (lua_State *L, int index);
</pre>
@@ -2428,7 +2441,7 @@ or a number (which is always convertible to a string),
and 0 otherwise.
<p><a name="lua_istable"></a>
-<hr /><h3><code>lua_istable</code></h3>
+<hr></hr><h3><code>lua_istable</code></h3>
<pre>
int lua_istable (lua_State *L, int index);
</pre>
@@ -2438,7 +2451,7 @@ and 0 otherwise.
and 0 otherwise.
<p><a name="lua_isthread"></a>
-<hr /><h3><code>lua_isthread</code></h3>
+<hr></hr><h3><code>lua_isthread</code></h3>
<pre>
int lua_isthread (lua_State *L, int index);
</pre>
@@ -2448,7 +2461,7 @@ and 0 otherwise.
and 0 otherwise.
<p><a name="lua_isuserdata"></a>
-<hr /><h3><code>lua_isuserdata</code></h3>
+<hr></hr><h3><code>lua_isuserdata</code></h3>
<pre>
int lua_isuserdata (lua_State *L, int index);
</pre>
@@ -2458,7 +2471,7 @@ and 0 otherwise.
(either full or light), and 0 otherwise.
<p><a name="lua_lessthan"></a>
-<hr /><h3><code>lua_lessthan</code></h3>
+<hr></hr><h3><code>lua_lessthan</code></h3>
<pre>
int lua_lessthan (lua_State *L, int index1, int index2);
</pre>
@@ -2472,7 +2485,7 @@ Otherwise returns 0.
Also returns 0 if any of the indices is non valid.
<p><a name="lua_load"></a>
-<hr /><h3><code>lua_load</code></h3>
+<hr></hr><h3><code>lua_load</code></h3>
<pre>
int lua_load (lua_State *L, lua_Reader reader, void *data,
const char *chunkname);
@@ -2505,7 +2518,7 @@ The <code>data</code> argument is an opaque value passed to the reader function.
which is used for error messages and in debug information (see <a href="#debugI">3.8</a>).
<p><a name="lua_newstate"></a>
-<hr /><h3><code>lua_newstate</code></h3>
+<hr></hr><h3><code>lua_newstate</code></h3>
<pre>
lua_State *lua_newstate (lua_Alloc f, void *ud);
</pre>
@@ -2520,7 +2533,7 @@ The second argument, <code>ud</code>, is an opaque pointer that Lua
simply passes to the allocator in every call.
<p><a name="lua_newtable"></a>
-<hr /><h3><code>lua_newtable</code></h3>
+<hr></hr><h3><code>lua_newtable</code></h3>
<pre>
void lua_newtable (lua_State *L);
</pre>
@@ -2530,7 +2543,7 @@ simply passes to the allocator in every call.
Equivalent to <code>lua_createtable(L, 0, 0)</code>.
<p><a name="lua_newthread"></a>
-<hr /><h3><code>lua_newthread</code></h3>
+<hr></hr><h3><code>lua_newthread</code></h3>
<pre>
lua_State *lua_newthread (lua_State *L);
</pre>
@@ -2547,7 +2560,7 @@ Threads are subject to garbage collection,
like any Lua object.
<p><a name="lua_newuserdata"></a>
-<hr /><h3><code>lua_newuserdata</code></h3>
+<hr></hr><h3><code>lua_newuserdata</code></h3>
<pre>
void *lua_newuserdata (lua_State *L, size_t size);
</pre>
@@ -2570,7 +2583,7 @@ When that userdata is collected again then
Lua frees its corresponding memory.
<p><a name="lua_next"></a>
-<hr /><h3><code>lua_next</code></h3>
+<hr></hr><h3><code>lua_next</code></h3>
<pre>
int lua_next (lua_State *L, int index);
</pre>
@@ -2602,7 +2615,7 @@ the value at the given index;
this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
<p><a name="lua_Number"></a>
-<hr /><h3><code>lua_Number</code></h3>
+<hr></hr><h3><code>lua_Number</code></h3>
<pre>
typedef double lua_Number;
</pre>
@@ -2612,10 +2625,10 @@ this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
By default, it is double, but that can be changed in <code>luaconf.h</code>.
<p>Through the configuration file you can change
-Lua to operate with other type for numbers (e.g., float or long).
+Lua to operate with another type for numbers (e.g., float or long).
<p><a name="lua_objlen"></a>
-<hr /><h3><code>lua_objlen</code></h3>
+<hr></hr><h3><code>lua_objlen</code></h3>
<pre>
size_t lua_objlen (lua_State *L, int index);
</pre>
@@ -2629,7 +2642,7 @@ for the userdata;
for other values, it is 0.
<p><a name="lua_pcall"></a>
-<hr /><h3><code>lua_pcall</code></h3>
+<hr></hr><h3><code>lua_pcall</code></h3>
<pre>
lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
</pre>
@@ -2676,7 +2689,7 @@ error while running the error handler function.
</ul>
<p><a name="lua_pop"></a>
-<hr /><h3><code>lua_pop</code></h3>
+<hr></hr><h3><code>lua_pop</code></h3>
<pre>
void lua_pop (lua_State *L, int n);
</pre>
@@ -2685,7 +2698,7 @@ error while running the error handler function.
<p>Pops <code>n</code> elements from the stack.
<p><a name="lua_pushboolean"></a>
-<hr /><h3><code>lua_pushboolean</code></h3>
+<hr></hr><h3><code>lua_pushboolean</code></h3>
<pre>
void lua_pushboolean (lua_State *L, int b);
</pre>
@@ -2694,7 +2707,7 @@ error while running the error handler function.
<p>Pushes a boolean value with value <code>b</code> onto the stack.
<p><a name="lua_pushcclosure"></a>
-<hr /><h3><code>lua_pushcclosure</code></h3>
+<hr></hr><h3><code>lua_pushcclosure</code></h3>
<pre>
void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
</pre>
@@ -2716,17 +2729,26 @@ associated with the function.
<a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.
<p><a name="lua_pushcfunction"></a>
-<hr /><h3><code>lua_pushcfunction</code></h3>
+<hr></hr><h3><code>lua_pushcfunction</code></h3>
<pre>
void lua_pushcfunction (lua_State *L, lua_CFunction f);
</pre>
<p>Pushes a C function onto the stack.
-This function is equivalent to <code>lua_pushcclosure(L, f, 0);</code>.
+This function receives a pointer to a C function
+and pushes on the stack a Lua value of type <code>function</code> that,
+when called, invokes the corresponding C function.
+
+<p>Any function to be registered in Lua must
+follow the correct protocol to receive its parameters
+and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
+
+<p>The call <code>lua_pushcfunction(L, f)</code> is equivalent to
+<code>lua_pushcclosure(L, f, 0)</code>.
<p><a name="lua_pushfstring"></a>
-<hr /><h3><code>lua_pushfstring</code></h3>
+<hr></hr><h3><code>lua_pushfstring</code></h3>
<pre>
const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
</pre>
@@ -2752,7 +2774,7 @@ The conversion specifiers can only be
</ul>
<p><a name="lua_pushinteger"></a>
-<hr /><h3><code>lua_pushinteger</code></h3>
+<hr></hr><h3><code>lua_pushinteger</code></h3>
<pre>
void lua_pushinteger (lua_State *L, lua_Integer n);
</pre>
@@ -2761,7 +2783,7 @@ The conversion specifiers can only be
<p>Pushes a number with value <code>n</code> onto the stack.
<p><a name="lua_pushlightuserdata"></a>
-<hr /><h3><code>lua_pushlightuserdata</code></h3>
+<hr></hr><h3><code>lua_pushlightuserdata</code></h3>
<pre>
void lua_pushlightuserdata (lua_State *L, void *p);
</pre>
@@ -2778,7 +2800,7 @@ A light userdata is equal to "any"
light userdata with the same C address.
<p><a name="lua_pushlstring"></a>
-<hr /><h3><code>lua_pushlstring</code></h3>
+<hr></hr><h3><code>lua_pushlstring</code></h3>
<pre>
void lua_pushlstring (lua_State *L, const char *s, size_t len);
</pre>
@@ -2792,7 +2814,7 @@ the function returns.
The string can contain embedded zeros.
<p><a name="lua_pushnil"></a>
-<hr /><h3><code>lua_pushnil</code></h3>
+<hr></hr><h3><code>lua_pushnil</code></h3>
<pre>
void lua_pushnil (lua_State *L);
</pre>
@@ -2801,7 +2823,7 @@ The string can contain embedded zeros.
<p>Pushes a nil value onto the stack.
<p><a name="lua_pushnumber"></a>
-<hr /><h3><code>lua_pushnumber</code></h3>
+<hr></hr><h3><code>lua_pushnumber</code></h3>
<pre>
void lua_pushnumber (lua_State *L, lua_Number n);
</pre>
@@ -2810,7 +2832,7 @@ The string can contain embedded zeros.
<p>Pushes a number with value <code>n</code> onto the stack.
<p><a name="lua_pushstring"></a>
-<hr /><h3><code>lua_pushstring</code></h3>
+<hr></hr><h3><code>lua_pushstring</code></h3>
<pre>
void lua_pushstring (lua_State *L, const char *s);
</pre>
@@ -2825,7 +2847,7 @@ The string cannot contain embedded zeros;
it is assumed to end at the first zero.
<p><a name="lua_pushthread"></a>
-<hr /><h3><code>lua_pushthread</code></h3>
+<hr></hr><h3><code>lua_pushthread</code></h3>
<pre>
void lua_pushthread (lua_State *L);
</pre>
@@ -2834,7 +2856,7 @@ it is assumed to end at the first zero.
<p>Pushes the thread represented by <code>L</code> onto the stack.
<p><a name="lua_pushvalue"></a>
-<hr /><h3><code>lua_pushvalue</code></h3>
+<hr></hr><h3><code>lua_pushvalue</code></h3>
<pre>
void lua_pushvalue (lua_State *L, int index);
</pre>
@@ -2844,7 +2866,7 @@ it is assumed to end at the first zero.
onto the stack.
<p><a name="lua_pushvfstring"></a>
-<hr /><h3><code>lua_pushvfstring</code></h3>
+<hr></hr><h3><code>lua_pushvfstring</code></h3>
<pre>
const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp);
</pre>
@@ -2854,7 +2876,7 @@ onto the stack.
instead of a variable number of arguments.
<p><a name="lua_rawequal"></a>
-<hr /><h3><code>lua_rawequal</code></h3>
+<hr></hr><h3><code>lua_rawequal</code></h3>
<pre>
int lua_rawequal (lua_State *L, int index1, int index2);
</pre>
@@ -2867,7 +2889,7 @@ Otherwise returns 0.
Also returns 0 if any of the indices are non valid.
<p><a name="lua_rawget"></a>
-<hr /><h3><code>lua_rawget</code></h3>
+<hr></hr><h3><code>lua_rawget</code></h3>
<pre>
void lua_rawget (lua_State *L, int index);
</pre>
@@ -2877,7 +2899,7 @@ Also returns 0 if any of the indices are non valid.
(i.e., without metamethods).
<p><a name="lua_rawgeti"></a>
-<hr /><h3><code>lua_rawgeti</code></h3>
+<hr></hr><h3><code>lua_rawgeti</code></h3>
<pre>
void lua_rawgeti (lua_State *L, int index, int n);
</pre>
@@ -2889,7 +2911,7 @@ The access is raw;
that is, it does not invoke metamethods.
<p><a name="lua_rawset"></a>
-<hr /><h3><code>lua_rawset</code></h3>
+<hr></hr><h3><code>lua_rawset</code></h3>
<pre>
void lua_rawset (lua_State *L, int index);
</pre>
@@ -2899,7 +2921,7 @@ that is, it does not invoke metamethods.
(i.e., without metamethods).
<p><a name="lua_rawseti"></a>
-<hr /><h3><code>lua_rawseti</code></h3>
+<hr></hr><h3><code>lua_rawseti</code></h3>
<pre>
void lua_rawseti (lua_State *L, int index, int n);
</pre>
@@ -2914,7 +2936,7 @@ The assignment is raw;
that is, it does not invoke metamethods.
<p><a name="lua_Reader"></a>
-<hr /><h3><code>lua_Reader</code></h3>
+<hr></hr><h3><code>lua_Reader</code></h3>
<pre>
typedef const char * (*lua_Reader)
(lua_State *L, void *data, size_t *size);
@@ -2933,8 +2955,21 @@ The block must exist until the reader function is called again.
To signal the end of the chunk, the reader must return <code>NULL</code>.
The reader function may return pieces of any size greater than zero.
+<p><a name="lua_register"></a>
+<hr></hr><h3><code>lua_register</code></h3>
+<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))
+</pre>
+
<p><a name="lua_remove"></a>
-<hr /><h3><code>lua_remove</code></h3>
+<hr></hr><h3><code>lua_remove</code></h3>
<pre>
void lua_remove (lua_State *L, int index);
</pre>
@@ -2946,7 +2981,7 @@ Cannot be called with a pseudo-index,
because a pseudo-index is not an actual stack position.
<p><a name="lua_replace"></a>
-<hr /><h3><code>lua_replace</code></h3>
+<hr></hr><h3><code>lua_replace</code></h3>
<pre>
void lua_replace (lua_State *L, int index);
</pre>
@@ -2957,7 +2992,7 @@ without shifting any element
(therefore replacing the value at the given position).
<p><a name="lua_resume"></a>
-<hr /><h3><code>lua_resume</code></h3>
+<hr></hr><h3><code>lua_resume</code></h3>
<pre>
int lua_resume (lua_State *L, int narg);
</pre>
@@ -2987,7 +3022,7 @@ be passed as results from <code>yield</code>,
and then call <a href="#lua_resume"><code>lua_resume</code></a>.
<p><a name="lua_setallocf"></a>
-<hr /><h3><code>lua_setallocf</code></h3>
+<hr></hr><h3><code>lua_setallocf</code></h3>
<pre>
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
</pre>
@@ -2997,7 +3032,7 @@ and then call <a href="#lua_resume"><code>lua_resume</code></a>.
with user data <code>ud</code>.
<p><a name="lua_setfenv"></a>
-<hr /><h3><code>lua_setfenv</code></h3>
+<hr></hr><h3><code>lua_setfenv</code></h3>
<pre>
int lua_setfenv (lua_State *L, int index);
</pre>
@@ -3011,7 +3046,7 @@ neither a function nor a thread nor a userdata,
Otherwise it returns 1.
<p><a name="lua_setfield"></a>
-<hr /><h3><code>lua_setfield</code></h3>
+<hr></hr><h3><code>lua_setfield</code></h3>
<pre>
void lua_setfield (lua_State *L, int index, const char *k);
</pre>
@@ -3025,8 +3060,22 @@ and <code>v</code> is the value at the top of the stack,
As in Lua, this function may trigger a metamethod
for the "newindex" event (see <a href="#metatable">2.8</a>).
+<p><a name="lua_setglobal"></a>
+<hr></hr><h3><code>lua_setglobal</code></h3>
+<pre>
+ void lua_setglobal (lua_State *L, const char *name);
+</pre>
+
+
+<p>Pops a value from the stack and
+sets it as the new value of global <code>name</code>.
+It is defined as a macro:
+<pre>
+#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s)
+</pre>
+
<p><a name="lua_setmetatable"></a>
-<hr /><h3><code>lua_setmetatable</code></h3>
+<hr></hr><h3><code>lua_setmetatable</code></h3>
<pre>
int lua_setmetatable (lua_State *L, int index);
</pre>
@@ -3037,7 +3086,7 @@ sets it as the new metatable for the value at the given
acceptable index.
<p><a name="lua_settable"></a>
-<hr /><h3><code>lua_settable</code></h3>
+<hr></hr><h3><code>lua_settable</code></h3>
<pre>
void lua_settable (lua_State *L, int index);
</pre>
@@ -3053,7 +3102,7 @@ As in Lua, this function may trigger a metamethod
for the "newindex" event (see <a href="#metatable">2.8</a>).
<p><a name="lua_settop"></a>
-<hr /><h3><code>lua_settop</code></h3>
+<hr></hr><h3><code>lua_settop</code></h3>
<pre>
void lua_settop (lua_State *L, int index);
</pre>
@@ -3066,7 +3115,7 @@ then the new elements are filled with <b>nil</b>.
If <code>index</code> is 0, then all stack elements are removed.
<p><a name="lua_State"></a>
-<hr /><h3><code>lua_State</code></h3>
+<hr></hr><h3><code>lua_State</code></h3>
<pre>
typedef struct lua_State lua_State;
</pre>
@@ -3082,7 +3131,7 @@ every function in the library, except to <a href="#lua_newstate"><code>lua_newst
which creates a Lua state from scratch.
<p><a name="lua_status"></a>
-<hr /><h3><code>lua_status</code></h3>
+<hr></hr><h3><code>lua_status</code></h3>
<pre>
int lua_status (lua_State *L);
</pre>
@@ -3090,19 +3139,19 @@ which creates a Lua state from scratch.
<p>Returns the status of the thread <code>L</code>.
-<p>The status can by 0 for a normal thread,
+<p>The status can be 0 for a normal thread,
an error code if the thread finished its execution with an error,
or <code>LUA_YIELD</code> if the thread is suspended.
<p><a name="lua_toboolean"></a>
-<hr /><h3><code>lua_toboolean</code></h3>
+<hr></hr><h3><code>lua_toboolean</code></h3>
<pre>
int lua_toboolean (lua_State *L, int index);
</pre>
<p>Converts the Lua value at the given acceptable index to a C boolean
-value ((0 or 1).
+value (0 or 1).
Like all tests in Lua,
<a href="#lua_toboolean"><code>lua_toboolean</code></a> returns 1 for any Lua value
different from <b>false</b> and <b>nil</b>;
@@ -3112,7 +3161,7 @@ It also returns 0 when called with a non-valid index.
use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's type.)
<p><a name="lua_tocfunction"></a>
-<hr /><h3><code>lua_tocfunction</code></h3>
+<hr></hr><h3><code>lua_tocfunction</code></h3>
<pre>
lua_CFunction lua_tocfunction (lua_State *L, int index);
</pre>
@@ -3123,7 +3172,7 @@ That value must be a C function;
otherwise, returns <code>NULL</code>.
<p><a name="lua_tointeger"></a>
-<hr /><h3><code>lua_tointeger</code></h3>
+<hr></hr><h3><code>lua_tointeger</code></h3>
<pre>
lua_Integer lua_tointeger (lua_State *L, int idx);
</pre>
@@ -3131,7 +3180,7 @@ otherwise, returns <code>NULL</code>.
<p>Converts the Lua value at the given acceptable index
to the signed integral type <a href="#lua_Integer"><code>lua_Integer</code></a>.
-The Lua value must be a number or a string convertible to number
+The Lua value must be a number or a string convertible to a number
(see <a href="#coercion">2.2.1</a>);
otherwise, <a href="#lua_tointeger"><code>lua_tointeger</code></a> returns 0.
@@ -3139,7 +3188,7 @@ otherwise, <a href="#lua_tointeger"><code>lua_tointeger</code></a> returns 0.
it is truncated in some non-specified way.
<p><a name="lua_tolstring"></a>
-<hr /><h3><code>lua_tolstring</code></h3>
+<hr></hr><h3><code>lua_tolstring</code></h3>
<pre>
const char *lua_tolstring (lua_State *L, int index, size_t *len);
</pre>
@@ -3167,7 +3216,7 @@ there is no guarantee that the pointer returned by <a href="#lua_tolstring"><cod
will be valid after the corresponding value is removed from the stack.
<p><a name="lua_tonumber"></a>
-<hr /><h3><code>lua_tonumber</code></h3>
+<hr></hr><h3><code>lua_tonumber</code></h3>
<pre>
lua_Number lua_tonumber (lua_State *L, int index);
</pre>
@@ -3175,12 +3224,12 @@ will be valid after the corresponding value is removed from the stack.
<p>Converts the Lua value at the given acceptable index
to a number (see <a href="#lua_Number"><code>lua_Number</code></a>).
-The Lua value must be a number or a string convertible to number
+The Lua value must be a number or a string convertible to a number
(see <a href="#coercion">2.2.1</a>);
otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns 0.
<p><a name="lua_topointer"></a>
-<hr /><h3><code>lua_topointer</code></h3>
+<hr></hr><h3><code>lua_topointer</code></h3>
<pre>
const void *lua_topointer (lua_State *L, int index);
</pre>
@@ -3196,7 +3245,7 @@ There is no direct way to convert the pointer back to its original value.
<p>Typically this function is used only for debug information.
<p><a name="lua_tostring"></a>
-<hr /><h3><code>lua_tostring</code></h3>
+<hr></hr><h3><code>lua_tostring</code></h3>
<pre>
const char *lua_tostring (lua_State *L, int index);
</pre>
@@ -3205,7 +3254,7 @@ There is no direct way to convert the pointer back to its original value.
<p>Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to <code>NULL</code>.
<p><a name="lua_tothread"></a>
-<hr /><h3><code>lua_tothread</code></h3>
+<hr></hr><h3><code>lua_tothread</code></h3>
<pre>
lua_State *lua_tothread (lua_State *L, int index);
</pre>
@@ -3217,7 +3266,7 @@ This value must be a thread;
otherwise, the function returns <code>NULL</code>.
<p><a name="lua_touserdata"></a>
-<hr /><h3><code>lua_touserdata</code></h3>
+<hr></hr><h3><code>lua_touserdata</code></h3>
<pre>
void *lua_touserdata (lua_State *L, int index);
</pre>
@@ -3230,13 +3279,13 @@ returns its pointer.
Otherwise, returns <code>NULL</code>.
<p><a name="lua_type"></a>
-<hr /><h3><code>lua_type</code></h3>
+<hr></hr><h3><code>lua_type</code></h3>
<pre>
int lua_type (lua_State *L, int index);
</pre>
-<p>Returns the type of a value in the given acceptable index,
+<p>Returns the type of the value in the given acceptable index,
or <code>LUA_TNONE</code> for a non-valid index
(that is, an index to an "empty" stack position).
The types returned by <a href="#lua_type"><code>lua_type</code></a> are coded by the following constants
@@ -3253,7 +3302,7 @@ and
<code>LUA_TLIGHTUSERDATA</code>.
<p><a name="lua_typename"></a>
-<hr /><h3><code>lua_typename</code></h3>
+<hr></hr><h3><code>lua_typename</code></h3>
<pre>
const char *lua_typename (lua_State *L, int tp);
</pre>
@@ -3263,7 +3312,7 @@ and
which must be one the values returned by <a href="#lua_type"><code>lua_type</code></a>.
<p><a name="lua_Writer"></a>
-<hr /><h3><code>lua_Writer</code></h3>
+<hr></hr><h3><code>lua_Writer</code></h3>
<pre>
typedef int (*lua_Writer)
(lua_State *L, const void* p, size_t sz, void* ud);
@@ -3284,7 +3333,7 @@ any other value means an error and stops <a href="#lua_dump"><code>lua_dump</cod
calling the writer again.
<p><a name="lua_xmove"></a>
-<hr /><h3><code>lua_xmove</code></h3>
+<hr></hr><h3><code>lua_xmove</code></h3>
<pre>
void lua_xmove (lua_State *from, lua_State *to, int n);
</pre>
@@ -3293,10 +3342,10 @@ calling the writer again.
<p>Exchange values between different threads of the <em>same</em> global state.
<p>This function pops <code>n</code> values from the stack <code>from</code>,
-and pushes them into the stack <code>to</code>.
+and pushes them onto the stack <code>to</code>.
<p><a name="lua_yield"></a>
-<hr /><h3><code>lua_yield</code></h3>
+<hr></hr><h3><code>lua_yield</code></h3>
<pre>
int lua_yield (lua_State *L, int nresults);
</pre>
@@ -3326,7 +3375,7 @@ kinds of debuggers, profilers, and other tools
that need "inside information" from the interpreter.
<p><a name="lua_Debug"></a>
-<hr /><h3><code>lua_Debug</code></h3>
+<hr></hr><h3><code>lua_Debug</code></h3>
<pre>
typedef struct lua_Debug {
int event;
@@ -3408,7 +3457,7 @@ the number of upvalues of the function.
<p></ul>
<p><a name="lua_gethook"></a>
-<hr /><h3><code>lua_gethook</code></h3>
+<hr></hr><h3><code>lua_gethook</code></h3>
<pre>
lua_Hook lua_gethook (lua_State *L);
</pre>
@@ -3417,7 +3466,7 @@ the number of upvalues of the function.
<p>Returns the current hook function.
<p><a name="lua_gethookcount"></a>
-<hr /><h3><code>lua_gethookcount</code></h3>
+<hr></hr><h3><code>lua_gethookcount</code></h3>
<pre>
int lua_gethookcount (lua_State *L);
</pre>
@@ -3426,7 +3475,7 @@ the number of upvalues of the function.
<p>Returns the current hook count.
<p><a name="lua_gethookmask"></a>
-<hr /><h3><code>lua_gethookmask</code></h3>
+<hr></hr><h3><code>lua_gethookmask</code></h3>
<pre>
int lua_gethookmask (lua_State *L);
</pre>
@@ -3435,7 +3484,7 @@ the number of upvalues of the function.
<p>Returns the current hook mask.
<p><a name="lua_getinfo"></a>
-<hr /><h3><code>lua_getinfo</code></h3>
+<hr></hr><h3><code>lua_getinfo</code></h3>
<pre>
int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
</pre>
@@ -3469,7 +3518,7 @@ you can write the following code:
</pre>
<p><a name="lua_getlocal"></a>
-<hr /><h3><code>lua_getlocal</code></h3>
+<hr></hr><h3><code>lua_getlocal</code></h3>
<pre>
const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
</pre>
@@ -3494,7 +3543,7 @@ when the index is greater than
the number of active local variables.
<p><a name="lua_getstack"></a>
-<hr /><h3><code>lua_getstack</code></h3>
+<hr></hr><h3><code>lua_getstack</code></h3>
<pre>
int lua_getstack (lua_State *L, int level, lua_Debug *ar);
</pre>
@@ -3512,7 +3561,7 @@ when called with a level greater than the stack depth,
it returns 0.
<p><a name="lua_getupvalue"></a>
-<hr /><h3><code>lua_getupvalue</code></h3>
+<hr></hr><h3><code>lua_getupvalue</code></h3>
<pre>
const char *lua_getupvalue (lua_State *L, int funcindex, int n);
</pre>
@@ -3536,7 +3585,7 @@ For C functions, this function uses the empty string <code>""</code>
as a name for all upvalues.
<p><a name="lua_Hook"></a>
-<hr /><h3><code>lua_Hook</code></h3>
+<hr></hr><h3><code>lua_Hook</code></h3>
<pre>
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
</pre>
@@ -3564,7 +3613,7 @@ Therefore, if a hook calls back Lua to execute a function or a chunk,
that execution occurs without any calls to hooks.
<p><a name="lua_sethook"></a>
-<hr /><h3><code>lua_sethook</code></h3>
+<hr></hr><h3><code>lua_sethook</code></h3>
<pre>
int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
</pre>
@@ -3601,7 +3650,7 @@ or when it jumps back in the code (even to the same line).
<p>A hook is disabled by setting <code>mask</code> to zero.
<p><a name="lua_setlocal"></a>
-<hr /><h3><code>lua_setlocal</code></h3>
+<hr></hr><h3><code>lua_setlocal</code></h3>
<pre>
const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
</pre>
@@ -3619,7 +3668,7 @@ when the index is greater than
the number of active local variables.
<p><a name="lua_setupvalue"></a>
-<hr /><h3><code>lua_setupvalue</code></h3>
+<hr></hr><h3><code>lua_setupvalue</code></h3>
<pre>
const char *lua_setupvalue (lua_State *L, int funcindex, int n);
</pre>
@@ -3668,7 +3717,7 @@ you should not use these functions for other stack values.
in alphabetical order.
<p><a name="luaL_addchar"></a>
-<hr /><h3><code>luaL_addchar</code></h3>
+<hr></hr><h3><code>luaL_addchar</code></h3>
<pre>
void luaL_addchar (luaL_Buffer B, char c);
</pre>
@@ -3678,7 +3727,7 @@ in alphabetical order.
(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
<p><a name="luaL_addlstring"></a>
-<hr /><h3><code>luaL_addlstring</code></h3>
+<hr></hr><h3><code>luaL_addlstring</code></h3>
<pre>
void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
</pre>
@@ -3690,7 +3739,7 @@ the buffer <code>B</code>
The string may contain embedded zeros.
<p><a name="luaL_addsize"></a>
-<hr /><h3><code>luaL_addsize</code></h3>
+<hr></hr><h3><code>luaL_addsize</code></h3>
<pre>
void luaL_addsize (luaL_Buffer B, size_t n);
</pre>
@@ -3701,7 +3750,7 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>) to
(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
<p><a name="luaL_addstring"></a>
-<hr /><h3><code>luaL_addstring</code></h3>
+<hr></hr><h3><code>luaL_addstring</code></h3>
<pre>
void luaL_addstring (luaL_Buffer *B, const char *s);
</pre>
@@ -3713,7 +3762,7 @@ to the buffer <code>B</code>
The string may not contain embedded zeros.
<p><a name="luaL_addvalue"></a>
-<hr /><h3><code>luaL_addvalue</code></h3>
+<hr></hr><h3><code>luaL_addvalue</code></h3>
<pre>
void luaL_addvalue (luaL_Buffer *B);
</pre>
@@ -3729,7 +3778,7 @@ be called with an extra element on the stack,
which is the value to be added to the buffer.
<p><a name="luaL_argcheck"></a>
-<hr /><h3><code>luaL_argcheck</code></h3>
+<hr></hr><h3><code>luaL_argcheck</code></h3>
<pre>
void luaL_argcheck (lua_State *L, int cond, int numarg,
const char *extramsg);
@@ -3742,7 +3791,7 @@ If not, raises an error with message
where <code>func</code> is retrieved from the call stack.
<p><a name="luaL_argerror"></a>
-<hr /><h3><code>luaL_argerror</code></h3>
+<hr></hr><h3><code>luaL_argerror</code></h3>
<pre>
int luaL_argerror (lua_State *L, int numarg, const char *extramsg);
</pre>
@@ -3757,7 +3806,7 @@ but it is an idiom to use it as <code>return luaL_argerror ...</code>
in C functions.
<p><a name="luaL_Buffer"></a>
-<hr /><h3><code>luaL_Buffer</code></h3>
+<hr></hr><h3><code>luaL_Buffer</code></h3>
<pre>
typedef struct luaL_Buffer luaL_Buffer;
</pre>
@@ -3772,7 +3821,7 @@ Its pattern of use is as follows:
<li> Then you initialize it with a call <code>luaL_buffinit(L, &#038;b)</code>.
<li> Then you add string pieces to the buffer calling any of
the <code>luaL_add*</code> functions.
-<li> You finish calling <code>luaL_pushresult(&#038;b)</code>.
+<li> You finish by calling <code>luaL_pushresult(&#038;b)</code>.
That call leaves the final string on the top of the stack.
</ul>
@@ -3792,7 +3841,7 @@ level when the buffer was initialized,
plus the final string on its top.
<p><a name="luaL_buffinit"></a>
-<hr /><h3><code>luaL_buffinit</code></h3>
+<hr></hr><h3><code>luaL_buffinit</code></h3>
<pre>
void luaL_buffinit (lua_State *L, luaL_Buffer *B);
</pre>
@@ -3804,7 +3853,7 @@ the buffer must be declared as a variable
(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
<p><a name="luaL_callmeta"></a>
-<hr /><h3><code>luaL_callmeta</code></h3>
+<hr></hr><h3><code>luaL_callmeta</code></h3>
<pre>
int luaL_callmeta (lua_State *L, int obj, const char *e);
</pre>
@@ -3821,7 +3870,7 @@ If there is no metatable or no metamethod,
this function returns 0 (without pushing any value on the stack).
<p><a name="luaL_checkany"></a>
-<hr /><h3><code>luaL_checkany</code></h3>
+<hr></hr><h3><code>luaL_checkany</code></h3>
<pre>
void luaL_checkany (lua_State *L, int narg);
</pre>
@@ -3831,7 +3880,7 @@ this function returns 0 (without pushing any value on the stack).
of any type (including <b>nil</b>) at position <code>narg</code>.
<p><a name="luaL_checkint"></a>
-<hr /><h3><code>luaL_checkint</code></h3>
+<hr></hr><h3><code>luaL_checkint</code></h3>
<pre>
int luaL_checkint (lua_State *L, int narg);
</pre>
@@ -3841,7 +3890,7 @@ of any type (including <b>nil</b>) at position <code>narg</code>.
and returns that number cast to an <code>int</code>.
<p><a name="luaL_checkinteger"></a>
-<hr /><h3><code>luaL_checkinteger</code></h3>
+<hr></hr><h3><code>luaL_checkinteger</code></h3>
<pre>
lua_Integer luaL_checkinteger (lua_State *L, int narg);
</pre>
@@ -3851,7 +3900,7 @@ and returns that number cast to an <code>int</code>.
and returns that number cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.
<p><a name="luaL_checklong"></a>
-<hr /><h3><code>luaL_checklong</code></h3>
+<hr></hr><h3><code>luaL_checklong</code></h3>
<pre>
long luaL_checklong (lua_State *L, int narg);
</pre>
@@ -3861,9 +3910,9 @@ and returns that number cast to a <a href="#lua_Integer"><code>lua_Integer</code
and returns that number cast to a <code>long</code>.
<p><a name="luaL_checklstring"></a>
-<hr /><h3><code>luaL_checklstring</code></h3>
+<hr></hr><h3><code>luaL_checklstring</code></h3>
<pre>
- const char *luaL_checklstring (lua_State *L, int numArg, size_t *l);
+ const char *luaL_checklstring (lua_State *L, int narg, size_t *l);
</pre>
@@ -3873,9 +3922,9 @@ if <code>l</code> is not <code>NULL</code> fills <code>*l</code>
with the string's length.
<p><a name="luaL_checknumber"></a>
-<hr /><h3><code>luaL_checknumber</code></h3>
+<hr></hr><h3><code>luaL_checknumber</code></h3>
<pre>
- lua_Number luaL_checknumber (lua_State *L, int numArg);
+ lua_Number luaL_checknumber (lua_State *L, int narg);
</pre>
@@ -3883,7 +3932,7 @@ with the string's length.
and returns that number.
<p><a name="luaL_checkoption"></a>
-<hr /><h3><code>luaL_checkoption</code></h3>
+<hr></hr><h3><code>luaL_checkoption</code></h3>
<pre>
int luaL_checkoption (lua_State *L, int narg, const char *def,
const char *const lst[]);
@@ -3902,11 +3951,11 @@ Raises an error if the argument is not a string or
if the string cannot be found.
<p>This is a useful function for mapping strings to C enums.
-The usual interfaces in Lua libraries is to use strings instead of numbers
+The usual convention in Lua libraries is to use strings instead of numbers
to select options.
<p><a name="luaL_checkstack"></a>
-<hr /><h3><code>luaL_checkstack</code></h3>
+<hr></hr><h3><code>luaL_checkstack</code></h3>
<pre>
void luaL_checkstack (lua_State *L, int sz, const char *msg);
</pre>
@@ -3917,7 +3966,7 @@ raising an error if the stack cannot grow to that size.
<code>msg</code> is an additional text to go into the error message.
<p><a name="luaL_checkstring"></a>
-<hr /><h3><code>luaL_checkstring</code></h3>
+<hr></hr><h3><code>luaL_checkstring</code></h3>
<pre>
const char *luaL_checkstring (lua_State *L, int narg);
</pre>
@@ -3927,7 +3976,7 @@ raising an error if the stack cannot grow to that size.
and returns that string.
<p><a name="luaL_checktype"></a>
-<hr /><h3><code>luaL_checktype</code></h3>
+<hr></hr><h3><code>luaL_checktype</code></h3>
<pre>
void luaL_checktype (lua_State *L, int narg, int t);
</pre>
@@ -3936,9 +3985,9 @@ and returns that string.
<p>Checks whether the function argument <code>narg</code> has type <code>t</code>.
<p><a name="luaL_checkudata"></a>
-<hr /><h3><code>luaL_checkudata</code></h3>
+<hr></hr><h3><code>luaL_checkudata</code></h3>
<pre>
- void *luaL_checkudata (lua_State *L, int ud, const char *tname);
+ void *luaL_checkudata (lua_State *L, int narg, const char *tname);
</pre>
@@ -3946,7 +3995,7 @@ and returns that string.
of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
<p><a name="luaL_error"></a>
-<hr /><h3><code>luaL_error</code></h3>
+<hr></hr><h3><code>luaL_error</code></h3>
<pre>
int luaL_error (lua_State *L, const char *fmt, ...);
</pre>
@@ -3954,7 +4003,7 @@ of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newm
<p>Raises an error.
The error message format is given by <code>fmt</code>
-plus any extra argument,
+plus any extra arguments,
following the same rules of <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>.
It also adds at the beginning of the message the file name and
the line number where the error occurred,
@@ -3965,7 +4014,7 @@ but it is an idiom to use it as <code>return luaL_error ...</code>
in C functions.
<p><a name="luaL_getmetafield"></a>
-<hr /><h3><code>luaL_getmetafield</code></h3>
+<hr></hr><h3><code>luaL_getmetafield</code></h3>
<pre>
int luaL_getmetafield (lua_State *L, int obj, const char *e);
</pre>
@@ -3978,7 +4027,7 @@ or if the metatable does not have that field,
returns 0 and pushes nothing.
<p><a name="luaL_getmetatable"></a>
-<hr /><h3><code>luaL_getmetatable</code></h3>
+<hr></hr><h3><code>luaL_getmetatable</code></h3>
<pre>
void luaL_getmetatable (lua_State *L, const char *tname);
</pre>
@@ -3988,7 +4037,7 @@ returns 0 and pushes nothing.
in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
<p><a name="luaL_gsub"></a>
-<hr /><h3><code>luaL_gsub</code></h3>
+<hr></hr><h3><code>luaL_gsub</code></h3>
<pre>
const char *luaL_gsub (lua_State *L, const char *s,
const char *p, const char *r);
@@ -4001,7 +4050,7 @@ with the string <code>r</code>.
Pushes the resulting string on the stack and returns it.
<p><a name="luaL_loadbuffer"></a>
-<hr /><h3><code>luaL_loadbuffer</code></h3>
+<hr></hr><h3><code>luaL_loadbuffer</code></h3>
<pre>
int luaL_loadbuffer (lua_State *L, const char *buff,
size_t sz, const char *name);
@@ -4017,7 +4066,7 @@ buffer pointed by <code>buff</code> with size <code>sz</code>.
used for debug information and error messages.
<p><a name="luaL_loadfile"></a>
-<hr /><h3><code>luaL_loadfile</code></h3>
+<hr></hr><h3><code>luaL_loadfile</code></h3>
<pre>
int luaL_loadfile (lua_State *L, const char *filename);
</pre>
@@ -4035,7 +4084,7 @@ but it has an extra error code <code>LUA_ERRFILE</code>
if it cannot open/read the file.
<p><a name="luaL_loadstring"></a>
-<hr /><h3><code>luaL_loadstring</code></h3>
+<hr></hr><h3><code>luaL_loadstring</code></h3>
<pre>
int luaL_loadstring (lua_State *L, const char *s);
</pre>
@@ -4048,24 +4097,24 @@ the zero-terminated string <code>s</code>.
<p>This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
<p><a name="luaL_newmetatable"></a>
-<hr /><h3><code>luaL_newmetatable</code></h3>
+<hr></hr><h3><code>luaL_newmetatable</code></h3>
<pre>
int luaL_newmetatable (lua_State *L, const char *tname);
</pre>
-<p>If the registry already has the key <code>"tname"</code>,
+<p>If the registry already has the key <code>tname</code>,
returns 0.
Otherwise,
creates a new table to be used as a metatable for userdata,
-adds it to the registry with key <code>"tname"</code>,
+adds it to the registry with key <code>tname</code>,
and returns 1.
<p>In both cases pushes on the stack the final value associated
-with <code>"tname"</code> in the registry.
+with <code>tname</code> in the registry.
<p><a name="luaL_newstate"></a>
-<hr /><h3><code>luaL_newstate</code></h3>
+<hr></hr><h3><code>luaL_newstate</code></h3>
<pre>
lua_State *luaL_newstate (void);
</pre>
@@ -4080,8 +4129,17 @@ errors.
<p>Returns the new state,
or <code>NULL</code> if there is a memory allocation error.
+<p><a name="luaL_openlibs"></a>
+<hr></hr><h3><code>luaL_openlibs</code></h3>
+<pre>
+ void luaL_openlibs (lua_State *L);
+</pre>
+
+
+<p>Opens all standard Lua libraries into the given state.
+
<p><a name="luaL_optint"></a>
-<hr /><h3><code>luaL_optint</code></h3>
+<hr></hr><h3><code>luaL_optint</code></h3>
<pre>
int luaL_optint (lua_State *L, int narg, int d);
</pre>
@@ -4094,9 +4152,9 @@ returns <code>d</code>.
Otherwise, raises an error.
<p><a name="luaL_optinteger"></a>
-<hr /><h3><code>luaL_optinteger</code></h3>
+<hr></hr><h3><code>luaL_optinteger</code></h3>
<pre>
- lua_Integer luaL_optinteger (lua_State *L, int nArg, lua_Integer d);
+ lua_Integer luaL_optinteger (lua_State *L, int narg, lua_Integer d);
</pre>
@@ -4107,7 +4165,7 @@ returns <code>d</code>.
Otherwise, raises an error.
<p><a name="luaL_optlong"></a>
-<hr /><h3><code>luaL_optlong</code></h3>
+<hr></hr><h3><code>luaL_optlong</code></h3>
<pre>
long luaL_optlong (lua_State *L, int narg, long d);
</pre>
@@ -4120,9 +4178,9 @@ returns <code>d</code>.
Otherwise, raises an error.
<p><a name="luaL_optlstring"></a>
-<hr /><h3><code>luaL_optlstring</code></h3>
+<hr></hr><h3><code>luaL_optlstring</code></h3>
<pre>
- const char *luaL_optlstring (lua_State *L, int numArg,
+ const char *luaL_optlstring (lua_State *L, int narg,
const char *d, size_t *l);
</pre>
@@ -4137,9 +4195,9 @@ Otherwise, raises an error.
fills the position <code>*l</code> with the results's length.
<p><a name="luaL_optnumber"></a>
-<hr /><h3><code>luaL_optnumber</code></h3>
+<hr></hr><h3><code>luaL_optnumber</code></h3>
<pre>
- lua_Number luaL_optnumber (lua_State *L, int nArg, lua_Number d);
+ lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
</pre>
@@ -4150,7 +4208,7 @@ returns <code>d</code>.
Otherwise, raises an error.
<p><a name="luaL_optstring"></a>
-<hr /><h3><code>luaL_optstring</code></h3>
+<hr></hr><h3><code>luaL_optstring</code></h3>
<pre>
const char *luaL_optstring (lua_State *L, int narg, const char *d);
</pre>
@@ -4163,7 +4221,7 @@ returns <code>d</code>.
Otherwise, raises an error.
<p><a name="luaL_prepbuffer"></a>
-<hr /><h3><code>luaL_prepbuffer</code></h3>
+<hr></hr><h3><code>luaL_prepbuffer</code></h3>
<pre>
char *luaL_prepbuffer (luaL_Buffer *B);
</pre>
@@ -4177,7 +4235,7 @@ After copying the string into that space you must call
it to the buffer.
<p><a name="luaL_pushresult"></a>
-<hr /><h3><code>luaL_pushresult</code></h3>
+<hr></hr><h3><code>luaL_pushresult</code></h3>
<pre>
void luaL_pushresult (luaL_Buffer *B);
</pre>
@@ -4187,7 +4245,7 @@ it to the buffer.
the top of the stack.
<p><a name="luaL_ref"></a>
-<hr /><h3><code>luaL_ref</code></h3>
+<hr></hr><h3><code>luaL_ref</code></h3>
<pre>
int luaL_ref (lua_State *L, int t);
</pre>
@@ -4205,12 +4263,12 @@ by calling <code>lua_rawgeti(L, t, r)</code>.
Function <a href="#luaL_unref"><code>luaL_unref</code></a> frees a reference and its associated object.
<p>If the object at the top of the stack is <b>nil</b>,
-<a href="#luaL_ref"><code>luaL_ref</code></a> returns the same reference <code>LUA_REFNIL</code>.
+<a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <code>LUA_REFNIL</code>.
The constant <code>LUA_NOREF</code> is guaranteed to be different
from any reference returned by <a href="#luaL_ref"><code>luaL_ref</code></a>.
<p><a name="luaL_Reg"></a>
-<hr /><h3><code>luaL_Reg</code></h3>
+<hr></hr><h3><code>luaL_Reg</code></h3>
<pre>
typedef struct luaL_Reg {
const char *name;
@@ -4228,7 +4286,7 @@ Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sent
in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
<p><a name="luaL_register"></a>
-<hr /><h3><code>luaL_register</code></h3>
+<hr></hr><h3><code>luaL_register</code></h3>
<pre>
void luaL_register (lua_State *L, const char *libname,
const luaL_Reg *l);
@@ -4254,7 +4312,7 @@ reuses that table instead of creating a new one.
on the top of the stack.
<p><a name="luaL_typename"></a>
-<hr /><h3><code>luaL_typename</code></h3>
+<hr></hr><h3><code>luaL_typename</code></h3>
<pre>
const char *luaL_typename (lua_State *L, int idx);
</pre>
@@ -4263,7 +4321,7 @@ on the top of the stack.
<p>Returns the name of the type of the value at index <code>idx</code>.
<p><a name="luaL_typerror"></a>
-<hr /><h3><code>luaL_typerror</code></h3>
+<hr></hr><h3><code>luaL_typerror</code></h3>
<pre>
int luaL_typerror (lua_State *L, int narg, const char *tname);
</pre>
@@ -4278,7 +4336,7 @@ where <code>&#060;location></code> is produced by <a href="#luaL_where"><code>lu
and <code>&#060;realt></code> is the type name of the actual argument.
<p><a name="luaL_unref"></a>
-<hr /><h3><code>luaL_unref</code></h3>
+<hr></hr><h3><code>luaL_unref</code></h3>
<pre>
void luaL_unref (lua_State *L, int t, int ref);
</pre>
@@ -4294,7 +4352,7 @@ The reference <code>ref</code> is also freed to be used again.
<a href="#luaL_unref"><code>luaL_unref</code></a> does nothing.
<p><a name="luaL_where"></a>
-<hr /><h3><code>luaL_where</code></h3>
+<hr></hr><h3><code>luaL_where</code></h3>
<pre>
void luaL_where (lua_State *L, int lvl);
</pre>
@@ -4363,14 +4421,14 @@ If you do not include this library in your application,
you should check carefully whether you need to provide
implementations for some of its facilities.
-<p><a name="pdf-assert"></a><hr /><h3><code>assert (v [, message])</code></h3>
+<p><a name="pdf-assert"></a><hr></hr><h3><code>assert (v [, message])</code></h3>
Issues an error when
the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
otherwise, returns all its arguments.
<code>message</code> is an error message;
when absent, it defaults to "assertion failed!"
-<p><a name="pdf-collectgarbage"></a><hr /><h3><code>collectgarbage (opt [, arg])</code></h3>
+<p><a name="pdf-collectgarbage"></a><hr></hr><h3><code>collectgarbage (opt [, arg])</code></h3>
<p>This function is a generic interface to the garbage collector.
It performs different functions according to its first argument, <code>opt</code>:
@@ -4393,7 +4451,7 @@ sets <code>arg</code>/100 as the new value for the <em>step multiplier</em> of
the collector (see <a href="#GC">2.10</a>).
</ul>
-<p><a name="pdf-dofile"></a><hr /><h3><code>dofile (filename)</code></h3>
+<p><a name="pdf-dofile"></a><hr></hr><h3><code>dofile (filename)</code></h3>
Opens the named file and executes its contents as a Lua chunk.
When called without arguments,
<code>dofile</code> executes the contents of the standard input (<code>stdin</code>).
@@ -4401,7 +4459,7 @@ Returns all values returned by the chunk.
In case of errors, <code>dofile</code> propagates the error
to its caller (that is, <code>dofile</code> does not run in protected mode).
-<p><a name="pdf-error"></a><hr /><h3><code>error (message [, level])</code></h3>
+<p><a name="pdf-error"></a><hr></hr><h3><code>error (message [, level])</code></h3>
Terminates the last protected function called
and returns <code>message</code> as the error message.
Function <code>error</code> never returns.
@@ -4416,7 +4474,7 @@ that called <code>error</code> was called; and so on.
Passing a level 0 avoids the addition of error position information
to the message.
-<p><a name="pdf-_G"></a><hr /><h3><code>_G</code></h3>
+<p><a name="pdf-_G"></a><hr></hr><h3><code>_G</code></h3>
A global variable (not a function) that
holds the global environment (that is, <code>_G._G = _G</code>).
Lua itself does not use this variable;
@@ -4424,7 +4482,7 @@ changing its value does not affect any environment,
nor vice-versa.
(Use <a href="#pdf-setfenv"><code>setfenv</code></a> to change environments.)
-<p><a name="pdf-getfenv"></a><hr /><h3><code>getfenv (f)</code></h3>
+<p><a name="pdf-getfenv"></a><hr></hr><h3><code>getfenv (f)</code></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:
@@ -4434,7 +4492,7 @@ or if <code>f</code> is 0,
<code>getfenv</code> returns the global environment.
The default for <code>f</code> is 1.
-<p><a name="pdf-getmetatable"></a><hr /><h3><code>getmetatable (object)</code></h3>
+<p><a name="pdf-getmetatable"></a><hr></hr><h3><code>getmetatable (object)</code></h3>
<p>If <code>object</code> does not have a metatable, returns <b>nil</b>.
Otherwise,
@@ -4442,7 +4500,7 @@ if the object's metatable has a <code>"__metatable"</code> field,
returns the associated value.
Otherwise, returns the metatable of the given object.
-<p><a name="pdf-ipairs"></a><hr /><h3><code>ipairs (t)</code></h3>
+<p><a name="pdf-ipairs"></a><hr></hr><h3><code>ipairs (t)</code></h3>
<p>Returns three values: an iterator function, the table <code>t</code>, and 0,
so that the construction
@@ -4454,7 +4512,7 @@ up to the first integer key with a nil value in the table.
<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
-<p><a name="pdf-load"></a><hr /><h3><code>load (func [, chunkname])</code></h3>
+<p><a name="pdf-load"></a><hr></hr><h3><code>load (func [, chunkname])</code></h3>
<p>Loads a chunk using function <code>func</code> to get its pieces.
Each call to <code>func</code> must return a string that concatenates
@@ -4469,14 +4527,14 @@ The environment of the returned function is the global environment.
<p><code>chunkname</code> is used as the chunk name for error messages
and debug information.
-<p><a name="pdf-loadfile"></a><hr /><h3><code>loadfile ([filename])</code></h3>
+<p><a name="pdf-loadfile"></a><hr></hr><h3><code>loadfile ([filename])</code></h3>
<p>Similar to <a href="#pdf-load"><code>load</code></a>,
but gets the chunk from file <code>filename</code>
or from the standard input,
-if no file name given.
+if no file name is given.
-<p><a name="pdf-loadstring"></a><hr /><h3><code>loadstring (string [, chunkname])</code></h3>
+<p><a name="pdf-loadstring"></a><hr></hr><h3><code>loadstring (string [, chunkname])</code></h3>
<p>Similar to <a href="#pdf-load"><code>load</code></a>,
but gets the chunk from the given string.
@@ -4486,7 +4544,7 @@ but gets the chunk from the given string.
assert(loadstring(s))()
</pre>
-<p><a name="pdf-next"></a><hr /><h3><code>next (table [, index])</code></h3>
+<p><a name="pdf-next"></a><hr></hr><h3><code>next (table [, index])</code></h3>
<p>Allows a program to traverse all fields of a table.
Its first argument is a table and its second argument
@@ -4518,7 +4576,7 @@ you assign any value to a non-existent field in the table.
You may however modify existing fields.
In particular, you may clear existing fields.
-<p><a name="pdf-pairs"></a><hr /><h3><code>pairs (t)</code></h3>
+<p><a name="pdf-pairs"></a><hr></hr><h3><code>pairs (t)</code></h3>
<p>Returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</code>, and <b>nil</b>,
so that the construction
@@ -4529,7 +4587,7 @@ will iterate over all key--value pairs of table <code>t</code>.
<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
-<p><a name="pdf-pcall"></a><hr /><h3><code>pcall (f, arg1, arg2, ...)</code></h3>
+<p><a name="pdf-pcall"></a><hr></hr><h3><code>pcall (f, arg1, arg2, ...)</code></h3>
<p>Calls function <code>f</code> with
the given arguments in protected mode.
@@ -4542,7 +4600,7 @@ In such case, <code>pcall</code> also returns all results from the call,
after this first result.
In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.
-<p><a name="pdf-print"></a><hr /><h3><code>print (e1, e2, ...)</code></h3>
+<p><a name="pdf-print"></a><hr></hr><h3><code>print (e1, e2, ...)</code></h3>
Receives any number of arguments,
and prints their values in <code>stdout</code>,
using the <a href="#pdf-tostring"><code>tostring</code></a> function to convert them to strings.
@@ -4551,32 +4609,32 @@ but only as a quick way to show a value,
typically for debugging.
For formatted output, use <a href="#pdf-string.format"><code>string.format</code></a>.
-<p><a name="pdf-rawequal"></a><hr /><h3><code>rawequal (v1, v2)</code></h3>
+<p><a name="pdf-rawequal"></a><hr></hr><h3><code>rawequal (v1, v2)</code></h3>
Checks whether <code>v1</code> is equal to <code>v2</code>,
without invoking any metamethod.
Returns a boolean.
-<p><a name="pdf-rawget"></a><hr /><h3><code>rawget (table, index)</code></h3>
+<p><a name="pdf-rawget"></a><hr></hr><h3><code>rawget (table, index)</code></h3>
Gets the real value of <code>table[index]</code>,
without invoking any metamethod.
<code>table</code> must be a table and
<code>index</code> any value different from <b>nil</b>.
-<p><a name="pdf-rawset"></a><hr /><h3><code>rawset (table, index, value)</code></h3>
+<p><a name="pdf-rawset"></a><hr></hr><h3><code>rawset (table, index, value)</code></h3>
Sets the real value of <code>table[index]</code> to <code>value</code>,
without invoking any metamethod.
<code>table</code> must be a table,
<code>index</code> any value different from <b>nil</b>,
and <code>value</code> any Lua value.
-<p><a name="pdf-select"></a><hr /><h3><code>select (index, ...)</code></h3>
+<p><a name="pdf-select"></a><hr></hr><h3><code>select (index, ...)</code></h3>
<p>If <code>index</code> is a number,
returns all arguments after argument number <code>index</code>.
Otherwise, <code>index</code> must be the string <code>"#"</code>,
and <code>select</code> returns the total number of extra arguments it received.
-<p><a name="setfenv"></a><a name="pdf-setfenv"></a><hr /><h3><code>setfenv (f, table)</code></h3>
+<p><a name="setfenv"></a><a name="pdf-setfenv"></a><hr></hr><h3><code>setfenv (f, table)</code></h3>
<p>Sets the environment to be used by the given function.
<code>f</code> can be a Lua function or a number
@@ -4588,7 +4646,7 @@ Level 1 is the function calling <code>setfenv</code>.
the environment of the running thread.
In this case, <code>setfenv</code> returns no values.
-<p><a name="pdf-setmetatable"></a><hr /><h3><code>setmetatable (table, metatable)</code></h3>
+<p><a name="pdf-setmetatable"></a><hr></hr><h3><code>setmetatable (table, metatable)</code></h3>
<p>Sets the metatable for the given table.
(You cannot change the metatable of other types from Lua, only from C.)
@@ -4599,7 +4657,7 @@ raises an error.
<p>This function returns <code>table</code>.
-<p><a name="pdf-tonumber"></a><hr /><h3><code>tonumber (e [, base])</code></h3>
+<p><a name="pdf-tonumber"></a><hr></hr><h3><code>tonumber (e [, base])</code></h3>
Tries to convert its argument to a number.
If the argument is already a number or a string convertible
to a number, then <code>tonumber</code> returns that number;
@@ -4614,7 +4672,7 @@ In base 10 (the default), the number may have a decimal part,
as well as an optional exponent part (see <a href="#lexical">2.1</a>).
In other bases, only unsigned integers are accepted.
-<p><a name="pdf-tostring"></a><hr /><h3><code>tostring (e)</code></h3>
+<p><a name="pdf-tostring"></a><hr></hr><h3><code>tostring (e)</code></h3>
Receives an argument of any type and
converts it to a string in a reasonable format.
For complete control of how numbers are converted,
@@ -4625,7 +4683,7 @@ then <code>tostring</code> calls the corresponding value
with <code>e</code> as argument,
and uses the result of the call as its result.
-<p><a name="pdf-type"></a><hr /><h3><code>type (v)</code></h3>
+<p><a name="pdf-type"></a><hr></hr><h3><code>type (v)</code></h3>
Returns the type of its only argument, coded as a string.
The possible results of this function are
<code>"nil"</code> (a string, not the value <b>nil</b>),
@@ -4637,7 +4695,7 @@ The possible results of this function are
<code>"thread"</code>,
and <code>"userdata"</code>.
-<p><a name="pdf-unpack"></a><hr /><h3><code>unpack (list [, i [, j]])</code></h3>
+<p><a name="pdf-unpack"></a><hr></hr><h3><code>unpack (list [, i [, j]])</code></h3>
Returns the elements from the given table.
This function is equivalent to
<pre>
@@ -4648,12 +4706,12 @@ of elements.
By default, <code>i</code> is 1 and <code>j</code> is the length of the list,
as defined by the length operator (see <a href="#len-op">2.5.5</a>).
-<p><a name="pdf-_VERSION"></a><hr /><h3><code>_VERSION</code></h3>
+<p><a name="pdf-_VERSION"></a><hr></hr><h3><code>_VERSION</code></h3>
A global variable (not a function) that
holds a string containing the current interpreter version.
The current contents of this variable is <code>"Lua 5.1"</code>.
-<p><a name="pdf-xpcall"></a><hr /><h3><code>xpcall (f, err)</code></h3>
+<p><a name="pdf-xpcall"></a><hr></hr><h3><code>xpcall (f, err)</code></h3>
<p>This function is similar to <code>pcall</code>,
except that you can set a new error handler.
@@ -4677,14 +4735,14 @@ In case of any error,
the basic library and come inside the table <code>coroutine</code>.
See <a href="#coroutine">2.11</a> for a general description of coroutines.
-<p><a name="pdf-coroutine.create"></a><hr /><h3><code>coroutine.create (f)</code></h3>
+<p><a name="pdf-coroutine.create"></a><hr></hr><h3><code>coroutine.create (f)</code></h3>
<p>Creates a new coroutine, with body <code>f</code>.
<code>f</code> must be a Lua function.
Returns this new coroutine,
an object with type <code>"thread"</code>.
-<p><a name="pdf-coroutine.resume"></a><hr /><h3><code>coroutine.resume (co [, val1, ..., valn])</code></h3>
+<p><a name="pdf-coroutine.resume"></a><hr></hr><h3><code>coroutine.resume (co [, val1, ..., valn])</code></h3>
<p>Starts or continues the execution of coroutine <code>co</code>.
The first time you resume a coroutine,
@@ -4703,12 +4761,12 @@ as the results from the yield.
If there is any error,
<code>resume</code> returns <b>false</b> plus the error message.
-<p><a name="pdf-coroutine.running"></a><hr /><h3><code>coroutine.running ()</code></h3>
+<p><a name="pdf-coroutine.running"></a><hr></hr><h3><code>coroutine.running ()</code></h3>
<p>Returns the running coroutine,
or <b>nil</b> when called by the main thread.
-<p><a name="pdf-coroutine.status"></a><hr /><h3><code>coroutine.status (co)</code></h3>
+<p><a name="pdf-coroutine.status"></a><hr></hr><h3><code>coroutine.status (co)</code></h3>
<p>Returns the status of coroutine <code>co</code>, as a string:
<code>"running"</code>,
@@ -4720,7 +4778,7 @@ or if it has not started running yet;
and <code>"dead"</code> if the coroutine has finished its body function,
or if it has stopped with an error.
-<p><a name="pdf-coroutine.wrap"></a><hr /><h3><code>coroutine.wrap (f)</code></h3>
+<p><a name="pdf-coroutine.wrap"></a><hr></hr><h3><code>coroutine.wrap (f)</code></h3>
<p>Creates a new coroutine, with body <code>f</code>.
<code>f</code> must be a Lua function.
@@ -4731,7 +4789,7 @@ Returns the same values returned by <code>resume</code>,
except the first boolean.
In case of error, propagates the error.
-<p><a name="pdf-coroutine.yield"></a><hr /><h3><code>coroutine.yield ([val1, ..., valn])</code></h3>
+<p><a name="pdf-coroutine.yield"></a><hr></hr><h3><code>coroutine.yield ([val1, ..., valn])</code></h3>
<p>Suspends the execution of the calling coroutine.
The coroutine can be running neither a C function,
@@ -4746,7 +4804,7 @@ It exports two of its functions directly in the global environment:
<a href="#pdf-require"><code>require</code></a> and <a href="#pdf-module"><code>module</code></a>.
Everything else is exported in a table <code>package</code>.
-<p><a name="pdf-module"></a><hr /><h3><code>module (name [, ...])</code></h3>
+<p><a name="pdf-module"></a><hr></hr><h3><code>module (name [, ...])</code></h3>
<p>Creates a module.
If there is a table in <code>package.loaded[name]</code>,
@@ -4776,7 +4834,7 @@ field <code>b</code> of global <code>a</code>.
the module name,
where each option is a function to be applied over the module.
-<p><a name="pdf-require"></a><hr /><h3><code>require (modname)</code></h3>
+<p><a name="pdf-require"></a><hr></hr><h3><code>require (modname)</code></h3>
<p>Loads the given module.
The function starts by looking into the table <code>package.loaded</code>
@@ -4830,14 +4888,14 @@ If the loader returns any value,
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 that entry.
-In any case, require returns the
+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 that module,
then <code>require</code> signals an error.
-<p><a name="pdf-package.cpath"></a><hr /><h3><code>package.cpath</code></h3>
+<p><a name="pdf-package.cpath"></a><hr></hr><h3><code>package.cpath</code></h3>
<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a C loader.
@@ -4846,7 +4904,7 @@ it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code
using the environment variable <code>LUA_CPATH</code>
(plus another default path defined in <code>luaconf.h</code>).
-<p><a name="pdf-package.loaded"></a><hr /><h3><code>package.loaded</code></h3>
+<p><a name="pdf-package.loaded"></a><hr></hr><h3><code>package.loaded</code></h3>
<p>A table used by <a href="#pdf-require"><code>require</code></a> to control which
modules are already loaded.
@@ -4854,7 +4912,7 @@ 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><a name="pdf-package.loadlib"></a><hr /><h3><code>package.loadlib (libname, funcname)</code></h3>
+<p><a name="pdf-package.loadlib"></a><hr></hr><h3><code>package.loadlib (libname, funcname)</code></h3>
<p>Dynamically links the host program with the C library <code>libname</code>.
Inside this library, looks for a function <code>funcname</code>
@@ -4864,7 +4922,8 @@ and returns this function as a C function.
<p>This is a low-level function.
It completely bypasses the package and module system.
Unlike <a href="#pdf-require"><code>require</code></a>,
-it does not perform any path searching or automatically adds extensions.
+it does not perform any path searching and
+does not automatically adds extensions.
<code>libname</code> must be the complete file name of the C library,
including if necessary a path and extension.
<code>funcname</code> must be the exact name exported by the C library
@@ -4875,7 +4934,7 @@ As such, it is only available on some platforms
(Windows, Linux, Mac OS X, Solaris, BSD,
plus other Unix systems that support the <code>dlfcn</code> standard).
-<p><a name="pdf-package.path"></a><hr /><h3><code>package.path</code></h3>
+<p><a name="pdf-package.path"></a><hr></hr><h3><code>package.path</code></h3>
<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a Lua loader.
@@ -4901,12 +4960,12 @@ 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><a name="pdf-package.preload"></a><hr /><h3><code>package.preload</code></h3>
+<p><a name="pdf-package.preload"></a><hr></hr><h3><code>package.preload</code></h3>
<p>A table to store loaders for specific modules
(see <a href="#pdf-require"><code>require</code></a>).
-<p><a name="pdf-package.seeall"></a><hr /><h3><code>package.seeall (module)</code></h3>
+<p><a name="pdf-package.seeall"></a><hr></hr><h3><code>package.seeall (module)</code></h3>
<p>Sets a metatable for <code>module</code> with
its <code>__index</code> field referring to the global environment,
@@ -4932,7 +4991,7 @@ Therefore, you can use the string functions in object-oriented style.
For instance, <code>string.byte(s, i)</code>
can be written as <code>s:byte(i)</code>.
-<p><a name="pdf-string.byte"></a><hr /><h3><code>string.byte (s [, i [, j]])</code></h3>
+<p><a name="pdf-string.byte"></a><hr></hr><h3><code>string.byte (s [, i [, j]])</code></h3>
Returns the internal numerical codes of the characters <code>s[i]</code>,
<code>s[i+1]</code>, ..., <code>s[j]</code>.
The default value for <code>i</code> is 1;
@@ -4940,7 +4999,7 @@ the default value for <code>j</code> is <code>i</code>.
<p>Note that numerical codes are not necessarily portable across platforms.
-<p><a name="pdf-string.char"></a><hr /><h3><code>string.char (i1, i2, ...)</code></h3>
+<p><a name="pdf-string.char"></a><hr></hr><h3><code>string.char (i1, i2, ...)</code></h3>
Receives 0 or more integers.
Returns a string with length equal to the number of arguments,
in which each character has the internal numerical code equal
@@ -4948,14 +5007,14 @@ to its corresponding argument.
<p>Note that numerical codes are not necessarily portable across platforms.
-<p><a name="pdf-string.dump"></a><hr /><h3><code>string.dump (function)</code></h3>
+<p><a name="pdf-string.dump"></a><hr></hr><h3><code>string.dump (function)</code></h3>
<p>Returns a string containing a binary representation of the given function,
so that a later <a href="#pdf-loadstring"><code>loadstring</code></a> on that string returns
a copy of the function.
<code>function</code> must be a Lua function without upvalues.
-<p><a name="pdf-string.find"></a><hr /><h3><code>string.find (s, pattern [, init [, plain]])</code></h3>
+<p><a name="pdf-string.find"></a><hr></hr><h3><code>string.find (s, pattern [, init [, plain]])</code></h3>
Looks for the first match of
<code>pattern</code> in the string <code>s</code>.
If it finds a match, then <code>find</code> returns the indices of <code>s</code>
@@ -4975,7 +5034,7 @@ then in a successful match
the captured values are also returned,
after the two indices.
-<p><a name="format"></a><a name="pdf-string.format"></a><hr /><h3><code>string.format (formatstring, e1, e2, ...)</code></h3>
+<p><a name="format"></a><a name="pdf-string.format"></a><hr></hr><h3><code>string.format (formatstring, e1, e2, ...)</code></h3>
Returns a formatted version of its variable number of arguments
following the description given in its first argument (which must be a string).
The format string follows the same rules as the <code>printf</code> family of
@@ -5008,7 +5067,7 @@ whereas <code>q</code> and <code>s</code> expect a string.
<p>This function does not accept string values
containing embedded zeros.
-<p><a name="pdf-string.gmatch"></a><hr /><h3><code>string.gmatch (s, pattern)</code></h3>
+<p><a name="pdf-string.gmatch"></a><hr></hr><h3><code>string.gmatch (s, pattern)</code></h3>
Returns an iterator function that,
each time it is called,
returns the next captures from <code>pattern</code> over string <code>s</code>.
@@ -5035,7 +5094,7 @@ given string into a table:
end
</pre>
-<p><a name="pdf-string.gsub"></a><hr /><h3><code>string.gsub (s, pattern, repl [, n])</code></h3>
+<p><a name="pdf-string.gsub"></a><hr></hr><h3><code>string.gsub (s, pattern, repl [, n])</code></h3>
Returns a copy of <code>s</code>
in which all occurrences of the <code>pattern</code> have been
replaced by a replacement string specified by <code>repl</code>,
@@ -5061,12 +5120,8 @@ match occurs, with all captured substrings passed as arguments,
in order;
if the pattern specifies no captures,
then the whole match is passed as a sole argument.
-If <code>repl</code> is a table, then this table is queried with the
-value of the first capture or of the whole match,
-if the pattern specifies no captures.
-<p>In both cases,
-if the value returned by the function or by the table query
+<p>If the value returned by the table query or by the function call
is a string or a number,
then it is used as the replacement string;
otherwise, if it is <b>false</b> or <b>nil</b>,
@@ -5102,19 +5157,19 @@ For instance, when <code>n</code> is 1 only the first occurrence of
--> x="lua-5.1.tar.gz"
</pre>
-<p><a name="pdf-string.len"></a><hr /><h3><code>string.len (s)</code></h3>
+<p><a name="pdf-string.len"></a><hr></hr><h3><code>string.len (s)</code></h3>
Receives a string and returns its length.
The empty string <code>""</code> has length 0.
Embedded zeros are counted,
so <code>"a\000bc\000"</code> has length 5.
-<p><a name="pdf-string.lower"></a><hr /><h3><code>string.lower (s)</code></h3>
+<p><a name="pdf-string.lower"></a><hr></hr><h3><code>string.lower (s)</code></h3>
Receives a string and returns a copy of that string with all
uppercase letters changed to lowercase.
All other characters are left unchanged.
The definition of what an uppercase letter is depends on the current locale.
-<p><a name="pdf-string.match"></a><hr /><h3><code>string.match (s, pattern [, init])</code></h3>
+<p><a name="pdf-string.match"></a><hr></hr><h3><code>string.match (s, pattern [, init])</code></h3>
Looks for the first <em>match</em> of
<code>pattern</code> in the string <code>s</code>.
If it finds one, then <code>match</code> returns
@@ -5126,14 +5181,14 @@ A third, optional numerical argument <code>init</code> specifies
where to start the search;
its default value is 1 and may be negative.
-<p><a name="pdf-string.rep"></a><hr /><h3><code>string.rep (s, n)</code></h3>
+<p><a name="pdf-string.rep"></a><hr></hr><h3><code>string.rep (s, n)</code></h3>
Returns a string that is the concatenation of <code>n</code> copies of
the string <code>s</code>.
-<p><a name="pdf-string.reverse"></a><hr /><h3><code>string.reverse (s)</code></h3>
+<p><a name="pdf-string.reverse"></a><hr></hr><h3><code>string.reverse (s)</code></h3>
Returns a string that is the string <code>s</code> reversed.
-<p><a name="pdf-string.sub"></a><hr /><h3><code>string.sub (s, i [, j])</code></h3>
+<p><a name="pdf-string.sub"></a><hr></hr><h3><code>string.sub (s, i [, j])</code></h3>
Returns the substring of <code>s</code> that
starts at <code>i</code> and continues until <code>j</code>;
<code>i</code> and <code>j</code> may be negative.
@@ -5145,7 +5200,7 @@ with length <code>j</code>,
and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>
with length <code>i</code>.
-<p><a name="pdf-string.upper"></a><hr /><h3><code>string.upper (s)</code></h3>
+<p><a name="pdf-string.upper"></a><hr></hr><h3><code>string.upper (s)</code></h3>
Receives a string and returns a copy of that string with all
lowercase letters changed to uppercase.
All other characters are left unchanged.
@@ -5279,17 +5334,17 @@ It provides all its functions inside the table <code>table</code>.
<p>Most functions in the table library assume that the table
represents an array or a list.
-For those functions, when we talk about "the length" of a table
+For those functions, when we talk about the "length" of a table
we mean the result of the length operator.
-<p><a name="pdf-table.concat"></a><hr /><h3><code>table.concat (table [, sep [, i [, j]]])</code></h3>
+<p><a name="pdf-table.concat"></a><hr></hr><h3><code>table.concat (table [, sep [, i [, j]]])</code></h3>
Returns <code>table[i]..sep..table[i+1] ... 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.
If <code>i</code> is greater than <code>j</code>, returns the empty string.
-<p><a name="pdf-table.insert"></a><hr /><h3><code>table.insert (table, [pos,] value)</code></h3>
+<p><a name="pdf-table.insert"></a><hr></hr><h3><code>table.insert (table, [pos,] value)</code></h3>
<p>Inserts element <code>value</code> at position <code>pos</code> in <code>table</code>,
shifting up other elements to open space, if necessary.
@@ -5298,14 +5353,14 @@ where <code>n</code> is the length of the table (see <a href="#len-op">2.5.5</a>
so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
of table <code>t</code>.
-<p><a name="pdf-table.maxn"></a><hr /><h3><code>table.maxn (table)</code></h3>
+<p><a name="pdf-table.maxn"></a><hr></hr><h3><code>table.maxn (table)</code></h3>
<p>Returns the largest positive numerical index of the given table,
or zero if the table has no positive numerical indices.
(To do its job this function does a linear traversal of
the whole table.)
-<p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3>
+<p><a name="pdf-table.remove"></a><hr></hr><h3><code>table.remove (table [, pos])</code></h3>
<p>Removes from <code>table</code> the element at position <code>pos</code>,
shifting down other elements to close the space, if necessary.
@@ -5315,7 +5370,7 @@ where <code>n</code> is the length of the table,
so that a call <code>table.remove(t)</code> removes the last element
of table <code>t</code>.
-<p><a name="pdf-table.sort"></a><hr /><h3><code>table.sort (table [, comp])</code></h3>
+<p><a name="pdf-table.sort"></a><hr></hr><h3><code>table.sort (table [, comp])</code></h3>
Sorts table elements in a given order, <em>in-place</em>,
from <code>table[1]</code> to <code>table[n]</code>,
where <code>n</code> is the length of the table.
@@ -5336,16 +5391,17 @@ may have their relative positions changed by the sort.
<p>This library is an interface to the standard C math library.
It provides all its functions inside the table <code>math</code>.
The library provides the following functions:
-<a name="pdf-math.abs"></a><a name="pdf-math.acos"></a><a name="pdf-math.asin"></a><a name="pdf-math.atan"></a>
-<a name="pdf-math.atan2"></a><a name="pdf-math.ceil"></a><a name="pdf-math.cos"></a><a name="pdf-math.cosh"></a>
-<a name="pdf-math.def"></a><a name="pdf-math.exp"></a>
-<a name="pdf-math.floor"></a><a name="pdf-math.log"></a><a name="pdf-math.log10"></a>
-<a name="pdf-math.fmod"></a><a name="pdf-math.pow"></a><a name="pdf-math.sin"></a>
-<a name="pdf-math.sqrt"></a><a name="pdf-math.tan"></a><a name="pdf-math.ldexp"></a>
-<a name="pdf-math.sinh"></a><a name="pdf-math.tanh"></a>
+<a name="pdf-math.abs"></a> <a name="pdf-math.acos"></a> <a name="pdf-math.asin"></a> <a name="pdf-math.atan"></a>
+<a name="pdf-math.atan2"></a> <a name="pdf-math.ceil"></a> <a name="pdf-math.cos"></a> <a name="pdf-math.cosh"></a>
+<a name="pdf-math.deg"></a> <a name="pdf-math.exp"></a> <a name="pdf-math.floor"></a> <a name="pdf-math.fmod"></a>
+<a name="pdf-math.frexp"></a> <a name="pdf-math.ldexp"></a> <a name="pdf-math.log"></a> <a name="pdf-math.log10"></a>
+<a name="pdf-math.max"></a> <a name="pdf-math.min"></a> <a name="pdf-math.modf"></a> <a name="pdf-math.pow"></a>
+<a name="pdf-math.rad"></a> <a name="pdf-math.random"></a> <a name="pdf-math.randomseed"></a>
+<a name="pdf-math.sin"></a> <a name="pdf-math.sinh"></a> <a name="pdf-math.sqrt"></a> <a name="pdf-math.tan"></a>
+<a name="pdf-math.tanh"></a>
<pre>
math.abs math.acos math.asin math.atan math.atan2
- math.ceil math.cosh math.cos math.deg math.exp
+ math.ceil math.cos math.cosh math.deg math.exp
math.floor math.fmod math.frexp math.ldexp math.log
math.log10 math.max math.min math.modf math.pow
math.rad math.random math.randomseed math.sin
@@ -5413,16 +5469,16 @@ all I/O functions return <b>nil</b> on failure
(plus an error message as a second result)
and some value different from <b>nil</b> on success.
-<p><a name="pdf-io.close"></a><hr /><h3><code>io.close ([file])</code></h3>
+<p><a name="pdf-io.close"></a><hr></hr><h3><code>io.close ([file])</code></h3>
<p>Equivalent to <code>file:close()</code>.
Without a <code>file</code>, closes the default output file.
-<p><a name="pdf-io.flush"></a><hr /><h3><code>io.flush ()</code></h3>
+<p><a name="pdf-io.flush"></a><hr></hr><h3><code>io.flush ()</code></h3>
<p>Equivalent to <code>file:flush</code> over the default output file.
-<p><a name="pdf-io.input"></a><hr /><h3><code>io.input ([file])</code></h3>
+<p><a name="pdf-io.input"></a><hr></hr><h3><code>io.input ([file])</code></h3>
<p>When called with a file name, it opens the named file (in text mode),
and sets its handle as the default input file.
@@ -5434,7 +5490,7 @@ it returns the current default input file.
<p>In case of errors this function raises the error,
instead of returning an error code.
-<p><a name="pdf-io.lines"></a><hr /><h3><code>io.lines ([filename])</code></h3>
+<p><a name="pdf-io.lines"></a><hr></hr><h3><code>io.lines ([filename])</code></h3>
<p>Opens the given file name in read mode
and returns an iterator function that,
@@ -5453,7 +5509,7 @@ to <code>io.input():lines()</code>;
that is, it iterates over the lines of the default input file.
In that case it does not close the file when the loop ends.
-<p><a name="pdf-io.open"></a><hr /><h3><code>io.open (filename [, mode])</code></h3>
+<p><a name="pdf-io.open"></a><hr></hr><h3><code>io.open (filename [, mode])</code></h3>
<p>This function opens a file,
in the mode specified in the string <code>mode</code>.
@@ -5475,11 +5531,11 @@ which is needed in some systems to open the file in binary mode.
This string is exactly what is used in the
standard C function <code>fopen</code>.
-<p><a name="pdf-io.output"></a><hr /><h3><code>io.output ([file])</code></h3>
+<p><a name="pdf-io.output"></a><hr></hr><h3><code>io.output ([file])</code></h3>
<p>Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output file.
-<p><a name="pdf-io.popen"></a><hr /><h3><code>io.popen ([prog [, mode]])</code></h3>
+<p><a name="pdf-io.popen"></a><hr></hr><h3><code>io.popen ([prog [, mode]])</code></h3>
<p>Starts program <code>prog</code> in a separated process and returns
a file handle that you can use to read data from that program
@@ -5490,39 +5546,39 @@ or to write data to that program
<p>This function is system dependent and is not available
on all platforms.
-<p><a name="pdf-io.read"></a><hr /><h3><code>io.read (format1, ...)</code></h3>
+<p><a name="pdf-io.read"></a><hr></hr><h3><code>io.read (format1, ...)</code></h3>
<p>Equivalent to <code>io.input():read</code>.
-<p><a name="pdf-io.tmpfile"></a><hr /><h3><code>io.tmpfile ()</code></h3>
+<p><a name="pdf-io.tmpfile"></a><hr></hr><h3><code>io.tmpfile ()</code></h3>
<p>Returns a handle for a temporary file.
This file is opened in update mode
and it is automatically removed when the program ends.
-<p><a name="pdf-io.type"></a><hr /><h3><code>io.type (obj)</code></h3>
+<p><a name="pdf-io.type"></a><hr></hr><h3><code>io.type (obj)</code></h3>
<p>Checks whether <code>obj</code> is a valid file handle.
Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,
<code>"closed file"</code> if <code>obj</code> is a closed file handle,
and <b>nil</b> if <code>obj</code> is not a file handle.
-<p><a name="pdf-io.write"></a><hr /><h3><code>io.write (value1, ...)</code></h3>
+<p><a name="pdf-io.write"></a><hr></hr><h3><code>io.write (value1, ...)</code></h3>
<p>Equivalent to <code>io.output():write</code>.
-<p><a name="pdf-file:close"></a><hr /><h3><code>file:close ()</code></h3>
+<p><a name="pdf-file:close"></a><hr></hr><h3><code>file:close ()</code></h3>
<p>Closes <code>file</code>.
Note that files are automatically closed when
their handles are garbage collected,
-but that takes an unpredictable time to happen.
+but that takes an unpredictable amount of time to happen.
-<p><a name="flush"></a><a name="pdf-file:flush"></a><hr /><h3><code>file:flush ()</code></h3>
+<p><a name="flush"></a><a name="pdf-file:flush"></a><hr></hr><h3><code>file:flush ()</code></h3>
<p>Saves any written data to <code>file</code>.
-<p><a name="pdf-file:lines"></a><hr /><h3><code>file:lines ()</code></h3>
+<p><a name="pdf-file:lines"></a><hr></hr><h3><code>file:lines ()</code></h3>
<p>Returns an iterator function that,
each time it is called,
@@ -5535,7 +5591,7 @@ will iterate over all lines of the file.
(Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
when the loop ends.)
-<p><a name="pdf-file:read"></a><hr /><h3><code>file:read (format1, ...)</code></h3>
+<p><a name="pdf-file:read"></a><hr></hr><h3><code>file:read (format1, ...)</code></h3>
<p>Reads the file <code>file</code>,
according to the given formats, which specify what to read.
@@ -5562,16 +5618,16 @@ it reads nothing and returns an empty string,
or <b>nil</b> on end of file.
</ul>
-<p><a name="pdf-file:seek"></a><hr /><h3><code>file:seek ([whence] [, offset])</code></h3>
+<p><a name="pdf-file:seek"></a><hr></hr><h3><code>file:seek ([whence] [, offset])</code></h3>
<p>Sets and gets the file position,
measured from the beginning of the file,
to the position given by <code>offset</code> plus a base
specified by the string <code>whence</code>, as follows:
<ul>
-<li><b>"set"</b> base is position 0 (beginning of the file);
-<li><b>"cur"</b> base is current position;
-<li><b>"end"</b> base is end of file;
+<li><b>"set"</b> --- base is position 0 (beginning of the file);
+<li><b>"cur"</b> --- base is current position;
+<li><b>"end"</b> --- base is end of file;
</ul>
In case of success, function <code>seek</code> returns the final file position,
measured in bytes from the beginning of the file.
@@ -5587,7 +5643,7 @@ beginning of the file (and returns 0);
and the call <code>file:seek("end")</code> sets the position to the
end of the file, and returns its size.
-<p><a name="pdf-file:setvbuf"></a><hr /><h3><code>file:setvbuf (mode [, size])</code></h3>
+<p><a name="pdf-file:setvbuf"></a><hr></hr><h3><code>file:setvbuf (mode [, size])</code></h3>
<p>Sets the buffering mode for an output file.
There are three available modes:
@@ -5606,7 +5662,7 @@ For the last two cases, <code>sizes</code>
specifies the size of the buffer, in bytes.
The default is an appropriate size.
-<p><a name="pdf-file:write"></a><hr /><h3><code>file:write (value1, ...)</code></h3>
+<p><a name="pdf-file:write"></a><hr></hr><h3><code>file:write (value1, ...)</code></h3>
<p>Writes the value of each of its arguments to
the <code>file</code>.
@@ -5618,12 +5674,12 @@ use <a href="#pdf-tostring"><code>tostring</code></a> or <a href="#pdf-string.fo
<p>This library is implemented through table <code>os</code>.
-<p><a name="pdf-os.clock"></a><hr /><h3><code>os.clock ()</code></h3>
+<p><a name="pdf-os.clock"></a><hr></hr><h3><code>os.clock ()</code></h3>
<p>Returns an approximation of the amount in seconds of CPU time
used by the program.
-<p><a name="pdf-os.date"></a><hr /><h3><code>os.date ([format [, time]])</code></h3>
+<p><a name="pdf-os.date"></a><hr></hr><h3><code>os.date ([format [, time]])</code></h3>
<p>Returns a string or a table containing date and time,
formatted according to the given string <code>format</code>.
@@ -5653,13 +5709,13 @@ formatted according to the same rules as the C function <code>strftime</code>.
the host system and on the current locale
(that is, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>).
-<p><a name="pdf-os.difftime"></a><hr /><h3><code>os.difftime (t2, t1)</code></h3>
+<p><a name="pdf-os.difftime"></a><hr></hr><h3><code>os.difftime (t2, t1)</code></h3>
<p>Returns the number of seconds from time <code>t1</code> to time <code>t2</code>.
-In Posix, Windows, and some other systems,
+In POSIX, Windows, and some other systems,
this value is exactly <code>t2</code><em>-</em><code>t1</code>.
-<p><a name="pdf-os.execute"></a><hr /><h3><code>os.execute ([command])</code></h3>
+<p><a name="pdf-os.execute"></a><hr></hr><h3><code>os.execute ([command])</code></h3>
<p>This function is equivalent to the C function <code>system</code>.
It passes <code>command</code> to be executed by an operating system shell.
@@ -5667,32 +5723,32 @@ It returns a status code, which is system-dependent.
If <code>command</code> is absent, then it returns nonzero if a shell is available
and zero otherwise.
-<p><a name="pdf-os.exit"></a><hr /><h3><code>os.exit ([code])</code></h3>
+<p><a name="pdf-os.exit"></a><hr></hr><h3><code>os.exit ([code])</code></h3>
<p>Calls the C function <code>exit</code>,
with an optional <code>code</code>,
to terminate the host program.
The default value for <code>code</code> is the success code.
-<p><a name="pdf-os.getenv"></a><hr /><h3><code>os.getenv (varname)</code></h3>
+<p><a name="pdf-os.getenv"></a><hr></hr><h3><code>os.getenv (varname)</code></h3>
<p>Returns the value of the process environment variable <code>varname</code>,
or <b>nil</b> if the variable is not defined.
-<p><a name="pdf-os.remove"></a><hr /><h3><code>os.remove (filename)</code></h3>
+<p><a name="pdf-os.remove"></a><hr></hr><h3><code>os.remove (filename)</code></h3>
<p>Deletes the file or directory with the given name.
Directories must be empty to be removed.
If this function fails, it returns <b>nil</b>,
plus a string describing the error.
-<p><a name="pdf-os.rename"></a><hr /><h3><code>os.rename (oldname, newname)</code></h3>
+<p><a name="pdf-os.rename"></a><hr></hr><h3><code>os.rename (oldname, newname)</code></h3>
<p>Renames file or directory named <code>oldname</code> to <code>newname</code>.
If this function fails, it returns <b>nil</b>,
plus a string describing the error.
-<p><a name="pdf-os.setlocale"></a><hr /><h3><code>os.setlocale (locale [, category])</code></h3>
+<p><a name="pdf-os.setlocale"></a><hr></hr><h3><code>os.setlocale (locale [, category])</code></h3>
<p>Sets the current locale of the program.
<code>locale</code> is a string specifying a locale;
@@ -5703,7 +5759,7 @@ the default category is <code>"all"</code>.
The function returns the name of the new locale,
or <b>nil</b> if the request cannot be honored.
-<p><a name="pdf-os.time"></a><hr /><h3><code>os.time ([table])</code></h3>
+<p><a name="pdf-os.time"></a><hr></hr><h3><code>os.time ([table])</code></h3>
<p>Returns the current time when called without arguments,
or a time representing the date and time specified by the given table.
@@ -5712,13 +5768,13 @@ and may have fields <code>hour</code>, <code>min</code>, <code>sec</code>, and <
(for a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function).
<p>The returned value is a number, whose meaning depends on your system.
-In Posix, Windows, and some other systems, this number counts the number
+In POSIX, Windows, and some other systems, this number counts the number
of seconds since some given start time (the "epoch").
In other systems, the meaning is not specified,
and the number returned by <code>time</code> can be used only as an argument to
<code>date</code> and <code>difftime</code>.
-<p><a name="pdf-os.tmpname"></a><hr /><h3><code>os.tmpname ()</code></h3>
+<p><a name="pdf-os.tmpname"></a><hr></hr><h3><code>os.tmpname ()</code></h3>
<p>Returns a string with a file name that can
be used for a temporary file.
@@ -5745,7 +5801,7 @@ and therefore can compromise otherwise secure code.
<p>All functions in this library are provided
inside the <code>debug</code> table.
-<p><a name="pdf-debug.debug"></a><hr /><h3><code>debug.debug ()</code></h3>
+<p><a name="pdf-debug.debug"></a><hr></hr><h3><code>debug.debug ()</code></h3>
<p>Enters an interactive mode with the user,
running each string that the user enters.
@@ -5758,17 +5814,17 @@ so that the caller continues its execution.
<p>Note that commands for <code>debug.debug</code> are not lexically nested
within any function, and so have no direct access to local variables.
-<p><a name="pdf-debug.getfenv"></a><hr /><h3><code>debug.getfenv (o)</code></h3>
+<p><a name="pdf-debug.getfenv"></a><hr></hr><h3><code>debug.getfenv (o)</code></h3>
Returns the environment of object <code>o</code>.
-<p><a name="pdf-debug.gethook"></a><hr /><h3><code>debug.gethook ()</code></h3>
+<p><a name="pdf-debug.gethook"></a><hr></hr><h3><code>debug.gethook ()</code></h3>
<p>Returns the current hook settings, as three values:
the current hook function, the current hook mask,
and the current hook count
(as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).
-<p><a name="pdf-debug.getinfo"></a><hr /><h3><code>debug.getinfo (function [, what])</code></h3>
+<p><a name="pdf-debug.getinfo"></a><hr></hr><h3><code>debug.getinfo (function [, what])</code></h3>
<p>Returns a table with information about a function.
You can give the function directly,
@@ -5792,7 +5848,7 @@ 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
about the <a href="#pdf-print"><code>print</code></a> function.
-<p><a name="pdf-debug.getlocal"></a><hr /><h3><code>debug.getlocal (level, local)</code></h3>
+<p><a name="pdf-debug.getlocal"></a><hr></hr><h3><code>debug.getlocal (level, local)</code></h3>
<p>This function returns the name and the value of the local variable
with index <code>local</code> of the function at level <code>level</code> of the stack.
@@ -5807,26 +5863,26 @@ and raises an error when called with a <code>level</code> out of range.
represent internal variables
(loop control variables, temporaries, and C function locals).
-<p><a name="pdf-debug.getmetatable"></a><hr /><h3><code>debug.getmetatable (object)</code></h3>
+<p><a name="pdf-debug.getmetatable"></a><hr></hr><h3><code>debug.getmetatable (object)</code></h3>
<p>Returns the metatable of the given <code>object</code>
or <b>nil</b> if it does not have a metatable.
-<p><a name="pdf-debug.getregistry"></a><hr /><h3><code>debug.getregistry ()</code></h3>
+<p><a name="pdf-debug.getregistry"></a><hr></hr><h3><code>debug.getregistry ()</code></h3>
<p>Returns the registry table (see <a href="#registry">3.5</a>).
-<p><a name="pdf-debug.getupvalue"></a><hr /><h3><code>debug.getupvalue (func, up)</code></h3>
+<p><a name="pdf-debug.getupvalue"></a><hr></hr><h3><code>debug.getupvalue (func, up)</code></h3>
<p>This function returns the name and the value of the upvalue
with index <code>up</code> of the function <code>func</code>.
The function returns <b>nil</b> if there is no upvalue with the given index.
-<p><a name="pdf-debug.setfenv"></a><hr /><h3><code>debug.setfenv (object, table)</code></h3>
+<p><a name="pdf-debug.setfenv"></a><hr></hr><h3><code>debug.setfenv (object, table)</code></h3>
<p>Sets the environment of the given <code>object</code> to the given <code>table</code>.
-<p><a name="pdf-debug.sethook"></a><hr /><h3><code>debug.sethook (hook, mask [, count])</code></h3>
+<p><a name="pdf-debug.sethook"></a><hr></hr><h3><code>debug.sethook (hook, mask [, count])</code></h3>
<p>Sets the given function as a hook.
The string <code>mask</code> and the number <code>count</code> describe
@@ -5859,7 +5915,7 @@ unless the event is <code>"tail return"</code>.
In this case, Lua is only simulating the return,
and a call to <code>getinfo</code> will return invalid data.
-<p><a name="pdf-debug.setlocal"></a><hr /><h3><code>debug.setlocal (level, local, value)</code></h3>
+<p><a name="pdf-debug.setlocal"></a><hr></hr><h3><code>debug.setlocal (level, local, value)</code></h3>
<p>This function assigns the value <code>value</code> to the local variable
with index <code>local</code> of the function at level <code>level</code> of the stack.
@@ -5869,12 +5925,12 @@ and raises an error when called with a <code>level</code> out of range.
(You can call <code>getinfo</code> to check whether the level is valid.)
Otherwise, it returns the name of the local variable.
-<p><a name="pdf-debug.setmetatable"></a><hr /><h3><code>debug.setmetatable (object, table)</code></h3>
+<p><a name="pdf-debug.setmetatable"></a><hr></hr><h3><code>debug.setmetatable (object, table)</code></h3>
-<p>Sets the metatable for the given <code>object</code> to the given id@{table}
+<p>Sets the metatable for the given <code>object</code> to the given <code>table</code>
(which can be <b>nil</b>).
-<p><a name="pdf-debug.setupvalue"></a><hr /><h3><code>debug.setupvalue (func, up, value)</code></h3>
+<p><a name="pdf-debug.setupvalue"></a><hr></hr><h3><code>debug.setupvalue (func, up, value)</code></h3>
<p>This function assigns the value <code>value</code> to the upvalue
with index <code>up</code> of the function <code>func</code>.
@@ -5882,7 +5938,7 @@ The function returns <b>nil</b> if there is no upvalue
with the given index.
Otherwise, it returns the name of the upvalue.
-<p><a name="pdf-debug.traceback"></a><hr /><h3><code>debug.traceback ([message])</code></h3>
+<p><a name="pdf-debug.traceback"></a><hr></hr><h3><code>debug.traceback ([message])</code></h3>
<p>Returns a string with a traceback of the call stack.
An optional <code>message</code> string is appended
@@ -5969,7 +6025,7 @@ by issuing a different prompt.
<p>If the global variable <code>_PROMPT</code> contains a string,
then its value is used as the prompt.
Similarly, if the global variable <code>_PROMPT2</code> contains a string,
-it its value is used as the secondary prompt
+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,
@@ -6001,7 +6057,7 @@ then
</pre>
is a more portable solution.)
-<p><hr />
+<p><hr></hr>
<p><h1>Incompatibilities with the Previous Version</h1>
@@ -6110,7 +6166,7 @@ Function <code>luaL_openlib</code> was replaced by <a href="#luaL_register"><cod
<p>Here is the complete syntax of Lua in extended BNF.
-It does not describe operator priorities nor some syntactical restrictions,
+It does not describe operator priorities or some syntactical restrictions,
such as <b>return</b> and <b>break</b> statements
can only appear as the <em>last</em> statement of a block.
diff --git a/etc/Makefile b/etc/Makefile
index 2dfc937c..02f09423 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -8,14 +8,15 @@ SRC= $(TOP)/src
TST= $(TOP)/test
CC= gcc
-CFLAGS= -O2 -Wall $(MYCFLAGS)
-MYCFLAGS= -ansi -I$(INC)
+CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS)
+MYCFLAGS=
MYLDFLAGS= -Wl,-E
-MYLIBS= -lm -ldl
+MYLIBS= -lm
+#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
RM= rm -f
-all:
- @echo 'choose a target: min noparser one clean'
+default:
+ @echo 'Please choose a target: min noparser one clean'
min: min.c
$(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)
@@ -31,5 +32,13 @@ one:
$(CC) $(CFLAGS) all.c $(MYLIBS)
./a.out $(TST)/hello.lua
+strict:
+ -$(BIN)/lua -e 'print(a);b=2'
+ -$(BIN)/lua -lstrict -e 'print(a)'
+ -$(BIN)/lua -e 'function f() b=2 end f()'
+ -$(BIN)/lua -lstrict -e 'function f() b=2 end f()'
+
clean:
- $(RM) noparser.o a.out core core.* *.o luac.out
+ $(RM) a.out core core.* *.o luac.out
+
+.PHONY: default min noparser one strict clean
diff --git a/etc/README b/etc/README
index 5e42ec56..ad9ca6ab 100644
--- a/etc/README
+++ b/etc/README
@@ -1,9 +1,12 @@
This directory contains some useful files and code.
Unlike the code in ../src, everything here is in the public domain.
+If any of the makes fail, you're probably not using the same libraries
+used to build Lua. Set MYLIBS in Makefile accordingly.
+
all.c
Full Lua interpreter in a single file.
- Do "make one".
+ Do "make one" for a demo.
lua.hpp
Lua header files for C++ using 'extern "C"'.
@@ -21,11 +24,13 @@ luavs.bat
min.c
A minimal Lua interpreter.
Good for learning and for starting your own.
+ Do "make min" for a demo.
noparser.c
Linking with noparser.o avoids loading the parsing modules in lualib.a.
- Do "make noparser" to see a demo.
+ Do "make noparser" for a demo.
strict.lua
Traps uses of undeclared global variables.
+ Do "make strict" for a demo.
diff --git a/etc/lua.pc b/etc/lua.pc
index f0d6e2ff..5fd2b1ed 100644
--- a/etc/lua.pc
+++ b/etc/lua.pc
@@ -1,19 +1,19 @@
# lua.pc -- pkg-config data for Lua
# vars from install Makefile
-# grep '^INSTALL_.*=' ../Makefile
-INSTALL_TOP= /usr/local
-INSTALL_BIN= $(INSTALL_TOP)/bin
-INSTALL_INC= $(INSTALL_TOP)/include
-INSTALL_LIB= $(INSTALL_TOP)/lib
-INSTALL_MAN= $(INSTALL_TOP)/man/man1
-INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
-INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
# grep '^V=' ../Makefile
V= 5.1
-prefix=${INSTALL_TOP}
+# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
+prefix= /usr/local
+INSTALL_BIN= ${prefix}/bin
+INSTALL_INC= ${prefix}/include
+INSTALL_LIB= ${prefix}/lib
+INSTALL_MAN= ${prefix}/man/man1
+INSTALL_LMOD= ${prefix}/share/lua/${V}
+INSTALL_CMOD= ${prefix}/lib/lua/${V}
+
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
diff --git a/src/Makefile b/src/Makefile
index 13d0d497..fb69ce1e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -107,6 +107,8 @@ posix:
solaris:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
+# list targets that do not create files (but not all makes understand .PHONY)
+.PHONY: all $(PLATS) default o a clean depend echo none
# DO NOT DELETE
diff --git a/src/liolib.c b/src/liolib.c
index fd7894c9..bb3b5194 100644
--- a/src/liolib.c
+++ b/src/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp $
+** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -283,7 +283,7 @@ static int read_line (lua_State *L, FILE *f) {
return (lua_strlen(L, -1) > 0); /* check whether read something */
}
l = strlen(p);
- if (p[l-1] != '\n')
+ if (l == 0 || p[l-1] != '\n')
luaL_addsize(&b, l);
else {
luaL_addsize(&b, l - 1); /* do not include `eol' */
diff --git a/src/llex.c b/src/llex.c
index 9918b2f4..f3022df5 100644
--- a/src/llex.c
+++ b/src/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.18 2006/01/23 20:06:19 roberto Exp $
+** $Id: llex.c,v 2.19 2006/02/06 18:28:16 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -166,7 +166,7 @@ static int check_next (LexState *ls, const char *set) {
static void buffreplace (LexState *ls, char from, char to) {
- int n = luaZ_bufflen(ls->buff);
+ size_t n = luaZ_bufflen(ls->buff);
char *p = luaZ_buffer(ls->buff);
while (n--)
if (p[n] == from) p[n] = to;
diff --git a/src/loslib.c b/src/loslib.c
index 235377e4..509d7b72 100644
--- a/src/loslib.c
+++ b/src/loslib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loslib.c,v 1.16 2005/12/22 16:19:56 roberto Exp $
+** $Id: loslib.c,v 1.17 2006/01/27 13:54:31 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/
@@ -21,6 +21,7 @@
static int os_pushresult (lua_State *L, int i, const char *filename) {
+ int en = errno; /* calls to Lua API may change this value */
if (i) {
lua_pushboolean(L, 1);
return 1;
@@ -28,10 +29,10 @@ static int os_pushresult (lua_State *L, int i, const char *filename) {
else {
lua_pushnil(L);
if (filename)
- lua_pushfstring(L, "%s: %s", filename, strerror(errno));
+ lua_pushfstring(L, "%s: %s", filename, strerror(en));
else
- lua_pushfstring(L, "%s", strerror(errno));
- lua_pushinteger(L, errno);
+ lua_pushfstring(L, "%s", strerror(en));
+ lua_pushinteger(L, en);
return 3;
}
}
diff --git a/src/lstate.h b/src/lstate.h
index e8bc15ab..d296a4ca 100644
--- a/src/lstate.h
+++ b/src/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.23 2005/07/09 13:22:34 roberto Exp $
+** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
@@ -49,8 +49,8 @@ typedef struct CallInfo {
StkId base; /* base for this function */
StkId func; /* function index in the stack */
StkId top; /* top for this function */
- int nresults; /* expected number of results from this function */
const Instruction *savedpc;
+ int nresults; /* expected number of results from this function */
int tailcalls; /* number of tail calls lost under this entry */
} CallInfo;
@@ -71,9 +71,9 @@ typedef struct global_State {
void *ud; /* auxiliary data to `frealloc' */
lu_byte currentwhite;
lu_byte gcstate; /* state of garbage collector */
+ int sweepstrgc; /* position of sweep in `strt' */
GCObject *rootgc; /* list of all collectable objects */
GCObject **sweepgc; /* position of sweep in `rootgc' */
- int sweepstrgc; /* position of sweep in `strt' */
GCObject *gray; /* list of gray objects */
GCObject *grayagain; /* list of objects to be traversed atomically */
GCObject *weak; /* list of weak tables (to be cleared) */
@@ -99,6 +99,7 @@ typedef struct global_State {
*/
struct lua_State {
CommonHeader;
+ lu_byte status;
StkId top; /* first free slot in the stack */
StkId base; /* base of current function */
global_State *l_G;
@@ -106,14 +107,13 @@ struct lua_State {
const Instruction *savedpc; /* `savedpc' of current function */
StkId stack_last; /* last free slot in the stack */
StkId stack; /* stack base */
- int stacksize;
CallInfo *end_ci; /* points after end of ci array*/
CallInfo *base_ci; /* array of CallInfo's */
+ int stacksize;
int size_ci; /* size of array `base_ci' */
unsigned short nCcalls; /* number of nested C calls */
lu_byte hookmask;
lu_byte allowhook;
- lu_byte status;
int basehookcount;
int hookcount;
lua_Hook hook;
diff --git a/src/luaconf.h b/src/luaconf.h
index 56705985..3f3e2bbe 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.79 2006/01/23 19:51:43 roberto Exp $
+** $Id: luaconf.h,v 1.80 2006/01/27 13:54:39 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -541,7 +541,7 @@
*/
/* On a Pentium, resort to a trick */
-#if !defined(LUA_ANSI) && !defined(__SSE2__) && \
+#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
(defined(__i386) || defined (_M_IX86) || defined(__i386__))
union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \