History

Lua 5.1-rc3

Lua Team committed 20 years ago

Commit 010ebd01 parent 2fee0d617 files · +480 −377Browse files

Unified · Split

17 files
  1. HISTORY +1 −1
  2. INSTALL +3 −0
  3. MANIFEST +14 −14
  4. Makefile +24 −11
  5. doc/contents.html +21 −7
  6. doc/lua.html +1 −1
  7. doc/luac.html +5 −5
  8. doc/manual.html +362 −306
  9. etc/Makefile +15 −6
  10. etc/README +7 −2
  11. etc/lua.pc +9 −9
  12. src/Makefile +2 −0
  13. src/liolib.c +2 −2
  14. src/llex.c +2 −2
  15. src/loslib.c +5 −4
  16. src/lstate.h +5 −5
  17. src/luaconf.h +2 −2
HISTORY+1−1
@@ -14,7 +14,7 @@ HISTORY for Lua 5.1 · 13 unmodified lines
14 API:14 API:
15 + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.15 + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
16 + user supplies memory allocator (lua_open becomes lua_newstate).16 + user supplies memory allocator (lua_open becomes lua_newstate).
17 + luaopen_* functionst be called through Lua.17 + luaopen_* functionst must be called through Lua.
18 Implementation:18 Implementation:
19 + new configuration scheme via luaconf.h.19 + new configuration scheme via luaconf.h.
20 + incremental garbage collection.20 + incremental garbage collection.
INSTALL+3−0
@@ -23,6 +23,9 @@ INSTALL for Lua 5.1 · 22 unmodified lines
23 place and the way to install files are defined in Makefile. You must23 place and the way to install files are defined in Makefile. You must
24 have the right permissions to install files.24 have the right permissions to install files.
25 25
26 If you want to build and install Lua in one step, do "make xxx install",
27 where xxx is your platform name.
28
26 If you want to install Lua locally, then do "make local". This will29 If you want to install Lua locally, then do "make local". This will
27 create directories bin, include, lib, man, and install Lua there as30 create directories bin, include, lib, man, and install Lua there as
28 follows:31 follows:
MANIFEST+14−14
@@ -1,33 +1,34 @@
1MANIFEST contents of Lua 5.1 distribution on Tue Jan 24 16:12:03 BRST 20061MANIFEST contents of Lua 5.1 distribution on Tue Feb 7 15:05:04 BRST 2006
2lua-5.12lua-5.1
3lua-5.1/COPYRIGHT3lua-5.1/COPYRIGHT
4lua-5.1/HISTORY
5lua-5.1/INSTALL
6lua-5.1/MANIFEST
7lua-5.1/Makefile
8lua-5.1/README
4lua-5.1/doc9lua-5.1/doc
5lua-5.1/doc/contents.html10lua-5.1/doc/contents.html
6lua-5.1/doc/logo.gif11lua-5.1/doc/logo.gif
7lua-5.1/doc/lua.112lua-5.1/doc/lua.1
8lua-5.1/doc/luac.1
9lua-5.1/doc/luac.html
10lua-5.1/doc/lua.css13lua-5.1/doc/lua.css
11lua-5.1/doc/lua.html14lua-5.1/doc/lua.html
15lua-5.1/doc/luac.1
16lua-5.1/doc/luac.html
12lua-5.1/doc/manual.html17lua-5.1/doc/manual.html
13lua-5.1/doc/readme.html18lua-5.1/doc/readme.html
14lua-5.1/etc19lua-5.1/etc
20lua-5.1/etc/Makefile
21lua-5.1/etc/README
15lua-5.1/etc/all.c22lua-5.1/etc/all.c
16lua-5.1/etc/lua.hpp23lua-5.1/etc/lua.hpp
17lua-5.1/etc/lua.ico24lua-5.1/etc/lua.ico
18lua-5.1/etc/lua.pc25lua-5.1/etc/lua.pc
19lua-5.1/etc/luavs.bat26lua-5.1/etc/luavs.bat
20lua-5.1/etc/Makefile
21lua-5.1/etc/min.c27lua-5.1/etc/min.c
22lua-5.1/etc/noparser.c28lua-5.1/etc/noparser.c
23lua-5.1/etc/README
24lua-5.1/etc/strict.lua29lua-5.1/etc/strict.lua
25lua-5.1/HISTORY
26lua-5.1/INSTALL
27lua-5.1/Makefile
28lua-5.1/MANIFEST
29lua-5.1/README
30lua-5.1/src30lua-5.1/src
31lua-5.1/src/Makefile
31lua-5.1/src/lapi.c32lua-5.1/src/lapi.c
32lua-5.1/src/lapi.h33lua-5.1/src/lapi.h
33lua-5.1/src/lauxlib.c34lua-5.1/src/lauxlib.c
@@ -72,9 +73,9 @@ lua-5.1/src/ltablib.c · 38 unmodified lines
72lua-5.1/src/ltm.c73lua-5.1/src/ltm.c
73lua-5.1/src/ltm.h74lua-5.1/src/ltm.h
74lua-5.1/src/lua.c75lua-5.1/src/lua.c
76lua-5.1/src/lua.h
75lua-5.1/src/luac.c77lua-5.1/src/luac.c
76lua-5.1/src/luaconf.h78lua-5.1/src/luaconf.h
77lua-5.1/src/lua.h
78lua-5.1/src/lualib.h79lua-5.1/src/lualib.h
79lua-5.1/src/lundump.c80lua-5.1/src/lundump.c
80lua-5.1/src/lundump.h81lua-5.1/src/lundump.h
@@ -82,22 +83,21 @@ lua-5.1/src/lvm.c · 1 unmodified line
82lua-5.1/src/lvm.h83lua-5.1/src/lvm.h
83lua-5.1/src/lzio.c84lua-5.1/src/lzio.c
84lua-5.1/src/lzio.h85lua-5.1/src/lzio.h
85lua-5.1/src/Makefile
86lua-5.1/src/print.c86lua-5.1/src/print.c
87lua-5.1/test87lua-5.1/test
88lua-5.1/test/README
88lua-5.1/test/bisect.lua89lua-5.1/test/bisect.lua
89lua-5.1/test/cf.lua90lua-5.1/test/cf.lua
90lua-5.1/test/echo.lua91lua-5.1/test/echo.lua
91lua-5.1/test/env.lua92lua-5.1/test/env.lua
92lua-5.1/test/factorial.lua93lua-5.1/test/factorial.lua
93lua-5.1/test/fibfor.lua
94lua-5.1/test/fib.lua94lua-5.1/test/fib.lua
95lua-5.1/test/fibfor.lua
95lua-5.1/test/globals.lua96lua-5.1/test/globals.lua
96lua-5.1/test/hello.lua97lua-5.1/test/hello.lua
97lua-5.1/test/life.lua98lua-5.1/test/life.lua
98lua-5.1/test/luac.lua99lua-5.1/test/luac.lua
99lua-5.1/test/printf.lua100lua-5.1/test/printf.lua
100lua-5.1/test/README
101lua-5.1/test/readonly.lua101lua-5.1/test/readonly.lua
102lua-5.1/test/sieve.lua102lua-5.1/test/sieve.lua
103lua-5.1/test/sort.lua103lua-5.1/test/sort.lua
Makefile+24−11
@@ -22,10 +22,17 @@ INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V · 21 unmodified lines
22# How to install. You may prefer "install" instead of "cp" if you have it.22# How to install. You may prefer "install" instead of "cp" if you have it.
23# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.23# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
24#24#
25INSTALL_EXEC= cp25INSTALL_EXEC= $(CP)
26INSTALL_DATA= cp26INSTALL_DATA= $(CP)
27#INSTALL_EXEC= install -m 075527#INSTALL_EXEC= $(INSTALL) -m 0755
28#INSTALL_DATA= install -m 064428#INSTALL_DATA= $(INSTALL) -m 0644
29
30# Utilities.
31CP= cp
32FIND= find
33INSTALL= install
34MKDIR= mkdir
35RANLIB= ranlib
29 36
30# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========37# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
31 38
@@ -46,15 +53,16 @@ all: $(PLAT) · 14 unmodified lines
46$(PLATS) clean:53$(PLATS) clean:
47 cd src; $(MAKE) $@54 cd src; $(MAKE) $@
48 55
49test: all56test: dummy
50 src/lua test/hello.lua57 src/lua test/hello.lua
51 58
52install:59install: dummy
53 cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)60 cd src; $(MKDIR) -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
54 cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)61 cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
55 cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)62 cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
56 cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)63 cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
57 cd doc; $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)64 cd doc; $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
65# $(RANLIB) $(INSTALL_LIB)/$(TO_LIB)
58 66
59local:67local:
60 $(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"68 $(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"
@@ -62,6 +70,9 @@ local: · 1 unmodified line
62none:70none:
63 @echo "Please choose a platform: $(PLATS)"71 @echo "Please choose a platform: $(PLATS)"
64 72
73# make may get confused with test/ and INSTALL in a case-insensitive OS
74dummy:
75
65# echo config parameters76# echo config parameters
66echo:77echo:
67 @echo ""78 @echo ""
@@ -77,11 +88,10 @@ echo: · 9 unmodified lines
77 @echo "INSTALL_INC = $(INSTALL_INC)"88 @echo "INSTALL_INC = $(INSTALL_INC)"
78 @echo "INSTALL_LIB = $(INSTALL_LIB)"89 @echo "INSTALL_LIB = $(INSTALL_LIB)"
79 @echo "INSTALL_MAN = $(INSTALL_MAN)"90 @echo "INSTALL_MAN = $(INSTALL_MAN)"
80 @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
81 @echo "INSTALL_DATA = $(INSTALL_DATA)"
82 @echo "INSTALL_LMOD = $(INSTALL_LMOD)"91 @echo "INSTALL_LMOD = $(INSTALL_LMOD)"
83 @echo "INSTALL_CMOD = $(INSTALL_CMOD)"92 @echo "INSTALL_CMOD = $(INSTALL_CMOD)"
84 @echo "INSTALL_CMOD = $(INSTALL_CMOD)"93 @echo "INSTALL_EXEC = $(INSTALL_EXEC)"
94 @echo "INSTALL_DATA = $(INSTALL_DATA)"
85 @echo ""95 @echo ""
86 @echo "See also src/luaconf.h ."96 @echo "See also src/luaconf.h ."
87 @echo ""97 @echo ""
@@ -104,6 +114,9 @@ lecho: · 16 unmodified lines
104 114
105# show what has changed since we unpacked115# show what has changed since we unpacked
106newer:116newer:
107 @find . -newer MANIFEST -type f117 @$(FIND) . -newer MANIFEST -type f
118
119# list targets that do not create files (but not all makes understand .PHONY)
120.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho newer
108 121
109# (end of Makefile)122# (end of Makefile)
doc/contents.html+21−7
@@ -154,24 +154,31 @@ Lua 5.1 Reference Manual · 153 unmodified lines
154<A HREF="manual.html#pdf-math.abs">math.abs</A><BR>154<A HREF="manual.html#pdf-math.abs">math.abs</A><BR>
155<A HREF="manual.html#pdf-math.acos">math.acos</A><BR>155<A HREF="manual.html#pdf-math.acos">math.acos</A><BR>
156<A HREF="manual.html#pdf-math.asin">math.asin</A><BR>156<A HREF="manual.html#pdf-math.asin">math.asin</A><BR>
157<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
158<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>157<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
158<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
159<A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>159<A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>
160<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
161<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>160<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
162<A HREF="manual.html#pdf-math.def">math.def</A><BR>161<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
162<A HREF="manual.html#pdf-math.deg">math.deg</A><BR>
163<A HREF="manual.html#pdf-math.exp">math.exp</A><BR>163<A HREF="manual.html#pdf-math.exp">math.exp</A><BR>
164<A HREF="manual.html#pdf-math.floor">math.floor</A><BR>164<A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
165<A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR>165<A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR>
166<A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
166<A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>167<A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>
167<A HREF="manual.html#pdf-math.log">math.log</A><BR>
168<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>168<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
169<A HREF="manual.html#pdf-math.log">math.log</A><BR>
170<A HREF="manual.html#pdf-math.max">math.max</A><BR>
171<A HREF="manual.html#pdf-math.min">math.min</A><BR>
172<A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
169<A HREF="manual.html#pdf-math.pow">math.pow</A><BR>173<A HREF="manual.html#pdf-math.pow">math.pow</A><BR>
170<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>174<A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
175<A HREF="manual.html#pdf-math.random">math.random</A><BR>
176<A HREF="manual.html#pdf-math.randomseed">math.randomseed</A><BR>
171<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>177<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
178<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
172<A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>179<A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
173<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
174<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>180<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
181<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
175<A HREF="manual.html#pdf-module">module</A><BR>182<A HREF="manual.html#pdf-module">module</A><BR>
176<A HREF="manual.html#pdf-next">next</A><BR>183<A HREF="manual.html#pdf-next">next</A><BR>
177<A HREF="manual.html#pdf-os.clock">os.clock</A><BR>184<A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
@@ -225,6 +232,7 @@ Lua 5.1 Reference Manual · 47 unmodified lines
225<A HREF="manual.html#pdf-type">type</A><BR>232<A HREF="manual.html#pdf-type">type</A><BR>
226<A HREF="manual.html#pdf-unpack">unpack</A><BR>233<A HREF="manual.html#pdf-unpack">unpack</A><BR>
227<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>234<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
235
228</TD>236</TD>
229<TD>237<TD>
230<H3>API</H3>238<H3>API</H3>
@@ -251,6 +259,7 @@ Lua 5.1 Reference Manual · 20 unmodified lines
251<A HREF="manual.html#lua_getallocf">lua_getallocf</A><BR>259<A HREF="manual.html#lua_getallocf">lua_getallocf</A><BR>
252<A HREF="manual.html#lua_getfenv">lua_getfenv</A><BR>260<A HREF="manual.html#lua_getfenv">lua_getfenv</A><BR>
253<A HREF="manual.html#lua_getfield">lua_getfield</A><BR>261<A HREF="manual.html#lua_getfield">lua_getfield</A><BR>
262<A HREF="manual.html#lua_getglobal">lua_getglobal</A><BR>
254<A HREF="manual.html#lua_gethook">lua_gethook</A><BR>263<A HREF="manual.html#lua_gethook">lua_gethook</A><BR>
255<A HREF="manual.html#lua_gethookcount">lua_gethookcount</A><BR>264<A HREF="manual.html#lua_gethookcount">lua_gethookcount</A><BR>
256<A HREF="manual.html#lua_gethookmask">lua_gethookmask</A><BR>265<A HREF="manual.html#lua_gethookmask">lua_gethookmask</A><BR>
@@ -300,12 +309,14 @@ Lua 5.1 Reference Manual · 43 unmodified lines
300<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>309<A HREF="manual.html#lua_rawgeti">lua_rawgeti</A><BR>
301<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>310<A HREF="manual.html#lua_rawset">lua_rawset</A><BR>
302<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>311<A HREF="manual.html#lua_rawseti">lua_rawseti</A><BR>
312<A HREF="manual.html#lua_register">lua_register</A><BR>
303<A HREF="manual.html#lua_remove">lua_remove</A><BR>313<A HREF="manual.html#lua_remove">lua_remove</A><BR>
304<A HREF="manual.html#lua_replace">lua_replace</A><BR>314<A HREF="manual.html#lua_replace">lua_replace</A><BR>
305<A HREF="manual.html#lua_resume">lua_resume</A><BR>315<A HREF="manual.html#lua_resume">lua_resume</A><BR>
306<A HREF="manual.html#lua_setallocf">lua_setallocf</A><BR>316<A HREF="manual.html#lua_setallocf">lua_setallocf</A><BR>
307<A HREF="manual.html#lua_setfenv">lua_setfenv</A><BR>317<A HREF="manual.html#lua_setfenv">lua_setfenv</A><BR>
308<A HREF="manual.html#lua_setfield">lua_setfield</A><BR>318<A HREF="manual.html#lua_setfield">lua_setfield</A><BR>
319<A HREF="manual.html#lua_setglobal">lua_setglobal</A><BR>
309<A HREF="manual.html#lua_sethook">lua_sethook</A><BR>320<A HREF="manual.html#lua_sethook">lua_sethook</A><BR>
310<A HREF="manual.html#lua_setlocal">lua_setlocal</A><BR>321<A HREF="manual.html#lua_setlocal">lua_setlocal</A><BR>
311<A HREF="manual.html#lua_setmetatable">lua_setmetatable</A><BR>322<A HREF="manual.html#lua_setmetatable">lua_setmetatable</A><BR>
@@ -326,6 +337,7 @@ Lua 5.1 Reference Manual · 14 unmodified lines
326<A HREF="manual.html#lua_typename">lua_typename</A><BR>337<A HREF="manual.html#lua_typename">lua_typename</A><BR>
327<A HREF="manual.html#lua_xmove">lua_xmove</A><BR>338<A HREF="manual.html#lua_xmove">lua_xmove</A><BR>
328<A HREF="manual.html#lua_yield">lua_yield</A><BR>339<A HREF="manual.html#lua_yield">lua_yield</A><BR>
340
329</TD>341</TD>
330<TD>342<TD>
331<H3>Auxiliary library</H3>343<H3>Auxiliary library</H3>
@@ -360,6 +372,7 @@ Lua 5.1 Reference Manual · 28 unmodified lines
360<A HREF="manual.html#luaL_loadstring">luaL_loadstring</A><BR>372<A HREF="manual.html#luaL_loadstring">luaL_loadstring</A><BR>
361<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>373<A HREF="manual.html#luaL_newmetatable">luaL_newmetatable</A><BR>
362<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>374<A HREF="manual.html#luaL_newstate">luaL_newstate</A><BR>
375<A HREF="manual.html#luaL_openlibs">luaL_openlibs</A><BR>
363<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>376<A HREF="manual.html#luaL_optint">luaL_optint</A><BR>
364<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>377<A HREF="manual.html#luaL_optinteger">luaL_optinteger</A><BR>
365<A HREF="manual.html#luaL_optlong">luaL_optlong</A><BR>378<A HREF="manual.html#luaL_optlong">luaL_optlong</A><BR>
@@ -374,6 +387,7 @@ Lua 5.1 Reference Manual · 8 unmodified lines
374<A HREF="manual.html#luaL_typerror">luaL_typerror</A><BR>387<A HREF="manual.html#luaL_typerror">luaL_typerror</A><BR>
375<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>388<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>
376<A HREF="manual.html#luaL_where">luaL_where</A><BR>389<A HREF="manual.html#luaL_where">luaL_where</A><BR>
390
377</TD>391</TD>
378</TR>392</TR>
379</TABLE>393</TABLE>
@@ -382,7 +396,7 @@ Lua 5.1 Reference Manual · 2 unmodified lines
382<HR>396<HR>
383<SMALL>397<SMALL>
384Last update:398Last update:
385Tue Jan 10 10:10:22 BRST 2006399Tue Feb 7 14:37:59 BRST 2006
386</SMALL>400</SMALL>
387 401
388</BODY>402</BODY>
doc/lua.html+1−1
@@ -149,7 +149,7 @@ is executed. · 148 unmodified lines
149<P>149<P>
150<B>-l </B><I>name</I>150<B>-l </B><I>name</I>
151call151call
152<B>require(' name</B><I>')</I>152<B>require</B>('<I>name</I>')
153before executing153before executing
154<I>script</I>.154<I>script</I>.
155Typically used to load libraries.155Typically used to load libraries.
doc/luac.html+5−5
@@ -28,13 +28,13 @@ protecting source code from accidental user changes, · 27 unmodified lines
28and28and
29off-line syntax checking.29off-line syntax checking.
30<P>30<P>
31Pre-compiling does not imply faster execution31Precompiling does not imply faster execution
32because in Lua chunks are always compiled into bytecodes before being executed.32because in Lua chunks are always compiled into bytecodes before being executed.
33<B>luac</B>33<B>luac</B>
34simply allows those bytecodes to be saved in a file for later execution.34simply allows those bytecodes to be saved in a file for later execution.
35<P>35<P>
36Pre-compiled chunks are not necessarily smaller than the corresponding source.36Precompiled chunks are not necessarily smaller than the corresponding source.
37The main goal in pre-compiling is faster loading.37The main goal in precompiling is faster loading.
38<P>38<P>
39The binary files created by39The binary files created by
40<B>luac</B>40<B>luac</B>
@@ -54,9 +54,9 @@ In the command line, · 13 unmodified lines
54you can mix54you can mix
55text files containing Lua source and55text files containing Lua source and
56binary files containing precompiled chunks.56binary files containing precompiled chunks.
57This is useful to combine several precompiled chunks,57This is useful because several precompiled chunks,
58even from different (but compatible) platforms,58even from different (but compatible) platforms,
59into a single precompiled chunk.59can be combined into a single precompiled chunk.
60<P>60<P>
61You can use61You can use
62<B>'-'</B>62<B>'-'</B>
doc/manual.html+362−306
@@ -8,9 +8,9 @@ · 7 unmodified lines
8 8
9<body bgcolor="#FFFFFF">9<body bgcolor="#FFFFFF">
10 10
11<hr />11<hr></hr>
12<h1>12<h1>
13<a href="http://www.lua.org/home.html"><img src="logo.gif" alt="[Lua logo]" border="0" /></a>13<a href="http://www.lua.org/home.html"><img src="logo.gif" alt="[Lua logo]" border="0"></img></a>
14Lua 5.1 Reference Manual14Lua 5.1 Reference Manual
15</h1>15</h1>
16 16
@@ -20,7 +20,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes · 3 unmodified lines
20<a href="http://www.lua.org/copyright.html">Copyright</a>20<a href="http://www.lua.org/copyright.html">Copyright</a>
21&copy; 2006 Lua.org, PUC-Rio. All rights reserved.21&copy; 2006 Lua.org, PUC-Rio. All rights reserved.
22</small>22</small>
23<hr />23<hr></hr>
24 24
25<p>25<p>
26<p>26<p>
@@ -302,7 +302,7 @@ Any arithmetic operation applied to a string tries to convert · 275 unmodified lines
302that string to a number, following the usual conversion rules.302that string to a number, following the usual conversion rules.
303Conversely, whenever a number is used where a string is expected,303Conversely, whenever a number is used where a string is expected,
304the number is converted to a string, in a reasonable format.304the number is converted to a string, in a reasonable format.
305For complete control of how numbers are converted to strings,305For complete control over how numbers are converted to strings,
306use the <code>format</code> function from the string library306use the <code>format</code> function from the string library
307(see <a href="#pdf-string.format"><code>string.format</code></a>).307(see <a href="#pdf-string.format"><code>string.format</code></a>).
308 308
@@ -1554,9 +1554,9 @@ They are used as the default environment for other Lua functions · 1245 unmodified lines
1554created by that function.1554created by that function.
1555 1555
1556<p>You can change the environment of a Lua function or the1556<p>You can change the environment of a Lua function or the
1557running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>.1557running thread by calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
1558You can get the environment of a Lua function or the running thread1558You can get the environment of a Lua function or the running thread
1559calling <a href="#pdf-getfenv"><code>getfenv</code></a>.1559by calling <a href="#pdf-getfenv"><code>getfenv</code></a>.
1560To manipulate the environment of other objects1560To manipulate the environment of other objects
1561(userdata, C functions, other threads) you must1561(userdata, C functions, other threads) you must
1562use the C API.1562use the C API.
@@ -1565,7 +1565,7 @@ use the C API. · 2 unmodified lines
1565 1565
1566<p>Lua performs automatic memory management.1566<p>Lua performs automatic memory management.
1567That means that1567That means that
1568you do not have to worry neither about allocating memory for new objects1568you have to worry neither about allocating memory for new objects
1569nor about freeing it when the objects are no longer needed.1569nor about freeing it when the objects are no longer needed.
1570Lua manages memory automatically by running1570Lua manages memory automatically by running
1571a <em>garbage collector</em> from time to time1571a <em>garbage collector</em> from time to time
@@ -1577,7 +1577,7 @@ tables, userdata, functions, threads, and strings. · 5 unmodified lines
1577<p>Lua implements an incremental mark-and-sweep collector.1577<p>Lua implements an incremental mark-and-sweep collector.
1578It uses two numbers to control its garbage-collection cycles:1578It uses two numbers to control its garbage-collection cycles:
1579the <em>garbage-collector pause</em> and1579the <em>garbage-collector pause</em> and
1580the <em>garbage-collector multiplier</em>.1580the <em>garbage-collector step multiplier</em>.
1581 1581
1582<p>The garbage-collector pause1582<p>The garbage-collector pause
1583controls how long the collector waits before starting a new cycle.1583controls how long the collector waits before starting a new cycle.
@@ -1587,7 +1587,7 @@ start a new cycle. · 3 unmodified lines
1587A value of 2 means that the collector waits more or less to double1587A value of 2 means that the collector waits more or less to double
1588the total memory in use before starting a new cycle.1588the total memory in use before starting a new cycle.
1589 1589
1590<p>The garbage-collector multiplier1590<p>The step multiplier
1591controls the relative speed of the collector relative to1591controls the relative speed of the collector relative to
1592memory allocation.1592memory allocation.
1593Larger values make the collector more aggressive but also increases1593Larger 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. · 304 unmodified lines
1898 1898
1899<p>The integer keys in the registry are used by the reference mechanism,1899<p>The integer keys in the registry are used by the reference mechanism,
1900implemented by the auxiliary library,1900implemented by the auxiliary library,
1901and therefore should not be used by other purposes.1901and therefore should not be used for other purposes.
1902 1902
1903<p><a name="3.6"></a><h2>3.6 - Error Handling in C</h2>1903<p><a name="3.6"></a><h2>3.6 - Error Handling in C</h2>
1904 1904
@@ -1930,7 +1930,7 @@ so they never raise an error: · 25 unmodified lines
1930alphabetical order.1930alphabetical order.
1931 1931
1932<p><a name="lua_Alloc"></a>1932<p><a name="lua_Alloc"></a>
1933<hr /><h3><code>lua_Alloc</code></h3>1933<hr></hr><h3><code>lua_Alloc</code></h3>
1934<pre>1934<pre>
1935 typedef void * (*lua_Alloc) (void *ud,1935 typedef void * (*lua_Alloc) (void *ud,
1936 void *ptr,1936 void *ptr,
@@ -1979,7 +1979,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { · 42 unmodified lines
1979</pre>1979</pre>
1980 1980
1981<p><a name="lua_atpanic"></a>1981<p><a name="lua_atpanic"></a>
1982<hr /><h3><code>lua_atpanic</code></h3>1982<hr></hr><h3><code>lua_atpanic</code></h3>
1983<pre>1983<pre>
1984 lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);1984 lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
1985</pre>1985</pre>
@@ -1997,7 +1997,7 @@ never returning (e.g., doing a long jump). · 11 unmodified lines
1997<p>The panic function can access the error message at the top of the stack.1997<p>The panic function can access the error message at the top of the stack.
1998 1998
1999<p><a name="lua_call"></a>1999<p><a name="lua_call"></a>
2000<hr /><h3><code>lua_call</code></h3>2000<hr></hr><h3><code>lua_call</code></h3>
2001<pre>2001<pre>
2002 void lua_call (lua_State *L, int nargs, int nresults);2002 void lua_call (lua_State *L, int nargs, int nresults);
2003</pre>2003</pre>
@@ -2047,7 +2047,7 @@ at its end, the stack is back to its original configuration. · 43 unmodified lines
2047This is considered good programming practice.2047This is considered good programming practice.
2048 2048
2049<p><a name="lua_CFunction"></a>2049<p><a name="lua_CFunction"></a>
2050<hr /><h3><code>lua_CFunction</code></h3>2050<hr></hr><h3><code>lua_CFunction</code></h3>
2051<pre>2051<pre>
2052 typedef int (*lua_CFunction) (lua_State *L);2052 typedef int (*lua_CFunction) (lua_State *L);
2053</pre>2053</pre>
@@ -2093,20 +2093,20 @@ of numerical arguments and returns their average and sum: · 39 unmodified lines
2093</pre>2093</pre>
2094 2094
2095<p><a name="lua_checkstack"></a>2095<p><a name="lua_checkstack"></a>
2096<hr /><h3><code>lua_checkstack</code></h3>2096<hr></hr><h3><code>lua_checkstack</code></h3>
2097<pre>2097<pre>
2098 int lua_checkstack (lua_State *L, int extra);2098 int lua_checkstack (lua_State *L, int extra);
2099</pre>2099</pre>
2100 2100
2101 2101
2102<p>Ensures that there are at least <code>extra</code> free stack slots in the stack.2102<p>Ensures that there are at least <code>extra</code> free stack slots in the stack.
2103it returns false if it cannot grow the stack to that size.2103It returns false if it cannot grow the stack to that size.
2104This function never shrinks the stack;2104This function never shrinks the stack;
2105if the stack is already larger than the new size,2105if the stack is already larger than the new size,
2106it is left unchanged.2106it is left unchanged.
2107 2107
2108<p><a name="lua_close"></a>2108<p><a name="lua_close"></a>
2109<hr /><h3><code>lua_close</code></h3>2109<hr></hr><h3><code>lua_close</code></h3>
2110<pre>2110<pre>
2111 void lua_close (lua_State *L);2111 void lua_close (lua_State *L);
2112</pre>2112</pre>
@@ -2123,7 +2123,7 @@ might need to release states as soon as they are not needed, · 10 unmodified lines
2123to avoid growing too large.2123to avoid growing too large.
2124 2124
2125<p><a name="lua_concat"></a>2125<p><a name="lua_concat"></a>
2126<hr /><h3><code>lua_concat</code></h3>2126<hr></hr><h3><code>lua_concat</code></h3>
2127<pre>2127<pre>
2128 void lua_concat (lua_State *L, int n);2128 void lua_concat (lua_State *L, int n);
2129</pre>2129</pre>
@@ -2138,7 +2138,7 @@ Concatenation is done following the usual semantics of Lua · 8 unmodified lines
2138(see <a href="#concat">2.5.4</a>).2138(see <a href="#concat">2.5.4</a>).
2139 2139
2140<p><a name="lua_cpcall"></a>2140<p><a name="lua_cpcall"></a>
2141<hr /><h3><code>lua_cpcall</code></h3>2141<hr></hr><h3><code>lua_cpcall</code></h3>
2142<pre>2142<pre>
2143 int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);2143 int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);
2144</pre>2144</pre>
@@ -2154,7 +2154,7 @@ otherwise, it returns zero, and does not change the stack. · 9 unmodified lines
2154All values returned by <code>func</code> are discarded.2154All values returned by <code>func</code> are discarded.
2155 2155
2156<p><a name="lua_createtable"></a>2156<p><a name="lua_createtable"></a>
2157<hr /><h3><code>lua_createtable</code></h3>2157<hr></hr><h3><code>lua_createtable</code></h3>
2158<pre>2158<pre>
2159 void lua_createtable (lua_State *L, int narr, int nrec);2159 void lua_createtable (lua_State *L, int narr, int nrec);
2160</pre>2160</pre>
@@ -2168,7 +2168,7 @@ the table will have. · 7 unmodified lines
2168Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</code></a>.2168Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</code></a>.
2169 2169
2170<p><a name="lua_dump"></a>2170<p><a name="lua_dump"></a>
2171<hr /><h3><code>lua_dump</code></h3>2171<hr></hr><h3><code>lua_dump</code></h3>
2172<pre>2172<pre>
2173 int lua_dump (lua_State *L, lua_Writer writer, void *data);2173 int lua_dump (lua_State *L, lua_Writer writer, void *data);
2174</pre>2174</pre>
@@ -2191,7 +2191,7 @@ call to the writer; · 16 unmodified lines
2191<p>This function does not pop the function from the stack.2191<p>This function does not pop the function from the stack.
2192 2192
2193<p><a name="lua_equal"></a>2193<p><a name="lua_equal"></a>
2194<hr /><h3><code>lua_equal</code></h3>2194<hr></hr><h3><code>lua_equal</code></h3>
2195<pre>2195<pre>
2196 int lua_equal (lua_State *L, int index1, int index2);2196 int lua_equal (lua_State *L, int index1, int index2);
2197</pre>2197</pre>
@@ -2205,7 +2205,7 @@ Otherwise returns 0. · 7 unmodified lines
2205Also returns 0 if any of the indices is non valid.2205Also returns 0 if any of the indices is non valid.
2206 2206
2207<p><a name="lua_error"></a>2207<p><a name="lua_error"></a>
2208<hr /><h3><code>lua_error</code></h3>2208<hr></hr><h3><code>lua_error</code></h3>
2209<pre>2209<pre>
2210 int lua_error (lua_State *L);2210 int lua_error (lua_State *L);
2211</pre>2211</pre>
@@ -2219,7 +2219,7 @@ and therefore never returns. · 7 unmodified lines
2219(see <a href="#pdf-luaL_error"><code>luaL_error</code></a>).2219(see <a href="#pdf-luaL_error"><code>luaL_error</code></a>).
2220 2220
2221<p><a name="lua_gc"></a>2221<p><a name="lua_gc"></a>
2222<hr /><h3><code>lua_gc</code></h3>2222<hr></hr><h3><code>lua_gc</code></h3>
2223<pre>2223<pre>
2224 int lua_gc (lua_State *L, int what, int data);2224 int lua_gc (lua_State *L, int what, int data);
2225</pre>2225</pre>
@@ -2257,7 +2257,7 @@ The function returns the previous value of the step multiplier. · 31 unmodified lines
2257</ul>2257</ul>
2258 2258
2259<p><a name="lua_getallocf"></a>2259<p><a name="lua_getallocf"></a>
2260<hr /><h3><code>lua_getallocf</code></h3>2260<hr></hr><h3><code>lua_getallocf</code></h3>
2261<pre>2261<pre>
2262 lua_Alloc lua_getallocf (lua_State *L, void **ud);2262 lua_Alloc lua_getallocf (lua_State *L, void **ud);
2263</pre>2263</pre>
@@ -2268,7 +2268,7 @@ If <code>ud</code> is not <code>NULL</code>, Lua stores in <code>*ud</code> the · 4 unmodified lines
2268opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.2268opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.
2269 2269
2270<p><a name="lua_getfenv"></a>2270<p><a name="lua_getfenv"></a>
2271<hr /><h3><code>lua_getfenv</code></h3>2271<hr></hr><h3><code>lua_getfenv</code></h3>
2272<pre>2272<pre>
2273 void lua_getfenv (lua_State *L, int index);2273 void lua_getfenv (lua_State *L, int index);
2274</pre>2274</pre>
@@ -2278,7 +2278,7 @@ opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>. · 3 unmodified lines
2278the value at the given index.2278the value at the given index.
2279 2279
2280<p><a name="lua_getfield"></a>2280<p><a name="lua_getfield"></a>
2281<hr /><h3><code>lua_getfield</code></h3>2281<hr></hr><h3><code>lua_getfield</code></h3>
2282<pre>2282<pre>
2283 void lua_getfield (lua_State *L, int index, const char *k);2283 void lua_getfield (lua_State *L, int index, const char *k);
2284</pre>2284</pre>
@@ -2289,8 +2289,21 @@ where <code>t</code> is the value at the given valid index <code>index</code>. · 4 unmodified lines
2289As in Lua, this function may trigger a metamethod2289As in Lua, this function may trigger a metamethod
2290for the "index" event (see <a href="#metatable">2.8</a>).2290for the "index" event (see <a href="#metatable">2.8</a>).
2291 2291
2292<p><a name="lua_getglobal"></a>
2293<hr></hr><h3><code>lua_getglobal</code></h3>
2294<pre>
2295 void lua_getglobal (lua_State *L, const char *name);
2296</pre>
2297
2298
2299<p>Pushes onto the stack the value of the global <code>name</code>.
2300It is defined as a macro:
2301<pre>
2302#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s)
2303</pre>
2304
2292<p><a name="lua_getmetatable"></a>2305<p><a name="lua_getmetatable"></a>
2293<hr /><h3><code>lua_getmetatable</code></h3>2306<hr></hr><h3><code>lua_getmetatable</code></h3>
2294<pre>2307<pre>
2295 int lua_getmetatable (lua_State *L, int index);2308 int lua_getmetatable (lua_State *L, int index);
2296</pre>2309</pre>
@@ -2300,10 +2313,10 @@ for the "index" event (see <a href="#metatable">2.8</a>). · 3 unmodified lines
2300acceptable index.2313acceptable index.
2301If the index is not valid,2314If the index is not valid,
2302or if the value does not have a metatable,2315or if the value does not have a metatable,
2303returns 0 and pushes nothing on the stack.2316the function returns 0 and pushes nothing on the stack.
2304 2317
2305<p><a name="lua_gettable"></a>2318<p><a name="lua_gettable"></a>
2306<hr /><h3><code>lua_gettable</code></h3>2319<hr></hr><h3><code>lua_gettable</code></h3>
2307<pre>2320<pre>
2308 void lua_gettable (lua_State *L, int index);2321 void lua_gettable (lua_State *L, int index);
2309</pre>2322</pre>
@@ -2319,7 +2332,7 @@ As in Lua, this function may trigger a metamethod · 9 unmodified lines
2319for the "index" event (see <a href="#metatable">2.8</a>).2332for the "index" event (see <a href="#metatable">2.8</a>).
2320 2333
2321<p><a name="lua_gettop"></a>2334<p><a name="lua_gettop"></a>
2322<hr /><h3><code>lua_gettop</code></h3>2335<hr></hr><h3><code>lua_gettop</code></h3>
2323<pre>2336<pre>
2324 int lua_gettop (lua_State *L);2337 int lua_gettop (lua_State *L);
2325</pre>2338</pre>
@@ -2331,7 +2344,7 @@ that result is equal to the number of elements in the stack · 5 unmodified lines
2331(and so 0 means an empty stack).2344(and so 0 means an empty stack).
2332 2345
2333<p><a name="lua_insert"></a>2346<p><a name="lua_insert"></a>
2334<hr /><h3><code>lua_insert</code></h3>2347<hr></hr><h3><code>lua_insert</code></h3>
2335<pre>2348<pre>
2336 void lua_insert (lua_State *L, int index);2349 void lua_insert (lua_State *L, int index);
2337</pre>2350</pre>
@@ -2343,7 +2356,7 @@ Cannot be called with a pseudo-index, · 5 unmodified lines
2343because a pseudo-index is not an actual stack position.2356because a pseudo-index is not an actual stack position.
2344 2357
2345<p><a name="lua_Integer"></a>2358<p><a name="lua_Integer"></a>
2346<hr /><h3><code>lua_Integer</code></h3>2359<hr></hr><h3><code>lua_Integer</code></h3>
2347<pre>2360<pre>
2348 typedef ptrdiff_t lua_Integer;2361 typedef ptrdiff_t lua_Integer;
2349</pre>2362</pre>
@@ -2356,7 +2369,7 @@ which is usually the largest integral type the machine handles · 6 unmodified lines
2356"comfortably".2369"comfortably".
2357 2370
2358<p><a name="lua_isboolean"></a>2371<p><a name="lua_isboolean"></a>
2359<hr /><h3><code>lua_isboolean</code></h3>2372<hr></hr><h3><code>lua_isboolean</code></h3>
2360<pre>2373<pre>
2361 int lua_isboolean (lua_State *L, int index);2374 int lua_isboolean (lua_State *L, int index);
2362</pre>2375</pre>
@@ -2366,7 +2379,7 @@ which is usually the largest integral type the machine handles · 3 unmodified lines
2366and 0 otherwise.2379and 0 otherwise.
2367 2380
2368<p><a name="lua_iscfunction"></a>2381<p><a name="lua_iscfunction"></a>
2369<hr /><h3><code>lua_iscfunction</code></h3>2382<hr></hr><h3><code>lua_iscfunction</code></h3>
2370<pre>2383<pre>
2371 int lua_iscfunction (lua_State *L, int index);2384 int lua_iscfunction (lua_State *L, int index);
2372</pre>2385</pre>
@@ -2376,7 +2389,7 @@ and 0 otherwise. · 3 unmodified lines
2376and 0 otherwise.2389and 0 otherwise.
2377 2390
2378<p><a name="lua_isfunction"></a>2391<p><a name="lua_isfunction"></a>
2379<hr /><h3><code>lua_isfunction</code></h3>2392<hr></hr><h3><code>lua_isfunction</code></h3>
2380<pre>2393<pre>
2381 int lua_isfunction (lua_State *L, int index);2394 int lua_isfunction (lua_State *L, int index);
2382</pre>2395</pre>
@@ -2386,7 +2399,7 @@ and 0 otherwise. · 3 unmodified lines
2386(either C or Lua), and 0 otherwise.2399(either C or Lua), and 0 otherwise.
2387 2400
2388<p><a name="lua_islightuserdata"></a>2401<p><a name="lua_islightuserdata"></a>
2389<hr /><h3><code>lua_islightuserdata</code></h3>2402<hr></hr><h3><code>lua_islightuserdata</code></h3>
2390<pre>2403<pre>
2391 int lua_islightuserdata (lua_State *L, int index);2404 int lua_islightuserdata (lua_State *L, int index);
2392</pre>2405</pre>
@@ -2396,7 +2409,7 @@ and 0 otherwise. · 3 unmodified lines
2396and 0 otherwise.2409and 0 otherwise.
2397 2410
2398<p><a name="lua_isnil"></a>2411<p><a name="lua_isnil"></a>
2399<hr /><h3><code>lua_isnil</code></h3>2412<hr></hr><h3><code>lua_isnil</code></h3>
2400<pre>2413<pre>
2401 int lua_isnil (lua_State *L, int index);2414 int lua_isnil (lua_State *L, int index);
2402</pre>2415</pre>
@@ -2406,7 +2419,7 @@ and 0 otherwise. · 3 unmodified lines
2406and 0 otherwise.2419and 0 otherwise.
2407 2420
2408<p><a name="lua_isnumber"></a>2421<p><a name="lua_isnumber"></a>
2409<hr /><h3><code>lua_isnumber</code></h3>2422<hr></hr><h3><code>lua_isnumber</code></h3>
2410<pre>2423<pre>
2411 int lua_isnumber (lua_State *L, int index);2424 int lua_isnumber (lua_State *L, int index);
2412</pre>2425</pre>
@@ -2417,7 +2430,7 @@ or a string convertible to a number, · 4 unmodified lines
2417and 0 otherwise.2430and 0 otherwise.
2418 2431
2419<p><a name="lua_isstring"></a>2432<p><a name="lua_isstring"></a>
2420<hr /><h3><code>lua_isstring</code></h3>2433<hr></hr><h3><code>lua_isstring</code></h3>
2421<pre>2434<pre>
2422 int lua_isstring (lua_State *L, int index);2435 int lua_isstring (lua_State *L, int index);
2423</pre>2436</pre>
@@ -2428,7 +2441,7 @@ or a number (which is always convertible to a string), · 4 unmodified lines
2428and 0 otherwise.2441and 0 otherwise.
2429 2442
2430<p><a name="lua_istable"></a>2443<p><a name="lua_istable"></a>
2431<hr /><h3><code>lua_istable</code></h3>2444<hr></hr><h3><code>lua_istable</code></h3>
2432<pre>2445<pre>
2433 int lua_istable (lua_State *L, int index);2446 int lua_istable (lua_State *L, int index);
2434</pre>2447</pre>
@@ -2438,7 +2451,7 @@ and 0 otherwise. · 3 unmodified lines
2438and 0 otherwise.2451and 0 otherwise.
2439 2452
2440<p><a name="lua_isthread"></a>2453<p><a name="lua_isthread"></a>
2441<hr /><h3><code>lua_isthread</code></h3>2454<hr></hr><h3><code>lua_isthread</code></h3>
2442<pre>2455<pre>
2443 int lua_isthread (lua_State *L, int index);2456 int lua_isthread (lua_State *L, int index);
2444</pre>2457</pre>
@@ -2448,7 +2461,7 @@ and 0 otherwise. · 3 unmodified lines
2448and 0 otherwise.2461and 0 otherwise.
2449 2462
2450<p><a name="lua_isuserdata"></a>2463<p><a name="lua_isuserdata"></a>
2451<hr /><h3><code>lua_isuserdata</code></h3>2464<hr></hr><h3><code>lua_isuserdata</code></h3>
2452<pre>2465<pre>
2453 int lua_isuserdata (lua_State *L, int index);2466 int lua_isuserdata (lua_State *L, int index);
2454</pre>2467</pre>
@@ -2458,7 +2471,7 @@ and 0 otherwise. · 3 unmodified lines
2458(either full or light), and 0 otherwise.2471(either full or light), and 0 otherwise.
2459 2472
2460<p><a name="lua_lessthan"></a>2473<p><a name="lua_lessthan"></a>
2461<hr /><h3><code>lua_lessthan</code></h3>2474<hr></hr><h3><code>lua_lessthan</code></h3>
2462<pre>2475<pre>
2463 int lua_lessthan (lua_State *L, int index1, int index2);2476 int lua_lessthan (lua_State *L, int index1, int index2);
2464</pre>2477</pre>
@@ -2472,7 +2485,7 @@ Otherwise returns 0. · 7 unmodified lines
2472Also returns 0 if any of the indices is non valid.2485Also returns 0 if any of the indices is non valid.
2473 2486
2474<p><a name="lua_load"></a>2487<p><a name="lua_load"></a>
2475<hr /><h3><code>lua_load</code></h3>2488<hr></hr><h3><code>lua_load</code></h3>
2476<pre>2489<pre>
2477 int lua_load (lua_State *L, lua_Reader reader, void *data,2490 int lua_load (lua_State *L, lua_Reader reader, void *data,
2478 const char *chunkname);2491 const char *chunkname);
@@ -2505,7 +2518,7 @@ The <code>data</code> argument is an opaque value passed to the reader function. · 26 unmodified lines
2505which is used for error messages and in debug information (see <a href="#debugI">3.8</a>).2518which is used for error messages and in debug information (see <a href="#debugI">3.8</a>).
2506 2519
2507<p><a name="lua_newstate"></a>2520<p><a name="lua_newstate"></a>
2508<hr /><h3><code>lua_newstate</code></h3>2521<hr></hr><h3><code>lua_newstate</code></h3>
2509<pre>2522<pre>
2510 lua_State *lua_newstate (lua_Alloc f, void *ud);2523 lua_State *lua_newstate (lua_Alloc f, void *ud);
2511</pre>2524</pre>
@@ -2520,7 +2533,7 @@ The second argument, <code>ud</code>, is an opaque pointer that Lua · 8 unmodified lines
2520simply passes to the allocator in every call.2533simply passes to the allocator in every call.
2521 2534
2522<p><a name="lua_newtable"></a>2535<p><a name="lua_newtable"></a>
2523<hr /><h3><code>lua_newtable</code></h3>2536<hr></hr><h3><code>lua_newtable</code></h3>
2524<pre>2537<pre>
2525 void lua_newtable (lua_State *L);2538 void lua_newtable (lua_State *L);
2526</pre>2539</pre>
@@ -2530,7 +2543,7 @@ simply passes to the allocator in every call. · 3 unmodified lines
2530Equivalent to <code>lua_createtable(L, 0, 0)</code>.2543Equivalent to <code>lua_createtable(L, 0, 0)</code>.
2531 2544
2532<p><a name="lua_newthread"></a>2545<p><a name="lua_newthread"></a>
2533<hr /><h3><code>lua_newthread</code></h3>2546<hr></hr><h3><code>lua_newthread</code></h3>
2534<pre>2547<pre>
2535 lua_State *lua_newthread (lua_State *L);2548 lua_State *lua_newthread (lua_State *L);
2536</pre>2549</pre>
@@ -2547,7 +2560,7 @@ Threads are subject to garbage collection, · 10 unmodified lines
2547like any Lua object.2560like any Lua object.
2548 2561
2549<p><a name="lua_newuserdata"></a>2562<p><a name="lua_newuserdata"></a>
2550<hr /><h3><code>lua_newuserdata</code></h3>2563<hr></hr><h3><code>lua_newuserdata</code></h3>
2551<pre>2564<pre>
2552 void *lua_newuserdata (lua_State *L, size_t size);2565 void *lua_newuserdata (lua_State *L, size_t size);
2553</pre>2566</pre>
@@ -2570,7 +2583,7 @@ When that userdata is collected again then · 16 unmodified lines
2570Lua frees its corresponding memory.2583Lua frees its corresponding memory.
2571 2584
2572<p><a name="lua_next"></a>2585<p><a name="lua_next"></a>
2573<hr /><h3><code>lua_next</code></h3>2586<hr></hr><h3><code>lua_next</code></h3>
2574<pre>2587<pre>
2575 int lua_next (lua_State *L, int index);2588 int lua_next (lua_State *L, int index);
2576</pre>2589</pre>
@@ -2602,7 +2615,7 @@ the value at the given index; · 25 unmodified lines
2602this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.2615this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
2603 2616
2604<p><a name="lua_Number"></a>2617<p><a name="lua_Number"></a>
2605<hr /><h3><code>lua_Number</code></h3>2618<hr></hr><h3><code>lua_Number</code></h3>
2606<pre>2619<pre>
2607 typedef double lua_Number;2620 typedef double lua_Number;
2608</pre>2621</pre>
@@ -2612,10 +2625,10 @@ this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>. · 3 unmodified lines
2612By default, it is double, but that can be changed in <code>luaconf.h</code>.2625By default, it is double, but that can be changed in <code>luaconf.h</code>.
2613 2626
2614<p>Through the configuration file you can change2627<p>Through the configuration file you can change
2615Lua to operate with other type for numbers (e.g., float or long).2628Lua to operate with another type for numbers (e.g., float or long).
2616 2629
2617<p><a name="lua_objlen"></a>2630<p><a name="lua_objlen"></a>
2618<hr /><h3><code>lua_objlen</code></h3>2631<hr></hr><h3><code>lua_objlen</code></h3>
2619<pre>2632<pre>
2620 size_t lua_objlen (lua_State *L, int index);2633 size_t lua_objlen (lua_State *L, int index);
2621</pre>2634</pre>
@@ -2629,7 +2642,7 @@ for the userdata; · 7 unmodified lines
2629for other values, it is 0.2642for other values, it is 0.
2630 2643
2631<p><a name="lua_pcall"></a>2644<p><a name="lua_pcall"></a>
2632<hr /><h3><code>lua_pcall</code></h3>2645<hr></hr><h3><code>lua_pcall</code></h3>
2633<pre>2646<pre>
2634 lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);2647 lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
2635</pre>2648</pre>
@@ -2676,7 +2689,7 @@ error while running the error handler function. · 40 unmodified lines
2676</ul>2689</ul>
2677 2690
2678<p><a name="lua_pop"></a>2691<p><a name="lua_pop"></a>
2679<hr /><h3><code>lua_pop</code></h3>2692<hr></hr><h3><code>lua_pop</code></h3>
2680<pre>2693<pre>
2681 void lua_pop (lua_State *L, int n);2694 void lua_pop (lua_State *L, int n);
2682</pre>2695</pre>
@@ -2685,7 +2698,7 @@ error while running the error handler function. · 2 unmodified lines
2685<p>Pops <code>n</code> elements from the stack.2698<p>Pops <code>n</code> elements from the stack.
2686 2699
2687<p><a name="lua_pushboolean"></a>2700<p><a name="lua_pushboolean"></a>
2688<hr /><h3><code>lua_pushboolean</code></h3>2701<hr></hr><h3><code>lua_pushboolean</code></h3>
2689<pre>2702<pre>
2690 void lua_pushboolean (lua_State *L, int b);2703 void lua_pushboolean (lua_State *L, int b);
2691</pre>2704</pre>
@@ -2694,7 +2707,7 @@ error while running the error handler function. · 2 unmodified lines
2694<p>Pushes a boolean value with value <code>b</code> onto the stack.2707<p>Pushes a boolean value with value <code>b</code> onto the stack.
2695 2708
2696<p><a name="lua_pushcclosure"></a>2709<p><a name="lua_pushcclosure"></a>
2697<hr /><h3><code>lua_pushcclosure</code></h3>2710<hr></hr><h3><code>lua_pushcclosure</code></h3>
2698<pre>2711<pre>
2699 void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);2712 void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
2700</pre>2713</pre>
@@ -2716,17 +2729,26 @@ associated with the function. · 15 unmodified lines
2716<a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.2729<a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.
2717 2730
2718<p><a name="lua_pushcfunction"></a>2731<p><a name="lua_pushcfunction"></a>
2719<hr /><h3><code>lua_pushcfunction</code></h3>2732<hr></hr><h3><code>lua_pushcfunction</code></h3>
2720<pre>2733<pre>
2721 void lua_pushcfunction (lua_State *L, lua_CFunction f);2734 void lua_pushcfunction (lua_State *L, lua_CFunction f);
2722</pre>2735</pre>
2723 2736
2724 2737
2725<p>Pushes a C function onto the stack.2738<p>Pushes a C function onto the stack.
2726This function is equivalent to <code>lua_pushcclosure(L, f, 0);</code>.2739This function receives a pointer to a C function
2740and pushes on the stack a Lua value of type <code>function</code> that,
2741when called, invokes the corresponding C function.
2742
2743<p>Any function to be registered in Lua must
2744follow the correct protocol to receive its parameters
2745and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).
2746
2747<p>The call <code>lua_pushcfunction(L, f)</code> is equivalent to
2748<code>lua_pushcclosure(L, f, 0)</code>.
2727 2749
2728<p><a name="lua_pushfstring"></a>2750<p><a name="lua_pushfstring"></a>
2729<hr /><h3><code>lua_pushfstring</code></h3>2751<hr></hr><h3><code>lua_pushfstring</code></h3>
2730<pre>2752<pre>
2731 const char *lua_pushfstring (lua_State *L, const char *fmt, ...);2753 const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
2732</pre>2754</pre>
@@ -2752,7 +2774,7 @@ The conversion specifiers can only be · 19 unmodified lines
2752</ul>2774</ul>
2753 2775
2754<p><a name="lua_pushinteger"></a>2776<p><a name="lua_pushinteger"></a>
2755<hr /><h3><code>lua_pushinteger</code></h3>2777<hr></hr><h3><code>lua_pushinteger</code></h3>
2756<pre>2778<pre>
2757 void lua_pushinteger (lua_State *L, lua_Integer n);2779 void lua_pushinteger (lua_State *L, lua_Integer n);
2758</pre>2780</pre>
@@ -2761,7 +2783,7 @@ The conversion specifiers can only be · 2 unmodified lines
2761<p>Pushes a number with value <code>n</code> onto the stack.2783<p>Pushes a number with value <code>n</code> onto the stack.
2762 2784
2763<p><a name="lua_pushlightuserdata"></a>2785<p><a name="lua_pushlightuserdata"></a>
2764<hr /><h3><code>lua_pushlightuserdata</code></h3>2786<hr></hr><h3><code>lua_pushlightuserdata</code></h3>
2765<pre>2787<pre>
2766 void lua_pushlightuserdata (lua_State *L, void *p);2788 void lua_pushlightuserdata (lua_State *L, void *p);
2767</pre>2789</pre>
@@ -2778,7 +2800,7 @@ A light userdata is equal to "any" · 10 unmodified lines
2778light userdata with the same C address.2800light userdata with the same C address.
2779 2801
2780<p><a name="lua_pushlstring"></a>2802<p><a name="lua_pushlstring"></a>
2781<hr /><h3><code>lua_pushlstring</code></h3>2803<hr></hr><h3><code>lua_pushlstring</code></h3>
2782<pre>2804<pre>
2783 void lua_pushlstring (lua_State *L, const char *s, size_t len);2805 void lua_pushlstring (lua_State *L, const char *s, size_t len);
2784</pre>2806</pre>
@@ -2792,7 +2814,7 @@ the function returns. · 7 unmodified lines
2792The string can contain embedded zeros.2814The string can contain embedded zeros.
2793 2815
2794<p><a name="lua_pushnil"></a>2816<p><a name="lua_pushnil"></a>
2795<hr /><h3><code>lua_pushnil</code></h3>2817<hr></hr><h3><code>lua_pushnil</code></h3>
2796<pre>2818<pre>
2797 void lua_pushnil (lua_State *L);2819 void lua_pushnil (lua_State *L);
2798</pre>2820</pre>
@@ -2801,7 +2823,7 @@ The string can contain embedded zeros. · 2 unmodified lines
2801<p>Pushes a nil value onto the stack.2823<p>Pushes a nil value onto the stack.
2802 2824
2803<p><a name="lua_pushnumber"></a>2825<p><a name="lua_pushnumber"></a>
2804<hr /><h3><code>lua_pushnumber</code></h3>2826<hr></hr><h3><code>lua_pushnumber</code></h3>
2805<pre>2827<pre>
2806 void lua_pushnumber (lua_State *L, lua_Number n);2828 void lua_pushnumber (lua_State *L, lua_Number n);
2807</pre>2829</pre>
@@ -2810,7 +2832,7 @@ The string can contain embedded zeros. · 2 unmodified lines
2810<p>Pushes a number with value <code>n</code> onto the stack.2832<p>Pushes a number with value <code>n</code> onto the stack.
2811 2833
2812<p><a name="lua_pushstring"></a>2834<p><a name="lua_pushstring"></a>
2813<hr /><h3><code>lua_pushstring</code></h3>2835<hr></hr><h3><code>lua_pushstring</code></h3>
2814<pre>2836<pre>
2815 void lua_pushstring (lua_State *L, const char *s);2837 void lua_pushstring (lua_State *L, const char *s);
2816</pre>2838</pre>
@@ -2825,7 +2847,7 @@ The string cannot contain embedded zeros; · 8 unmodified lines
2825it is assumed to end at the first zero.2847it is assumed to end at the first zero.
2826 2848
2827<p><a name="lua_pushthread"></a>2849<p><a name="lua_pushthread"></a>
2828<hr /><h3><code>lua_pushthread</code></h3>2850<hr></hr><h3><code>lua_pushthread</code></h3>
2829<pre>2851<pre>
2830 void lua_pushthread (lua_State *L);2852 void lua_pushthread (lua_State *L);
2831</pre>2853</pre>
@@ -2834,7 +2856,7 @@ it is assumed to end at the first zero. · 2 unmodified lines
2834<p>Pushes the thread represented by <code>L</code> onto the stack.2856<p>Pushes the thread represented by <code>L</code> onto the stack.
2835 2857
2836<p><a name="lua_pushvalue"></a>2858<p><a name="lua_pushvalue"></a>
2837<hr /><h3><code>lua_pushvalue</code></h3>2859<hr></hr><h3><code>lua_pushvalue</code></h3>
2838<pre>2860<pre>
2839 void lua_pushvalue (lua_State *L, int index);2861 void lua_pushvalue (lua_State *L, int index);
2840</pre>2862</pre>
@@ -2844,7 +2866,7 @@ it is assumed to end at the first zero. · 3 unmodified lines
2844onto the stack.2866onto the stack.
2845 2867
2846<p><a name="lua_pushvfstring"></a>2868<p><a name="lua_pushvfstring"></a>
2847<hr /><h3><code>lua_pushvfstring</code></h3>2869<hr></hr><h3><code>lua_pushvfstring</code></h3>
2848<pre>2870<pre>
2849 const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp);2871 const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp);
2850</pre>2872</pre>
@@ -2854,7 +2876,7 @@ onto the stack. · 3 unmodified lines
2854instead of a variable number of arguments.2876instead of a variable number of arguments.
2855 2877
2856<p><a name="lua_rawequal"></a>2878<p><a name="lua_rawequal"></a>
2857<hr /><h3><code>lua_rawequal</code></h3>2879<hr></hr><h3><code>lua_rawequal</code></h3>
2858<pre>2880<pre>
2859 int lua_rawequal (lua_State *L, int index1, int index2);2881 int lua_rawequal (lua_State *L, int index1, int index2);
2860</pre>2882</pre>
@@ -2867,7 +2889,7 @@ Otherwise returns 0. · 6 unmodified lines
2867Also returns 0 if any of the indices are non valid.2889Also returns 0 if any of the indices are non valid.
2868 2890
2869<p><a name="lua_rawget"></a>2891<p><a name="lua_rawget"></a>
2870<hr /><h3><code>lua_rawget</code></h3>2892<hr></hr><h3><code>lua_rawget</code></h3>
2871<pre>2893<pre>
2872 void lua_rawget (lua_State *L, int index);2894 void lua_rawget (lua_State *L, int index);
2873</pre>2895</pre>
@@ -2877,7 +2899,7 @@ Also returns 0 if any of the indices are non valid. · 3 unmodified lines
2877(i.e., without metamethods).2899(i.e., without metamethods).
2878 2900
2879<p><a name="lua_rawgeti"></a>2901<p><a name="lua_rawgeti"></a>
2880<hr /><h3><code>lua_rawgeti</code></h3>2902<hr></hr><h3><code>lua_rawgeti</code></h3>
2881<pre>2903<pre>
2882 void lua_rawgeti (lua_State *L, int index, int n);2904 void lua_rawgeti (lua_State *L, int index, int n);
2883</pre>2905</pre>
@@ -2889,7 +2911,7 @@ The access is raw; · 5 unmodified lines
2889that is, it does not invoke metamethods.2911that is, it does not invoke metamethods.
2890 2912
2891<p><a name="lua_rawset"></a>2913<p><a name="lua_rawset"></a>
2892<hr /><h3><code>lua_rawset</code></h3>2914<hr></hr><h3><code>lua_rawset</code></h3>
2893<pre>2915<pre>
2894 void lua_rawset (lua_State *L, int index);2916 void lua_rawset (lua_State *L, int index);
2895</pre>2917</pre>
@@ -2899,7 +2921,7 @@ that is, it does not invoke metamethods. · 3 unmodified lines
2899(i.e., without metamethods).2921(i.e., without metamethods).
2900 2922
2901<p><a name="lua_rawseti"></a>2923<p><a name="lua_rawseti"></a>
2902<hr /><h3><code>lua_rawseti</code></h3>2924<hr></hr><h3><code>lua_rawseti</code></h3>
2903<pre>2925<pre>
2904 void lua_rawseti (lua_State *L, int index, int n);2926 void lua_rawseti (lua_State *L, int index, int n);
2905</pre>2927</pre>
@@ -2914,7 +2936,7 @@ The assignment is raw; · 8 unmodified lines
2914that is, it does not invoke metamethods.2936that is, it does not invoke metamethods.
2915 2937
2916<p><a name="lua_Reader"></a>2938<p><a name="lua_Reader"></a>
2917<hr /><h3><code>lua_Reader</code></h3>2939<hr></hr><h3><code>lua_Reader</code></h3>
2918<pre>2940<pre>
2919 typedef const char * (*lua_Reader)2941 typedef const char * (*lua_Reader)
2920 (lua_State *L, void *data, size_t *size);2942 (lua_State *L, void *data, size_t *size);
@@ -2933,8 +2955,21 @@ The block must exist until the reader function is called again. · 12 unmodified lines
2933To signal the end of the chunk, the reader must return <code>NULL</code>.2955To signal the end of the chunk, the reader must return <code>NULL</code>.
2934The reader function may return pieces of any size greater than zero.2956The reader function may return pieces of any size greater than zero.
2935 2957
2958<p><a name="lua_register"></a>
2959<hr></hr><h3><code>lua_register</code></h3>
2960<pre>
2961 void lua_register (lua_State *L, const char *name, lua_CFunction f);
2962</pre>
2963
2964
2965<p>Sets the C function <code>f</code> as the new value of global <code>name</code>.
2966It is defined as a macro:
2967<pre>
2968#define lua_register(L,n,f) (lua_pushcfunction(L, f), lua_setglobal(L, n))
2969</pre>
2970
2936<p><a name="lua_remove"></a>2971<p><a name="lua_remove"></a>
2937<hr /><h3><code>lua_remove</code></h3>2972<hr></hr><h3><code>lua_remove</code></h3>
2938<pre>2973<pre>
2939 void lua_remove (lua_State *L, int index);2974 void lua_remove (lua_State *L, int index);
2940</pre>2975</pre>
@@ -2946,7 +2981,7 @@ Cannot be called with a pseudo-index, · 5 unmodified lines
2946because a pseudo-index is not an actual stack position.2981because a pseudo-index is not an actual stack position.
2947 2982
2948<p><a name="lua_replace"></a>2983<p><a name="lua_replace"></a>
2949<hr /><h3><code>lua_replace</code></h3>2984<hr></hr><h3><code>lua_replace</code></h3>
2950<pre>2985<pre>
2951 void lua_replace (lua_State *L, int index);2986 void lua_replace (lua_State *L, int index);
2952</pre>2987</pre>
@@ -2957,7 +2992,7 @@ without shifting any element · 4 unmodified lines
2957(therefore replacing the value at the given position).2992(therefore replacing the value at the given position).
2958 2993
2959<p><a name="lua_resume"></a>2994<p><a name="lua_resume"></a>
2960<hr /><h3><code>lua_resume</code></h3>2995<hr></hr><h3><code>lua_resume</code></h3>
2961<pre>2996<pre>
2962 int lua_resume (lua_State *L, int narg);2997 int lua_resume (lua_State *L, int narg);
2963</pre>2998</pre>
@@ -2987,7 +3022,7 @@ be passed as results from <code>yield</code>, · 23 unmodified lines
2987and then call <a href="#lua_resume"><code>lua_resume</code></a>.3022and then call <a href="#lua_resume"><code>lua_resume</code></a>.
2988 3023
2989<p><a name="lua_setallocf"></a>3024<p><a name="lua_setallocf"></a>
2990<hr /><h3><code>lua_setallocf</code></h3>3025<hr></hr><h3><code>lua_setallocf</code></h3>
2991<pre>3026<pre>
2992 void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);3027 void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
2993</pre>3028</pre>
@@ -2997,7 +3032,7 @@ and then call <a href="#lua_resume"><code>lua_resume</code></a>. · 3 unmodified lines
2997with user data <code>ud</code>.3032with user data <code>ud</code>.
2998 3033
2999<p><a name="lua_setfenv"></a>3034<p><a name="lua_setfenv"></a>
3000<hr /><h3><code>lua_setfenv</code></h3>3035<hr></hr><h3><code>lua_setfenv</code></h3>
3001<pre>3036<pre>
3002 int lua_setfenv (lua_State *L, int index);3037 int lua_setfenv (lua_State *L, int index);
3003</pre>3038</pre>
@@ -3011,7 +3046,7 @@ neither a function nor a thread nor a userdata, · 7 unmodified lines
3011Otherwise it returns 1.3046Otherwise it returns 1.
3012 3047
3013<p><a name="lua_setfield"></a>3048<p><a name="lua_setfield"></a>
3014<hr /><h3><code>lua_setfield</code></h3>3049<hr></hr><h3><code>lua_setfield</code></h3>
3015<pre>3050<pre>
3016 void lua_setfield (lua_State *L, int index, const char *k);3051 void lua_setfield (lua_State *L, int index, const char *k);
3017</pre>3052</pre>
@@ -3025,8 +3060,22 @@ and <code>v</code> is the value at the top of the stack, · 7 unmodified lines
3025As in Lua, this function may trigger a metamethod3060As in Lua, this function may trigger a metamethod
3026for the "newindex" event (see <a href="#metatable">2.8</a>).3061for the "newindex" event (see <a href="#metatable">2.8</a>).
3027 3062
3063<p><a name="lua_setglobal"></a>
3064<hr></hr><h3><code>lua_setglobal</code></h3>
3065<pre>
3066 void lua_setglobal (lua_State *L, const char *name);
3067</pre>
3068
3069
3070<p>Pops a value from the stack and
3071sets it as the new value of global <code>name</code>.
3072It is defined as a macro:
3073<pre>
3074#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s)
3075</pre>
3076
3028<p><a name="lua_setmetatable"></a>3077<p><a name="lua_setmetatable"></a>
3029<hr /><h3><code>lua_setmetatable</code></h3>3078<hr></hr><h3><code>lua_setmetatable</code></h3>
3030<pre>3079<pre>
3031 int lua_setmetatable (lua_State *L, int index);3080 int lua_setmetatable (lua_State *L, int index);
3032</pre>3081</pre>
@@ -3037,7 +3086,7 @@ sets it as the new metatable for the value at the given · 4 unmodified lines
3037acceptable index.3086acceptable index.
3038 3087
3039<p><a name="lua_settable"></a>3088<p><a name="lua_settable"></a>
3040<hr /><h3><code>lua_settable</code></h3>3089<hr></hr><h3><code>lua_settable</code></h3>
3041<pre>3090<pre>
3042 void lua_settable (lua_State *L, int index);3091 void lua_settable (lua_State *L, int index);
3043</pre>3092</pre>
@@ -3053,7 +3102,7 @@ As in Lua, this function may trigger a metamethod · 9 unmodified lines
3053for the "newindex" event (see <a href="#metatable">2.8</a>).3102for the "newindex" event (see <a href="#metatable">2.8</a>).
3054 3103
3055<p><a name="lua_settop"></a>3104<p><a name="lua_settop"></a>
3056<hr /><h3><code>lua_settop</code></h3>3105<hr></hr><h3><code>lua_settop</code></h3>
3057<pre>3106<pre>
3058 void lua_settop (lua_State *L, int index);3107 void lua_settop (lua_State *L, int index);
3059</pre>3108</pre>
@@ -3066,7 +3115,7 @@ then the new elements are filled with <b>nil</b>. · 6 unmodified lines
3066If <code>index</code> is 0, then all stack elements are removed.3115If <code>index</code> is 0, then all stack elements are removed.
3067 3116
3068<p><a name="lua_State"></a>3117<p><a name="lua_State"></a>
3069<hr /><h3><code>lua_State</code></h3>3118<hr></hr><h3><code>lua_State</code></h3>
3070<pre>3119<pre>
3071 typedef struct lua_State lua_State;3120 typedef struct lua_State lua_State;
3072</pre>3121</pre>
@@ -3082,7 +3131,7 @@ every function in the library, except to <a href="#lua_newstate"><code>lua_newst · 9 unmodified lines
3082which creates a Lua state from scratch.3131which creates a Lua state from scratch.
3083 3132
3084<p><a name="lua_status"></a>3133<p><a name="lua_status"></a>
3085<hr /><h3><code>lua_status</code></h3>3134<hr></hr><h3><code>lua_status</code></h3>
3086<pre>3135<pre>
3087 int lua_status (lua_State *L);3136 int lua_status (lua_State *L);
3088</pre>3137</pre>
@@ -3090,19 +3139,19 @@ which creates a Lua state from scratch. · 1 unmodified line
3090 3139
3091<p>Returns the status of the thread <code>L</code>.3140<p>Returns the status of the thread <code>L</code>.
3092 3141
3093<p>The status can by 0 for a normal thread,3142<p>The status can be 0 for a normal thread,
3094an error code if the thread finished its execution with an error,3143an error code if the thread finished its execution with an error,
3095or <code>LUA_YIELD</code> if the thread is suspended.3144or <code>LUA_YIELD</code> if the thread is suspended.
3096 3145
3097<p><a name="lua_toboolean"></a>3146<p><a name="lua_toboolean"></a>
3098<hr /><h3><code>lua_toboolean</code></h3>3147<hr></hr><h3><code>lua_toboolean</code></h3>
3099<pre>3148<pre>
3100 int lua_toboolean (lua_State *L, int index);3149 int lua_toboolean (lua_State *L, int index);
3101</pre>3150</pre>
3102 3151
3103 3152
3104<p>Converts the Lua value at the given acceptable index to a C boolean3153<p>Converts the Lua value at the given acceptable index to a C boolean
3105value ((0 or 1).3154value (0 or 1).
3106Like all tests in Lua,3155Like all tests in Lua,
3107<a href="#lua_toboolean"><code>lua_toboolean</code></a> returns 1 for any Lua value3156<a href="#lua_toboolean"><code>lua_toboolean</code></a> returns 1 for any Lua value
3108different from <b>false</b> and <b>nil</b>;3157different from <b>false</b> and <b>nil</b>;
@@ -3112,7 +3161,7 @@ It also returns 0 when called with a non-valid index. · 3 unmodified lines
3112use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's type.)3161use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's type.)
3113 3162
3114<p><a name="lua_tocfunction"></a>3163<p><a name="lua_tocfunction"></a>
3115<hr /><h3><code>lua_tocfunction</code></h3>3164<hr></hr><h3><code>lua_tocfunction</code></h3>
3116<pre>3165<pre>
3117 lua_CFunction lua_tocfunction (lua_State *L, int index);3166 lua_CFunction lua_tocfunction (lua_State *L, int index);
3118</pre>3167</pre>
@@ -3123,7 +3172,7 @@ That value must be a C function; · 4 unmodified lines
3123otherwise, returns <code>NULL</code>.3172otherwise, returns <code>NULL</code>.
3124 3173
3125<p><a name="lua_tointeger"></a>3174<p><a name="lua_tointeger"></a>
3126<hr /><h3><code>lua_tointeger</code></h3>3175<hr></hr><h3><code>lua_tointeger</code></h3>
3127<pre>3176<pre>
3128 lua_Integer lua_tointeger (lua_State *L, int idx);3177 lua_Integer lua_tointeger (lua_State *L, int idx);
3129</pre>3178</pre>
@@ -3131,7 +3180,7 @@ otherwise, returns <code>NULL</code>. · 1 unmodified line
3131 3180
3132<p>Converts the Lua value at the given acceptable index3181<p>Converts the Lua value at the given acceptable index
3133to the signed integral type <a href="#lua_Integer"><code>lua_Integer</code></a>.3182to the signed integral type <a href="#lua_Integer"><code>lua_Integer</code></a>.
3134The Lua value must be a number or a string convertible to number3183The Lua value must be a number or a string convertible to a number
3135(see <a href="#coercion">2.2.1</a>);3184(see <a href="#coercion">2.2.1</a>);
3136otherwise, <a href="#lua_tointeger"><code>lua_tointeger</code></a> returns 0.3185otherwise, <a href="#lua_tointeger"><code>lua_tointeger</code></a> returns 0.
3137 3186
@@ -3139,7 +3188,7 @@ otherwise, <a href="#lua_tointeger"><code>lua_tointeger</code></a> returns 0. · 1 unmodified line
3139it is truncated in some non-specified way.3188it is truncated in some non-specified way.
3140 3189
3141<p><a name="lua_tolstring"></a>3190<p><a name="lua_tolstring"></a>
3142<hr /><h3><code>lua_tolstring</code></h3>3191<hr></hr><h3><code>lua_tolstring</code></h3>
3143<pre>3192<pre>
3144 const char *lua_tolstring (lua_State *L, int index, size_t *len);3193 const char *lua_tolstring (lua_State *L, int index, size_t *len);
3145</pre>3194</pre>
@@ -3167,7 +3216,7 @@ there is no guarantee that the pointer returned by <a href="#lua_tolstring"><cod · 21 unmodified lines
3167will be valid after the corresponding value is removed from the stack.3216will be valid after the corresponding value is removed from the stack.
3168 3217
3169<p><a name="lua_tonumber"></a>3218<p><a name="lua_tonumber"></a>
3170<hr /><h3><code>lua_tonumber</code></h3>3219<hr></hr><h3><code>lua_tonumber</code></h3>
3171<pre>3220<pre>
3172 lua_Number lua_tonumber (lua_State *L, int index);3221 lua_Number lua_tonumber (lua_State *L, int index);
3173</pre>3222</pre>
@@ -3175,12 +3224,12 @@ will be valid after the corresponding value is removed from the stack. · 1 unmodified line
3175 3224
3176<p>Converts the Lua value at the given acceptable index3225<p>Converts the Lua value at the given acceptable index
3177to a number (see <a href="#lua_Number"><code>lua_Number</code></a>).3226to a number (see <a href="#lua_Number"><code>lua_Number</code></a>).
3178The Lua value must be a number or a string convertible to number3227The Lua value must be a number or a string convertible to a number
3179(see <a href="#coercion">2.2.1</a>);3228(see <a href="#coercion">2.2.1</a>);
3180otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns 0.3229otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns 0.
3181 3230
3182<p><a name="lua_topointer"></a>3231<p><a name="lua_topointer"></a>
3183<hr /><h3><code>lua_topointer</code></h3>3232<hr></hr><h3><code>lua_topointer</code></h3>
3184<pre>3233<pre>
3185 const void *lua_topointer (lua_State *L, int index);3234 const void *lua_topointer (lua_State *L, int index);
3186</pre>3235</pre>
@@ -3196,7 +3245,7 @@ There is no direct way to convert the pointer back to its original value. · 9 unmodified lines
3196<p>Typically this function is used only for debug information.3245<p>Typically this function is used only for debug information.
3197 3246
3198<p><a name="lua_tostring"></a>3247<p><a name="lua_tostring"></a>
3199<hr /><h3><code>lua_tostring</code></h3>3248<hr></hr><h3><code>lua_tostring</code></h3>
3200<pre>3249<pre>
3201 const char *lua_tostring (lua_State *L, int index);3250 const char *lua_tostring (lua_State *L, int index);
3202</pre>3251</pre>
@@ -3205,7 +3254,7 @@ There is no direct way to convert the pointer back to its original value. · 2 unmodified lines
3205<p>Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to <code>NULL</code>.3254<p>Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code>len</code> equal to <code>NULL</code>.
3206 3255
3207<p><a name="lua_tothread"></a>3256<p><a name="lua_tothread"></a>
3208<hr /><h3><code>lua_tothread</code></h3>3257<hr></hr><h3><code>lua_tothread</code></h3>
3209<pre>3258<pre>
3210 lua_State *lua_tothread (lua_State *L, int index);3259 lua_State *lua_tothread (lua_State *L, int index);
3211</pre>3260</pre>
@@ -3217,7 +3266,7 @@ This value must be a thread; · 5 unmodified lines
3217otherwise, the function returns <code>NULL</code>.3266otherwise, the function returns <code>NULL</code>.
3218 3267
3219<p><a name="lua_touserdata"></a>3268<p><a name="lua_touserdata"></a>
3220<hr /><h3><code>lua_touserdata</code></h3>3269<hr></hr><h3><code>lua_touserdata</code></h3>
3221<pre>3270<pre>
3222 void *lua_touserdata (lua_State *L, int index);3271 void *lua_touserdata (lua_State *L, int index);
3223</pre>3272</pre>
@@ -3230,13 +3279,13 @@ returns its pointer. · 6 unmodified lines
3230Otherwise, returns <code>NULL</code>.3279Otherwise, returns <code>NULL</code>.
3231 3280
3232<p><a name="lua_type"></a>3281<p><a name="lua_type"></a>
3233<hr /><h3><code>lua_type</code></h3>3282<hr></hr><h3><code>lua_type</code></h3>
3234<pre>3283<pre>
3235 int lua_type (lua_State *L, int index);3284 int lua_type (lua_State *L, int index);
3236</pre>3285</pre>
3237 3286
3238 3287
3239<p>Returns the type of a value in the given acceptable index,3288<p>Returns the type of the value in the given acceptable index,
3240or <code>LUA_TNONE</code> for a non-valid index3289or <code>LUA_TNONE</code> for a non-valid index
3241(that is, an index to an "empty" stack position).3290(that is, an index to an "empty" stack position).
3242The types returned by <a href="#lua_type"><code>lua_type</code></a> are coded by the following constants3291The types returned by <a href="#lua_type"><code>lua_type</code></a> are coded by the following constants
@@ -3253,7 +3302,7 @@ and · 10 unmodified lines
3253<code>LUA_TLIGHTUSERDATA</code>.3302<code>LUA_TLIGHTUSERDATA</code>.
3254 3303
3255<p><a name="lua_typename"></a>3304<p><a name="lua_typename"></a>
3256<hr /><h3><code>lua_typename</code></h3>3305<hr></hr><h3><code>lua_typename</code></h3>
3257<pre>3306<pre>
3258 const char *lua_typename (lua_State *L, int tp);3307 const char *lua_typename (lua_State *L, int tp);
3259</pre>3308</pre>
@@ -3263,7 +3312,7 @@ and · 3 unmodified lines
3263which must be one the values returned by <a href="#lua_type"><code>lua_type</code></a>.3312which must be one the values returned by <a href="#lua_type"><code>lua_type</code></a>.
3264 3313
3265<p><a name="lua_Writer"></a>3314<p><a name="lua_Writer"></a>
3266<hr /><h3><code>lua_Writer</code></h3>3315<hr></hr><h3><code>lua_Writer</code></h3>
3267<pre>3316<pre>
3268 typedef int (*lua_Writer)3317 typedef int (*lua_Writer)
3269 (lua_State *L, const void* p, size_t sz, void* ud);3318 (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 · 14 unmodified lines
3284calling the writer again.3333calling the writer again.
3285 3334
3286<p><a name="lua_xmove"></a>3335<p><a name="lua_xmove"></a>
3287<hr /><h3><code>lua_xmove</code></h3>3336<hr></hr><h3><code>lua_xmove</code></h3>
3288<pre>3337<pre>
3289 void lua_xmove (lua_State *from, lua_State *to, int n);3338 void lua_xmove (lua_State *from, lua_State *to, int n);
3290</pre>3339</pre>
@@ -3293,10 +3342,10 @@ calling the writer again. · 2 unmodified lines
3293<p>Exchange values between different threads of the <em>same</em> global state.3342<p>Exchange values between different threads of the <em>same</em> global state.
3294 3343
3295<p>This function pops <code>n</code> values from the stack <code>from</code>,3344<p>This function pops <code>n</code> values from the stack <code>from</code>,
3296and pushes them into the stack <code>to</code>.3345and pushes them onto the stack <code>to</code>.
3297 3346
3298<p><a name="lua_yield"></a>3347<p><a name="lua_yield"></a>
3299<hr /><h3><code>lua_yield</code></h3>3348<hr></hr><h3><code>lua_yield</code></h3>
3300<pre>3349<pre>
3301 int lua_yield (lua_State *L, int nresults);3350 int lua_yield (lua_State *L, int nresults);
3302</pre>3351</pre>
@@ -3326,7 +3375,7 @@ kinds of debuggers, profilers, and other tools · 23 unmodified lines
3326that need "inside information" from the interpreter.3375that need "inside information" from the interpreter.
3327 3376
3328<p><a name="lua_Debug"></a>3377<p><a name="lua_Debug"></a>
3329<hr /><h3><code>lua_Debug</code></h3>3378<hr></hr><h3><code>lua_Debug</code></h3>
3330<pre>3379<pre>
3331 typedef struct lua_Debug {3380 typedef struct lua_Debug {
3332 int event;3381 int event;
@@ -3408,7 +3457,7 @@ the number of upvalues of the function. · 75 unmodified lines
3408<p></ul>3457<p></ul>
3409 3458
3410<p><a name="lua_gethook"></a>3459<p><a name="lua_gethook"></a>
3411<hr /><h3><code>lua_gethook</code></h3>3460<hr></hr><h3><code>lua_gethook</code></h3>
3412<pre>3461<pre>
3413 lua_Hook lua_gethook (lua_State *L);3462 lua_Hook lua_gethook (lua_State *L);
3414</pre>3463</pre>
@@ -3417,7 +3466,7 @@ the number of upvalues of the function. · 2 unmodified lines
3417<p>Returns the current hook function.3466<p>Returns the current hook function.
3418 3467
3419<p><a name="lua_gethookcount"></a>3468<p><a name="lua_gethookcount"></a>
3420<hr /><h3><code>lua_gethookcount</code></h3>3469<hr></hr><h3><code>lua_gethookcount</code></h3>
3421<pre>3470<pre>
3422 int lua_gethookcount (lua_State *L);3471 int lua_gethookcount (lua_State *L);
3423</pre>3472</pre>
@@ -3426,7 +3475,7 @@ the number of upvalues of the function. · 2 unmodified lines
3426<p>Returns the current hook count.3475<p>Returns the current hook count.
3427 3476
3428<p><a name="lua_gethookmask"></a>3477<p><a name="lua_gethookmask"></a>
3429<hr /><h3><code>lua_gethookmask</code></h3>3478<hr></hr><h3><code>lua_gethookmask</code></h3>
3430<pre>3479<pre>
3431 int lua_gethookmask (lua_State *L);3480 int lua_gethookmask (lua_State *L);
3432</pre>3481</pre>
@@ -3435,7 +3484,7 @@ the number of upvalues of the function. · 2 unmodified lines
3435<p>Returns the current hook mask.3484<p>Returns the current hook mask.
3436 3485
3437<p><a name="lua_getinfo"></a>3486<p><a name="lua_getinfo"></a>
3438<hr /><h3><code>lua_getinfo</code></h3>3487<hr></hr><h3><code>lua_getinfo</code></h3>
3439<pre>3488<pre>
3440 int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);3489 int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
3441</pre>3490</pre>
@@ -3469,7 +3518,7 @@ you can write the following code: · 27 unmodified lines
3469</pre>3518</pre>
3470 3519
3471<p><a name="lua_getlocal"></a>3520<p><a name="lua_getlocal"></a>
3472<hr /><h3><code>lua_getlocal</code></h3>3521<hr></hr><h3><code>lua_getlocal</code></h3>
3473<pre>3522<pre>
3474 const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);3523 const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
3475</pre>3524</pre>
@@ -3494,7 +3543,7 @@ when the index is greater than · 18 unmodified lines
3494the number of active local variables.3543the number of active local variables.
3495 3544
3496<p><a name="lua_getstack"></a>3545<p><a name="lua_getstack"></a>
3497<hr /><h3><code>lua_getstack</code></h3>3546<hr></hr><h3><code>lua_getstack</code></h3>
3498<pre>3547<pre>
3499 int lua_getstack (lua_State *L, int level, lua_Debug *ar);3548 int lua_getstack (lua_State *L, int level, lua_Debug *ar);
3500</pre>3549</pre>
@@ -3512,7 +3561,7 @@ when called with a level greater than the stack depth, · 11 unmodified lines
3512it returns 0.3561it returns 0.
3513 3562
3514<p><a name="lua_getupvalue"></a>3563<p><a name="lua_getupvalue"></a>
3515<hr /><h3><code>lua_getupvalue</code></h3>3564<hr></hr><h3><code>lua_getupvalue</code></h3>
3516<pre>3565<pre>
3517 const char *lua_getupvalue (lua_State *L, int funcindex, int n);3566 const char *lua_getupvalue (lua_State *L, int funcindex, int n);
3518</pre>3567</pre>
@@ -3536,7 +3585,7 @@ For C functions, this function uses the empty string <code>""</code> · 17 unmodified lines
3536as a name for all upvalues.3585as a name for all upvalues.
3537 3586
3538<p><a name="lua_Hook"></a>3587<p><a name="lua_Hook"></a>
3539<hr /><h3><code>lua_Hook</code></h3>3588<hr></hr><h3><code>lua_Hook</code></h3>
3540<pre>3589<pre>
3541 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);3590 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
3542</pre>3591</pre>
@@ -3564,7 +3613,7 @@ Therefore, if a hook calls back Lua to execute a function or a chunk, · 21 unmodified lines
3564that execution occurs without any calls to hooks.3613that execution occurs without any calls to hooks.
3565 3614
3566<p><a name="lua_sethook"></a>3615<p><a name="lua_sethook"></a>
3567<hr /><h3><code>lua_sethook</code></h3>3616<hr></hr><h3><code>lua_sethook</code></h3>
3568<pre>3617<pre>
3569 int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);3618 int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
3570</pre>3619</pre>
@@ -3601,7 +3650,7 @@ or when it jumps back in the code (even to the same line). · 30 unmodified lines
3601<p>A hook is disabled by setting <code>mask</code> to zero.3650<p>A hook is disabled by setting <code>mask</code> to zero.
3602 3651
3603<p><a name="lua_setlocal"></a>3652<p><a name="lua_setlocal"></a>
3604<hr /><h3><code>lua_setlocal</code></h3>3653<hr></hr><h3><code>lua_setlocal</code></h3>
3605<pre>3654<pre>
3606 const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);3655 const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
3607</pre>3656</pre>
@@ -3619,7 +3668,7 @@ when the index is greater than · 11 unmodified lines
3619the number of active local variables.3668the number of active local variables.
3620 3669
3621<p><a name="lua_setupvalue"></a>3670<p><a name="lua_setupvalue"></a>
3622<hr /><h3><code>lua_setupvalue</code></h3>3671<hr></hr><h3><code>lua_setupvalue</code></h3>
3623<pre>3672<pre>
3624 const char *lua_setupvalue (lua_State *L, int funcindex, int n);3673 const char *lua_setupvalue (lua_State *L, int funcindex, int n);
3625</pre>3674</pre>
@@ -3668,7 +3717,7 @@ you should not use these functions for other stack values. · 42 unmodified lines
3668in alphabetical order.3717in alphabetical order.
3669 3718
3670<p><a name="luaL_addchar"></a>3719<p><a name="luaL_addchar"></a>
3671<hr /><h3><code>luaL_addchar</code></h3>3720<hr></hr><h3><code>luaL_addchar</code></h3>
3672<pre>3721<pre>
3673 void luaL_addchar (luaL_Buffer B, char c);3722 void luaL_addchar (luaL_Buffer B, char c);
3674</pre>3723</pre>
@@ -3678,7 +3727,7 @@ in alphabetical order. · 3 unmodified lines
3678(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).3727(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
3679 3728
3680<p><a name="luaL_addlstring"></a>3729<p><a name="luaL_addlstring"></a>
3681<hr /><h3><code>luaL_addlstring</code></h3>3730<hr></hr><h3><code>luaL_addlstring</code></h3>
3682<pre>3731<pre>
3683 void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);3732 void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
3684</pre>3733</pre>
@@ -3690,7 +3739,7 @@ the buffer <code>B</code> · 5 unmodified lines
3690The string may contain embedded zeros.3739The string may contain embedded zeros.
3691 3740
3692<p><a name="luaL_addsize"></a>3741<p><a name="luaL_addsize"></a>
3693<hr /><h3><code>luaL_addsize</code></h3>3742<hr></hr><h3><code>luaL_addsize</code></h3>
3694<pre>3743<pre>
3695 void luaL_addsize (luaL_Buffer B, size_t n);3744 void luaL_addsize (luaL_Buffer B, size_t n);
3696</pre>3745</pre>
@@ -3701,7 +3750,7 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>) to · 4 unmodified lines
3701(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).3750(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
3702 3751
3703<p><a name="luaL_addstring"></a>3752<p><a name="luaL_addstring"></a>
3704<hr /><h3><code>luaL_addstring</code></h3>3753<hr></hr><h3><code>luaL_addstring</code></h3>
3705<pre>3754<pre>
3706 void luaL_addstring (luaL_Buffer *B, const char *s);3755 void luaL_addstring (luaL_Buffer *B, const char *s);
3707</pre>3756</pre>
@@ -3713,7 +3762,7 @@ to the buffer <code>B</code> · 5 unmodified lines
3713The string may not contain embedded zeros.3762The string may not contain embedded zeros.
3714 3763
3715<p><a name="luaL_addvalue"></a>3764<p><a name="luaL_addvalue"></a>
3716<hr /><h3><code>luaL_addvalue</code></h3>3765<hr></hr><h3><code>luaL_addvalue</code></h3>
3717<pre>3766<pre>
3718 void luaL_addvalue (luaL_Buffer *B);3767 void luaL_addvalue (luaL_Buffer *B);
3719</pre>3768</pre>
@@ -3729,7 +3778,7 @@ be called with an extra element on the stack, · 9 unmodified lines
3729which is the value to be added to the buffer.3778which is the value to be added to the buffer.
3730 3779
3731<p><a name="luaL_argcheck"></a>3780<p><a name="luaL_argcheck"></a>
3732<hr /><h3><code>luaL_argcheck</code></h3>3781<hr></hr><h3><code>luaL_argcheck</code></h3>
3733<pre>3782<pre>
3734 void luaL_argcheck (lua_State *L, int cond, int numarg,3783 void luaL_argcheck (lua_State *L, int cond, int numarg,
3735 const char *extramsg);3784 const char *extramsg);
@@ -3742,7 +3791,7 @@ If not, raises an error with message · 6 unmodified lines
3742where <code>func</code> is retrieved from the call stack.3791where <code>func</code> is retrieved from the call stack.
3743 3792
3744<p><a name="luaL_argerror"></a>3793<p><a name="luaL_argerror"></a>
3745<hr /><h3><code>luaL_argerror</code></h3>3794<hr></hr><h3><code>luaL_argerror</code></h3>
3746<pre>3795<pre>
3747 int luaL_argerror (lua_State *L, int numarg, const char *extramsg);3796 int luaL_argerror (lua_State *L, int numarg, const char *extramsg);
3748</pre>3797</pre>
@@ -3757,7 +3806,7 @@ but it is an idiom to use it as <code>return luaL_argerror ...</code> · 8 unmodified lines
3757in C functions.3806in C functions.
3758 3807
3759<p><a name="luaL_Buffer"></a>3808<p><a name="luaL_Buffer"></a>
3760<hr /><h3><code>luaL_Buffer</code></h3>3809<hr></hr><h3><code>luaL_Buffer</code></h3>
3761<pre>3810<pre>
3762 typedef struct luaL_Buffer luaL_Buffer;3811 typedef struct luaL_Buffer luaL_Buffer;
3763</pre>3812</pre>
@@ -3772,7 +3821,7 @@ Its pattern of use is as follows: · 8 unmodified lines
3772<li> Then you initialize it with a call <code>luaL_buffinit(L, &#038;b)</code>.3821<li> Then you initialize it with a call <code>luaL_buffinit(L, &#038;b)</code>.
3773<li> Then you add string pieces to the buffer calling any of3822<li> Then you add string pieces to the buffer calling any of
3774the <code>luaL_add*</code> functions.3823the <code>luaL_add*</code> functions.
3775<li> You finish calling <code>luaL_pushresult(&#038;b)</code>.3824<li> You finish by calling <code>luaL_pushresult(&#038;b)</code>.
3776That call leaves the final string on the top of the stack.3825That call leaves the final string on the top of the stack.
3777</ul>3826</ul>
3778 3827
@@ -3792,7 +3841,7 @@ level when the buffer was initialized, · 13 unmodified lines
3792plus the final string on its top.3841plus the final string on its top.
3793 3842
3794<p><a name="luaL_buffinit"></a>3843<p><a name="luaL_buffinit"></a>
3795<hr /><h3><code>luaL_buffinit</code></h3>3844<hr></hr><h3><code>luaL_buffinit</code></h3>
3796<pre>3845<pre>
3797 void luaL_buffinit (lua_State *L, luaL_Buffer *B);3846 void luaL_buffinit (lua_State *L, luaL_Buffer *B);
3798</pre>3847</pre>
@@ -3804,7 +3853,7 @@ the buffer must be declared as a variable · 5 unmodified lines
3804(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).3853(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
3805 3854
3806<p><a name="luaL_callmeta"></a>3855<p><a name="luaL_callmeta"></a>
3807<hr /><h3><code>luaL_callmeta</code></h3>3856<hr></hr><h3><code>luaL_callmeta</code></h3>
3808<pre>3857<pre>
3809 int luaL_callmeta (lua_State *L, int obj, const char *e);3858 int luaL_callmeta (lua_State *L, int obj, const char *e);
3810</pre>3859</pre>
@@ -3821,7 +3870,7 @@ If there is no metatable or no metamethod, · 10 unmodified lines
3821this function returns 0 (without pushing any value on the stack).3870this function returns 0 (without pushing any value on the stack).
3822 3871
3823<p><a name="luaL_checkany"></a>3872<p><a name="luaL_checkany"></a>
3824<hr /><h3><code>luaL_checkany</code></h3>3873<hr></hr><h3><code>luaL_checkany</code></h3>
3825<pre>3874<pre>
3826 void luaL_checkany (lua_State *L, int narg);3875 void luaL_checkany (lua_State *L, int narg);
3827</pre>3876</pre>
@@ -3831,7 +3880,7 @@ this function returns 0 (without pushing any value on the stack). · 3 unmodified lines
3831of any type (including <b>nil</b>) at position <code>narg</code>.3880of any type (including <b>nil</b>) at position <code>narg</code>.
3832 3881
3833<p><a name="luaL_checkint"></a>3882<p><a name="luaL_checkint"></a>
3834<hr /><h3><code>luaL_checkint</code></h3>3883<hr></hr><h3><code>luaL_checkint</code></h3>
3835<pre>3884<pre>
3836 int luaL_checkint (lua_State *L, int narg);3885 int luaL_checkint (lua_State *L, int narg);
3837</pre>3886</pre>
@@ -3841,7 +3890,7 @@ of any type (including <b>nil</b>) at position <code>narg</code>. · 3 unmodified lines
3841and returns that number cast to an <code>int</code>.3890and returns that number cast to an <code>int</code>.
3842 3891
3843<p><a name="luaL_checkinteger"></a>3892<p><a name="luaL_checkinteger"></a>
3844<hr /><h3><code>luaL_checkinteger</code></h3>3893<hr></hr><h3><code>luaL_checkinteger</code></h3>
3845<pre>3894<pre>
3846 lua_Integer luaL_checkinteger (lua_State *L, int narg);3895 lua_Integer luaL_checkinteger (lua_State *L, int narg);
3847</pre>3896</pre>
@@ -3851,7 +3900,7 @@ and returns that number cast to an <code>int</code>. · 3 unmodified lines
3851and returns that number cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.3900and returns that number cast to a <a href="#lua_Integer"><code>lua_Integer</code></a>.
3852 3901
3853<p><a name="luaL_checklong"></a>3902<p><a name="luaL_checklong"></a>
3854<hr /><h3><code>luaL_checklong</code></h3>3903<hr></hr><h3><code>luaL_checklong</code></h3>
3855<pre>3904<pre>
3856 long luaL_checklong (lua_State *L, int narg);3905 long luaL_checklong (lua_State *L, int narg);
3857</pre>3906</pre>
@@ -3861,9 +3910,9 @@ and returns that number cast to a <a href="#lua_Integer"><code>lua_Integer</code · 3 unmodified lines
3861and returns that number cast to a <code>long</code>.3910and returns that number cast to a <code>long</code>.
3862 3911
3863<p><a name="luaL_checklstring"></a>3912<p><a name="luaL_checklstring"></a>
3864<hr /><h3><code>luaL_checklstring</code></h3>3913<hr></hr><h3><code>luaL_checklstring</code></h3>
3865<pre>3914<pre>
3866 const char *luaL_checklstring (lua_State *L, int numArg, size_t *l);3915 const char *luaL_checklstring (lua_State *L, int narg, size_t *l);
3867</pre>3916</pre>
3868 3917
3869 3918
@@ -3873,9 +3922,9 @@ if <code>l</code> is not <code>NULL</code> fills <code>*l</code> · 3 unmodified lines
3873with the string's length.3922with the string's length.
3874 3923
3875<p><a name="luaL_checknumber"></a>3924<p><a name="luaL_checknumber"></a>
3876<hr /><h3><code>luaL_checknumber</code></h3>3925<hr></hr><h3><code>luaL_checknumber</code></h3>
3877<pre>3926<pre>
3878 lua_Number luaL_checknumber (lua_State *L, int numArg);3927 lua_Number luaL_checknumber (lua_State *L, int narg);
3879</pre>3928</pre>
3880 3929
3881 3930
@@ -3883,7 +3932,7 @@ with the string's length. · 1 unmodified line
3883and returns that number.3932and returns that number.
3884 3933
3885<p><a name="luaL_checkoption"></a>3934<p><a name="luaL_checkoption"></a>
3886<hr /><h3><code>luaL_checkoption</code></h3>3935<hr></hr><h3><code>luaL_checkoption</code></h3>
3887<pre>3936<pre>
3888 int luaL_checkoption (lua_State *L, int narg, const char *def,3937 int luaL_checkoption (lua_State *L, int narg, const char *def,
3889 const char *const lst[]);3938 const char *const lst[]);
@@ -3902,11 +3951,11 @@ Raises an error if the argument is not a string or · 12 unmodified lines
3902if the string cannot be found.3951if the string cannot be found.
3903 3952
3904<p>This is a useful function for mapping strings to C enums.3953<p>This is a useful function for mapping strings to C enums.
3905The usual interfaces in Lua libraries is to use strings instead of numbers3954The usual convention in Lua libraries is to use strings instead of numbers
3906to select options.3955to select options.
3907 3956
3908<p><a name="luaL_checkstack"></a>3957<p><a name="luaL_checkstack"></a>
3909<hr /><h3><code>luaL_checkstack</code></h3>3958<hr></hr><h3><code>luaL_checkstack</code></h3>
3910<pre>3959<pre>
3911 void luaL_checkstack (lua_State *L, int sz, const char *msg);3960 void luaL_checkstack (lua_State *L, int sz, const char *msg);
3912</pre>3961</pre>
@@ -3917,7 +3966,7 @@ raising an error if the stack cannot grow to that size. · 4 unmodified lines
3917<code>msg</code> is an additional text to go into the error message.3966<code>msg</code> is an additional text to go into the error message.
3918 3967
3919<p><a name="luaL_checkstring"></a>3968<p><a name="luaL_checkstring"></a>
3920<hr /><h3><code>luaL_checkstring</code></h3>3969<hr></hr><h3><code>luaL_checkstring</code></h3>
3921<pre>3970<pre>
3922 const char *luaL_checkstring (lua_State *L, int narg);3971 const char *luaL_checkstring (lua_State *L, int narg);
3923</pre>3972</pre>
@@ -3927,7 +3976,7 @@ raising an error if the stack cannot grow to that size. · 3 unmodified lines
3927and returns that string.3976and returns that string.
3928 3977
3929<p><a name="luaL_checktype"></a>3978<p><a name="luaL_checktype"></a>
3930<hr /><h3><code>luaL_checktype</code></h3>3979<hr></hr><h3><code>luaL_checktype</code></h3>
3931<pre>3980<pre>
3932 void luaL_checktype (lua_State *L, int narg, int t);3981 void luaL_checktype (lua_State *L, int narg, int t);
3933</pre>3982</pre>
@@ -3936,9 +3985,9 @@ and returns that string. · 2 unmodified lines
3936<p>Checks whether the function argument <code>narg</code> has type <code>t</code>.3985<p>Checks whether the function argument <code>narg</code> has type <code>t</code>.
3937 3986
3938<p><a name="luaL_checkudata"></a>3987<p><a name="luaL_checkudata"></a>
3939<hr /><h3><code>luaL_checkudata</code></h3>3988<hr></hr><h3><code>luaL_checkudata</code></h3>
3940<pre>3989<pre>
3941 void *luaL_checkudata (lua_State *L, int ud, const char *tname);3990 void *luaL_checkudata (lua_State *L, int narg, const char *tname);
3942</pre>3991</pre>
3943 3992
3944 3993
@@ -3946,7 +3995,7 @@ and returns that string. · 1 unmodified line
3946of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).3995of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
3947 3996
3948<p><a name="luaL_error"></a>3997<p><a name="luaL_error"></a>
3949<hr /><h3><code>luaL_error</code></h3>3998<hr></hr><h3><code>luaL_error</code></h3>
3950<pre>3999<pre>
3951 int luaL_error (lua_State *L, const char *fmt, ...);4000 int luaL_error (lua_State *L, const char *fmt, ...);
3952</pre>4001</pre>
@@ -3954,7 +4003,7 @@ of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newm · 1 unmodified line
3954 4003
3955<p>Raises an error.4004<p>Raises an error.
3956The error message format is given by <code>fmt</code>4005The error message format is given by <code>fmt</code>
3957plus any extra argument,4006plus any extra arguments,
3958following the same rules of <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>.4007following the same rules of <a href="#lua_pushfstring"><code>lua_pushfstring</code></a>.
3959It also adds at the beginning of the message the file name and4008It also adds at the beginning of the message the file name and
3960the line number where the error occurred,4009the line number where the error occurred,
@@ -3965,7 +4014,7 @@ but it is an idiom to use it as <code>return luaL_error ...</code> · 4 unmodified lines
3965in C functions.4014in C functions.
3966 4015
3967<p><a name="luaL_getmetafield"></a>4016<p><a name="luaL_getmetafield"></a>
3968<hr /><h3><code>luaL_getmetafield</code></h3>4017<hr></hr><h3><code>luaL_getmetafield</code></h3>
3969<pre>4018<pre>
3970 int luaL_getmetafield (lua_State *L, int obj, const char *e);4019 int luaL_getmetafield (lua_State *L, int obj, const char *e);
3971</pre>4020</pre>
@@ -3978,7 +4027,7 @@ or if the metatable does not have that field, · 6 unmodified lines
3978returns 0 and pushes nothing.4027returns 0 and pushes nothing.
3979 4028
3980<p><a name="luaL_getmetatable"></a>4029<p><a name="luaL_getmetatable"></a>
3981<hr /><h3><code>luaL_getmetatable</code></h3>4030<hr></hr><h3><code>luaL_getmetatable</code></h3>
3982<pre>4031<pre>
3983 void luaL_getmetatable (lua_State *L, const char *tname);4032 void luaL_getmetatable (lua_State *L, const char *tname);
3984</pre>4033</pre>
@@ -3988,7 +4037,7 @@ returns 0 and pushes nothing. · 3 unmodified lines
3988in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).4037in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
3989 4038
3990<p><a name="luaL_gsub"></a>4039<p><a name="luaL_gsub"></a>
3991<hr /><h3><code>luaL_gsub</code></h3>4040<hr></hr><h3><code>luaL_gsub</code></h3>
3992<pre>4041<pre>
3993 const char *luaL_gsub (lua_State *L, const char *s,4042 const char *luaL_gsub (lua_State *L, const char *s,
3994 const char *p, const char *r);4043 const char *p, const char *r);
@@ -4001,7 +4050,7 @@ with the string <code>r</code>. · 6 unmodified lines
4001Pushes the resulting string on the stack and returns it.4050Pushes the resulting string on the stack and returns it.
4002 4051
4003<p><a name="luaL_loadbuffer"></a>4052<p><a name="luaL_loadbuffer"></a>
4004<hr /><h3><code>luaL_loadbuffer</code></h3>4053<hr></hr><h3><code>luaL_loadbuffer</code></h3>
4005<pre>4054<pre>
4006 int luaL_loadbuffer (lua_State *L, const char *buff,4055 int luaL_loadbuffer (lua_State *L, const char *buff,
4007 size_t sz, const char *name);4056 size_t sz, const char *name);
@@ -4017,7 +4066,7 @@ buffer pointed by <code>buff</code> with size <code>sz</code>. · 9 unmodified lines
4017used for debug information and error messages.4066used for debug information and error messages.
4018 4067
4019<p><a name="luaL_loadfile"></a>4068<p><a name="luaL_loadfile"></a>
4020<hr /><h3><code>luaL_loadfile</code></h3>4069<hr></hr><h3><code>luaL_loadfile</code></h3>
4021<pre>4070<pre>
4022 int luaL_loadfile (lua_State *L, const char *filename);4071 int luaL_loadfile (lua_State *L, const char *filename);
4023</pre>4072</pre>
@@ -4035,7 +4084,7 @@ but it has an extra error code <code>LUA_ERRFILE</code> · 11 unmodified lines
4035if it cannot open/read the file.4084if it cannot open/read the file.
4036 4085
4037<p><a name="luaL_loadstring"></a>4086<p><a name="luaL_loadstring"></a>
4038<hr /><h3><code>luaL_loadstring</code></h3>4087<hr></hr><h3><code>luaL_loadstring</code></h3>
4039<pre>4088<pre>
4040 int luaL_loadstring (lua_State *L, const char *s);4089 int luaL_loadstring (lua_State *L, const char *s);
4041</pre>4090</pre>
@@ -4048,24 +4097,24 @@ the zero-terminated string <code>s</code>. · 6 unmodified lines
4048<p>This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.4097<p>This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>.
4049 4098
4050<p><a name="luaL_newmetatable"></a>4099<p><a name="luaL_newmetatable"></a>
4051<hr /><h3><code>luaL_newmetatable</code></h3>4100<hr></hr><h3><code>luaL_newmetatable</code></h3>
4052<pre>4101<pre>
4053 int luaL_newmetatable (lua_State *L, const char *tname);4102 int luaL_newmetatable (lua_State *L, const char *tname);
4054</pre>4103</pre>
4055 4104
4056 4105
4057<p>If the registry already has the key <code>"tname"</code>,4106<p>If the registry already has the key <code>tname</code>,
4058returns 0.4107returns 0.
4059Otherwise,4108Otherwise,
4060creates a new table to be used as a metatable for userdata,4109creates a new table to be used as a metatable for userdata,
4061adds it to the registry with key <code>"tname"</code>,4110adds it to the registry with key <code>tname</code>,
4062and returns 1.4111and returns 1.
4063 4112
4064<p>In both cases pushes on the stack the final value associated4113<p>In both cases pushes on the stack the final value associated
4065with <code>"tname"</code> in the registry.4114with <code>tname</code> in the registry.
4066 4115
4067<p><a name="luaL_newstate"></a>4116<p><a name="luaL_newstate"></a>
4068<hr /><h3><code>luaL_newstate</code></h3>4117<hr></hr><h3><code>luaL_newstate</code></h3>
4069<pre>4118<pre>
4070 lua_State *luaL_newstate (void);4119 lua_State *luaL_newstate (void);
4071</pre>4120</pre>
@@ -4080,8 +4129,17 @@ errors. · 8 unmodified lines
4080<p>Returns the new state,4129<p>Returns the new state,
4081or <code>NULL</code> if there is a memory allocation error.4130or <code>NULL</code> if there is a memory allocation error.
4082 4131
4132<p><a name="luaL_openlibs"></a>
4133<hr></hr><h3><code>luaL_openlibs</code></h3>
4134<pre>
4135 void luaL_openlibs (lua_State *L);
4136</pre>
4137
4138
4139<p>Opens all standard Lua libraries into the given state.
4140
4083<p><a name="luaL_optint"></a>4141<p><a name="luaL_optint"></a>
4084<hr /><h3><code>luaL_optint</code></h3>4142<hr></hr><h3><code>luaL_optint</code></h3>
4085<pre>4143<pre>
4086 int luaL_optint (lua_State *L, int narg, int d);4144 int luaL_optint (lua_State *L, int narg, int d);
4087</pre>4145</pre>
@@ -4094,9 +4152,9 @@ returns <code>d</code>. · 6 unmodified lines
4094Otherwise, raises an error.4152Otherwise, raises an error.
4095 4153
4096<p><a name="luaL_optinteger"></a>4154<p><a name="luaL_optinteger"></a>
4097<hr /><h3><code>luaL_optinteger</code></h3>4155<hr></hr><h3><code>luaL_optinteger</code></h3>
4098<pre>4156<pre>
4099 lua_Integer luaL_optinteger (lua_State *L, int nArg, lua_Integer d);4157 lua_Integer luaL_optinteger (lua_State *L, int narg, lua_Integer d);
4100</pre>4158</pre>
4101 4159
4102 4160
@@ -4107,7 +4165,7 @@ returns <code>d</code>. · 4 unmodified lines
4107Otherwise, raises an error.4165Otherwise, raises an error.
4108 4166
4109<p><a name="luaL_optlong"></a>4167<p><a name="luaL_optlong"></a>
4110<hr /><h3><code>luaL_optlong</code></h3>4168<hr></hr><h3><code>luaL_optlong</code></h3>
4111<pre>4169<pre>
4112 long luaL_optlong (lua_State *L, int narg, long d);4170 long luaL_optlong (lua_State *L, int narg, long d);
4113</pre>4171</pre>
@@ -4120,9 +4178,9 @@ returns <code>d</code>. · 6 unmodified lines
4120Otherwise, raises an error.4178Otherwise, raises an error.
4121 4179
4122<p><a name="luaL_optlstring"></a>4180<p><a name="luaL_optlstring"></a>
4123<hr /><h3><code>luaL_optlstring</code></h3>4181<hr></hr><h3><code>luaL_optlstring</code></h3>
4124<pre>4182<pre>
4125 const char *luaL_optlstring (lua_State *L, int numArg,4183 const char *luaL_optlstring (lua_State *L, int narg,
4126 const char *d, size_t *l);4184 const char *d, size_t *l);
4127</pre>4185</pre>
4128 4186
@@ -4137,9 +4195,9 @@ Otherwise, raises an error. · 8 unmodified lines
4137fills the position <code>*l</code> with the results's length.4195fills the position <code>*l</code> with the results's length.
4138 4196
4139<p><a name="luaL_optnumber"></a>4197<p><a name="luaL_optnumber"></a>
4140<hr /><h3><code>luaL_optnumber</code></h3>4198<hr></hr><h3><code>luaL_optnumber</code></h3>
4141<pre>4199<pre>
4142 lua_Number luaL_optnumber (lua_State *L, int nArg, lua_Number d);4200 lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
4143</pre>4201</pre>
4144 4202
4145 4203
@@ -4150,7 +4208,7 @@ returns <code>d</code>. · 4 unmodified lines
4150Otherwise, raises an error.4208Otherwise, raises an error.
4151 4209
4152<p><a name="luaL_optstring"></a>4210<p><a name="luaL_optstring"></a>
4153<hr /><h3><code>luaL_optstring</code></h3>4211<hr></hr><h3><code>luaL_optstring</code></h3>
4154<pre>4212<pre>
4155 const char *luaL_optstring (lua_State *L, int narg, const char *d);4213 const char *luaL_optstring (lua_State *L, int narg, const char *d);
4156</pre>4214</pre>
@@ -4163,7 +4221,7 @@ returns <code>d</code>. · 6 unmodified lines
4163Otherwise, raises an error.4221Otherwise, raises an error.
4164 4222
4165<p><a name="luaL_prepbuffer"></a>4223<p><a name="luaL_prepbuffer"></a>
4166<hr /><h3><code>luaL_prepbuffer</code></h3>4224<hr></hr><h3><code>luaL_prepbuffer</code></h3>
4167<pre>4225<pre>
4168 char *luaL_prepbuffer (luaL_Buffer *B);4226 char *luaL_prepbuffer (luaL_Buffer *B);
4169</pre>4227</pre>
@@ -4177,7 +4235,7 @@ After copying the string into that space you must call · 7 unmodified lines
4177it to the buffer.4235it to the buffer.
4178 4236
4179<p><a name="luaL_pushresult"></a>4237<p><a name="luaL_pushresult"></a>
4180<hr /><h3><code>luaL_pushresult</code></h3>4238<hr></hr><h3><code>luaL_pushresult</code></h3>
4181<pre>4239<pre>
4182 void luaL_pushresult (luaL_Buffer *B);4240 void luaL_pushresult (luaL_Buffer *B);
4183</pre>4241</pre>
@@ -4187,7 +4245,7 @@ it to the buffer. · 3 unmodified lines
4187the top of the stack.4245the top of the stack.
4188 4246
4189<p><a name="luaL_ref"></a>4247<p><a name="luaL_ref"></a>
4190<hr /><h3><code>luaL_ref</code></h3>4248<hr></hr><h3><code>luaL_ref</code></h3>
4191<pre>4249<pre>
4192 int luaL_ref (lua_State *L, int t);4250 int luaL_ref (lua_State *L, int t);
4193</pre>4251</pre>
@@ -4205,12 +4263,12 @@ by calling <code>lua_rawgeti(L, t, r)</code>. · 11 unmodified lines
4205Function <a href="#luaL_unref"><code>luaL_unref</code></a> frees a reference and its associated object.4263Function <a href="#luaL_unref"><code>luaL_unref</code></a> frees a reference and its associated object.
4206 4264
4207<p>If the object at the top of the stack is <b>nil</b>,4265<p>If the object at the top of the stack is <b>nil</b>,
4208<a href="#luaL_ref"><code>luaL_ref</code></a> returns the same reference <code>LUA_REFNIL</code>.4266<a href="#luaL_ref"><code>luaL_ref</code></a> returns the constant <code>LUA_REFNIL</code>.
4209The constant <code>LUA_NOREF</code> is guaranteed to be different4267The constant <code>LUA_NOREF</code> is guaranteed to be different
4210from any reference returned by <a href="#luaL_ref"><code>luaL_ref</code></a>.4268from any reference returned by <a href="#luaL_ref"><code>luaL_ref</code></a>.
4211 4269
4212<p><a name="luaL_Reg"></a>4270<p><a name="luaL_Reg"></a>
4213<hr /><h3><code>luaL_Reg</code></h3>4271<hr></hr><h3><code>luaL_Reg</code></h3>
4214<pre>4272<pre>
4215 typedef struct luaL_Reg {4273 typedef struct luaL_Reg {
4216 const char *name;4274 const char *name;
@@ -4228,7 +4286,7 @@ Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sent · 11 unmodified lines
4228in which both <code>name</code> and <code>func</code> are <code>NULL</code>.4286in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
4229 4287
4230<p><a name="luaL_register"></a>4288<p><a name="luaL_register"></a>
4231<hr /><h3><code>luaL_register</code></h3>4289<hr></hr><h3><code>luaL_register</code></h3>
4232<pre>4290<pre>
4233 void luaL_register (lua_State *L, const char *libname,4291 void luaL_register (lua_State *L, const char *libname,
4234 const luaL_Reg *l);4292 const luaL_Reg *l);
@@ -4254,7 +4312,7 @@ reuses that table instead of creating a new one. · 19 unmodified lines
4254on the top of the stack.4312on the top of the stack.
4255 4313
4256<p><a name="luaL_typename"></a>4314<p><a name="luaL_typename"></a>
4257<hr /><h3><code>luaL_typename</code></h3>4315<hr></hr><h3><code>luaL_typename</code></h3>
4258<pre>4316<pre>
4259 const char *luaL_typename (lua_State *L, int idx);4317 const char *luaL_typename (lua_State *L, int idx);
4260</pre>4318</pre>
@@ -4263,7 +4321,7 @@ on the top of the stack. · 2 unmodified lines
4263<p>Returns the name of the type of the value at index <code>idx</code>.4321<p>Returns the name of the type of the value at index <code>idx</code>.
4264 4322
4265<p><a name="luaL_typerror"></a>4323<p><a name="luaL_typerror"></a>
4266<hr /><h3><code>luaL_typerror</code></h3>4324<hr></hr><h3><code>luaL_typerror</code></h3>
4267<pre>4325<pre>
4268 int luaL_typerror (lua_State *L, int narg, const char *tname);4326 int luaL_typerror (lua_State *L, int narg, const char *tname);
4269</pre>4327</pre>
@@ -4278,7 +4336,7 @@ where <code>&#060;location></code> is produced by <a href="#luaL_where"><code>lu · 8 unmodified lines
4278and <code>&#060;realt></code> is the type name of the actual argument.4336and <code>&#060;realt></code> is the type name of the actual argument.
4279 4337
4280<p><a name="luaL_unref"></a>4338<p><a name="luaL_unref"></a>
4281<hr /><h3><code>luaL_unref</code></h3>4339<hr></hr><h3><code>luaL_unref</code></h3>
4282<pre>4340<pre>
4283 void luaL_unref (lua_State *L, int t, int ref);4341 void luaL_unref (lua_State *L, int t, int ref);
4284</pre>4342</pre>
@@ -4294,7 +4352,7 @@ The reference <code>ref</code> is also freed to be used again. · 9 unmodified lines
4294<a href="#luaL_unref"><code>luaL_unref</code></a> does nothing.4352<a href="#luaL_unref"><code>luaL_unref</code></a> does nothing.
4295 4353
4296<p><a name="luaL_where"></a>4354<p><a name="luaL_where"></a>
4297<hr /><h3><code>luaL_where</code></h3>4355<hr></hr><h3><code>luaL_where</code></h3>
4298<pre>4356<pre>
4299 void luaL_where (lua_State *L, int lvl);4357 void luaL_where (lua_State *L, int lvl);
4300</pre>4358</pre>
@@ -4363,14 +4421,14 @@ If you do not include this library in your application, · 62 unmodified lines
4363you should check carefully whether you need to provide 4421you should check carefully whether you need to provide
4364implementations for some of its facilities.4422implementations for some of its facilities.
4365 4423
4366<p><a name="pdf-assert"></a><hr /><h3><code>assert (v [, message])</code></h3>4424<p><a name="pdf-assert"></a><hr></hr><h3><code>assert (v [, message])</code></h3>
4367Issues an error when4425Issues an error when
4368the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);4426the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
4369otherwise, returns all its arguments.4427otherwise, returns all its arguments.
4370<code>message</code> is an error message;4428<code>message</code> is an error message;
4371when absent, it defaults to "assertion failed!"4429when absent, it defaults to "assertion failed!"
4372 4430
4373<p><a name="pdf-collectgarbage"></a><hr /><h3><code>collectgarbage (opt [, arg])</code></h3>4431<p><a name="pdf-collectgarbage"></a><hr></hr><h3><code>collectgarbage (opt [, arg])</code></h3>
4374 4432
4375<p>This function is a generic interface to the garbage collector.4433<p>This function is a generic interface to the garbage collector.
4376It performs different functions according to its first argument, <code>opt</code>:4434It 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 · 16 unmodified lines
4393the collector (see <a href="#GC">2.10</a>).4451the collector (see <a href="#GC">2.10</a>).
4394</ul>4452</ul>
4395 4453
4396<p><a name="pdf-dofile"></a><hr /><h3><code>dofile (filename)</code></h3>4454<p><a name="pdf-dofile"></a><hr></hr><h3><code>dofile (filename)</code></h3>
4397Opens the named file and executes its contents as a Lua chunk.4455Opens the named file and executes its contents as a Lua chunk.
4398When called without arguments,4456When called without arguments,
4399<code>dofile</code> executes the contents of the standard input (<code>stdin</code>).4457<code>dofile</code> executes the contents of the standard input (<code>stdin</code>).
@@ -4401,7 +4459,7 @@ Returns all values returned by the chunk. · 1 unmodified line
4401In case of errors, <code>dofile</code> propagates the error4459In case of errors, <code>dofile</code> propagates the error
4402to its caller (that is, <code>dofile</code> does not run in protected mode).4460to its caller (that is, <code>dofile</code> does not run in protected mode).
4403 4461
4404<p><a name="pdf-error"></a><hr /><h3><code>error (message [, level])</code></h3>4462<p><a name="pdf-error"></a><hr></hr><h3><code>error (message [, level])</code></h3>
4405Terminates the last protected function called4463Terminates the last protected function called
4406and returns <code>message</code> as the error message.4464and returns <code>message</code> as the error message.
4407Function <code>error</code> never returns.4465Function <code>error</code> never returns.
@@ -4416,7 +4474,7 @@ that called <code>error</code> was called; and so on. · 8 unmodified lines
4416Passing a level 0 avoids the addition of error position information4474Passing a level 0 avoids the addition of error position information
4417to the message.4475to the message.
4418 4476
4419<p><a name="pdf-_G"></a><hr /><h3><code>_G</code></h3>4477<p><a name="pdf-_G"></a><hr></hr><h3><code>_G</code></h3>
4420A global variable (not a function) that4478A global variable (not a function) that
4421holds the global environment (that is, <code>_G._G = _G</code>).4479holds the global environment (that is, <code>_G._G = _G</code>).
4422Lua itself does not use this variable;4480Lua itself does not use this variable;
@@ -4424,7 +4482,7 @@ changing its value does not affect any environment, · 1 unmodified line
4424nor vice-versa.4482nor vice-versa.
4425(Use <a href="#pdf-setfenv"><code>setfenv</code></a> to change environments.)4483(Use <a href="#pdf-setfenv"><code>setfenv</code></a> to change environments.)
4426 4484
4427<p><a name="pdf-getfenv"></a><hr /><h3><code>getfenv (f)</code></h3>4485<p><a name="pdf-getfenv"></a><hr></hr><h3><code>getfenv (f)</code></h3>
4428Returns the current environment in use by the function.4486Returns the current environment in use by the function.
4429<code>f</code> can be a Lua function or a number4487<code>f</code> can be a Lua function or a number
4430that specifies the function at that stack level:4488that specifies the function at that stack level:
@@ -4434,7 +4492,7 @@ or if <code>f</code> is 0, · 3 unmodified lines
4434<code>getfenv</code> returns the global environment.4492<code>getfenv</code> returns the global environment.
4435The default for <code>f</code> is 1.4493The default for <code>f</code> is 1.
4436 4494
4437<p><a name="pdf-getmetatable"></a><hr /><h3><code>getmetatable (object)</code></h3>4495<p><a name="pdf-getmetatable"></a><hr></hr><h3><code>getmetatable (object)</code></h3>
4438 4496
4439<p>If <code>object</code> does not have a metatable, returns <b>nil</b>.4497<p>If <code>object</code> does not have a metatable, returns <b>nil</b>.
4440Otherwise,4498Otherwise,
@@ -4442,7 +4500,7 @@ if the object's metatable has a <code>"__metatable"</code> field, · 1 unmodified line
4442returns the associated value.4500returns the associated value.
4443Otherwise, returns the metatable of the given object.4501Otherwise, returns the metatable of the given object.
4444 4502
4445<p><a name="pdf-ipairs"></a><hr /><h3><code>ipairs (t)</code></h3>4503<p><a name="pdf-ipairs"></a><hr></hr><h3><code>ipairs (t)</code></h3>
4446 4504
4447<p>Returns three values: an iterator function, the table <code>t</code>, and 0,4505<p>Returns three values: an iterator function, the table <code>t</code>, and 0,
4448so that the construction4506so that the construction
@@ -4454,7 +4512,7 @@ up to the first integer key with a nil value in the table. · 5 unmodified lines
4454 4512
4455<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.4513<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
4456 4514
4457<p><a name="pdf-load"></a><hr /><h3><code>load (func [, chunkname])</code></h3>4515<p><a name="pdf-load"></a><hr></hr><h3><code>load (func [, chunkname])</code></h3>
4458 4516
4459<p>Loads a chunk using function <code>func</code> to get its pieces.4517<p>Loads a chunk using function <code>func</code> to get its pieces.
4460Each call to <code>func</code> must return a string that concatenates4518Each 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. · 8 unmodified lines
4469<p><code>chunkname</code> is used as the chunk name for error messages4527<p><code>chunkname</code> is used as the chunk name for error messages
4470and debug information.4528and debug information.
4471 4529
4472<p><a name="pdf-loadfile"></a><hr /><h3><code>loadfile ([filename])</code></h3>4530<p><a name="pdf-loadfile"></a><hr></hr><h3><code>loadfile ([filename])</code></h3>
4473 4531
4474<p>Similar to <a href="#pdf-load"><code>load</code></a>,4532<p>Similar to <a href="#pdf-load"><code>load</code></a>,
4475but gets the chunk from file <code>filename</code>4533but gets the chunk from file <code>filename</code>
4476or from the standard input,4534or from the standard input,
4477if no file name given.4535if no file name is given.
4478 4536
4479<p><a name="pdf-loadstring"></a><hr /><h3><code>loadstring (string [, chunkname])</code></h3>4537<p><a name="pdf-loadstring"></a><hr></hr><h3><code>loadstring (string [, chunkname])</code></h3>
4480 4538
4481<p>Similar to <a href="#pdf-load"><code>load</code></a>,4539<p>Similar to <a href="#pdf-load"><code>load</code></a>,
4482but gets the chunk from the given string.4540but gets the chunk from the given string.
@@ -4486,7 +4544,7 @@ but gets the chunk from the given string. · 3 unmodified lines
4486 assert(loadstring(s))()4544 assert(loadstring(s))()
4487</pre>4545</pre>
4488 4546
4489<p><a name="pdf-next"></a><hr /><h3><code>next (table [, index])</code></h3>4547<p><a name="pdf-next"></a><hr></hr><h3><code>next (table [, index])</code></h3>
4490 4548
4491<p>Allows a program to traverse all fields of a table.4549<p>Allows a program to traverse all fields of a table.
4492Its first argument is a table and its second argument4550Its 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. · 25 unmodified lines
4518You may however modify existing fields.4576You may however modify existing fields.
4519In particular, you may clear existing fields.4577In particular, you may clear existing fields.
4520 4578
4521<p><a name="pdf-pairs"></a><hr /><h3><code>pairs (t)</code></h3>4579<p><a name="pdf-pairs"></a><hr></hr><h3><code>pairs (t)</code></h3>
4522 4580
4523<p>Returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</code>, and <b>nil</b>,4581<p>Returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</code>, and <b>nil</b>,
4524so that the construction4582so that the construction
@@ -4529,7 +4587,7 @@ will iterate over all key--value pairs of table <code>t</code>. · 4 unmodified lines
4529 4587
4530<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.4588<p>See <a href="#pdf-next"><code>next</code></a> for the caveats of modifying the table during its traversal.
4531 4589
4532<p><a name="pdf-pcall"></a><hr /><h3><code>pcall (f, arg1, arg2, ...)</code></h3>4590<p><a name="pdf-pcall"></a><hr></hr><h3><code>pcall (f, arg1, arg2, ...)</code></h3>
4533 4591
4534<p>Calls function <code>f</code> with4592<p>Calls function <code>f</code> with
4535the given arguments in protected mode.4593the given arguments in protected mode.
@@ -4542,7 +4600,7 @@ In such case, <code>pcall</code> also returns all results from the call, · 6 unmodified lines
4542after this first result.4600after this first result.
4543In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.4601In case of any error, <code>pcall</code> returns <b>false</b> plus the error message.
4544 4602
4545<p><a name="pdf-print"></a><hr /><h3><code>print (e1, e2, ...)</code></h3>4603<p><a name="pdf-print"></a><hr></hr><h3><code>print (e1, e2, ...)</code></h3>
4546Receives any number of arguments,4604Receives any number of arguments,
4547and prints their values in <code>stdout</code>,4605and prints their values in <code>stdout</code>,
4548using the <a href="#pdf-tostring"><code>tostring</code></a> function to convert them to strings.4606using 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, · 2 unmodified lines
4551typically for debugging.4609typically for debugging.
4552For formatted output, use <a href="#pdf-string.format"><code>string.format</code></a>.4610For formatted output, use <a href="#pdf-string.format"><code>string.format</code></a>.
4553 4611
4554<p><a name="pdf-rawequal"></a><hr /><h3><code>rawequal (v1, v2)</code></h3>4612<p><a name="pdf-rawequal"></a><hr></hr><h3><code>rawequal (v1, v2)</code></h3>
4555Checks whether <code>v1</code> is equal to <code>v2</code>,4613Checks whether <code>v1</code> is equal to <code>v2</code>,
4556without invoking any metamethod.4614without invoking any metamethod.
4557Returns a boolean.4615Returns a boolean.
4558 4616
4559<p><a name="pdf-rawget"></a><hr /><h3><code>rawget (table, index)</code></h3>4617<p><a name="pdf-rawget"></a><hr></hr><h3><code>rawget (table, index)</code></h3>
4560Gets the real value of <code>table[index]</code>,4618Gets the real value of <code>table[index]</code>,
4561without invoking any metamethod.4619without invoking any metamethod.
4562<code>table</code> must be a table and4620<code>table</code> must be a table and
4563<code>index</code> any value different from <b>nil</b>.4621<code>index</code> any value different from <b>nil</b>.
4564 4622
4565<p><a name="pdf-rawset"></a><hr /><h3><code>rawset (table, index, value)</code></h3>4623<p><a name="pdf-rawset"></a><hr></hr><h3><code>rawset (table, index, value)</code></h3>
4566Sets the real value of <code>table[index]</code> to <code>value</code>,4624Sets the real value of <code>table[index]</code> to <code>value</code>,
4567without invoking any metamethod.4625without invoking any metamethod.
4568<code>table</code> must be a table,4626<code>table</code> must be a table,
4569<code>index</code> any value different from <b>nil</b>,4627<code>index</code> any value different from <b>nil</b>,
4570and <code>value</code> any Lua value.4628and <code>value</code> any Lua value.
4571 4629
4572<p><a name="pdf-select"></a><hr /><h3><code>select (index, ...)</code></h3>4630<p><a name="pdf-select"></a><hr></hr><h3><code>select (index, ...)</code></h3>
4573 4631
4574<p>If <code>index</code> is a number,4632<p>If <code>index</code> is a number,
4575returns all arguments after argument number <code>index</code>.4633returns all arguments after argument number <code>index</code>.
4576Otherwise, <code>index</code> must be the string <code>"#"</code>,4634Otherwise, <code>index</code> must be the string <code>"#"</code>,
4577and <code>select</code> returns the total number of extra arguments it received.4635and <code>select</code> returns the total number of extra arguments it received.
4578 4636
4579<p><a name="setfenv"></a><a name="pdf-setfenv"></a><hr /><h3><code>setfenv (f, table)</code></h3>4637<p><a name="setfenv"></a><a name="pdf-setfenv"></a><hr></hr><h3><code>setfenv (f, table)</code></h3>
4580 4638
4581<p>Sets the environment to be used by the given function.4639<p>Sets the environment to be used by the given function.
4582<code>f</code> can be a Lua function or a number4640<code>f</code> can be a Lua function or a number
@@ -4588,7 +4646,7 @@ Level 1 is the function calling <code>setfenv</code>. · 5 unmodified lines
4588the environment of the running thread.4646the environment of the running thread.
4589In this case, <code>setfenv</code> returns no values.4647In this case, <code>setfenv</code> returns no values.
4590 4648
4591<p><a name="pdf-setmetatable"></a><hr /><h3><code>setmetatable (table, metatable)</code></h3>4649<p><a name="pdf-setmetatable"></a><hr></hr><h3><code>setmetatable (table, metatable)</code></h3>
4592 4650
4593<p>Sets the metatable for the given table.4651<p>Sets the metatable for the given table.
4594(You cannot change the metatable of other types from Lua, only from C.)4652(You cannot change the metatable of other types from Lua, only from C.)
@@ -4599,7 +4657,7 @@ raises an error. · 4 unmodified lines
4599 4657
4600<p>This function returns <code>table</code>.4658<p>This function returns <code>table</code>.
4601 4659
4602<p><a name="pdf-tonumber"></a><hr /><h3><code>tonumber (e [, base])</code></h3>4660<p><a name="pdf-tonumber"></a><hr></hr><h3><code>tonumber (e [, base])</code></h3>
4603Tries to convert its argument to a number.4661Tries to convert its argument to a number.
4604If the argument is already a number or a string convertible4662If the argument is already a number or a string convertible
4605to a number, then <code>tonumber</code> returns that number;4663to 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, · 8 unmodified lines
4614as well as an optional exponent part (see <a href="#lexical">2.1</a>).4672as well as an optional exponent part (see <a href="#lexical">2.1</a>).
4615In other bases, only unsigned integers are accepted.4673In other bases, only unsigned integers are accepted.
4616 4674
4617<p><a name="pdf-tostring"></a><hr /><h3><code>tostring (e)</code></h3>4675<p><a name="pdf-tostring"></a><hr></hr><h3><code>tostring (e)</code></h3>
4618Receives an argument of any type and4676Receives an argument of any type and
4619converts it to a string in a reasonable format.4677converts it to a string in a reasonable format.
4620For complete control of how numbers are converted,4678For complete control of how numbers are converted,
@@ -4625,7 +4683,7 @@ then <code>tostring</code> calls the corresponding value · 4 unmodified lines
4625with <code>e</code> as argument,4683with <code>e</code> as argument,
4626and uses the result of the call as its result.4684and uses the result of the call as its result.
4627 4685
4628<p><a name="pdf-type"></a><hr /><h3><code>type (v)</code></h3>4686<p><a name="pdf-type"></a><hr></hr><h3><code>type (v)</code></h3>
4629Returns the type of its only argument, coded as a string.4687Returns the type of its only argument, coded as a string.
4630The possible results of this function are4688The possible results of this function are
4631<code>"nil"</code> (a string, not the value <b>nil</b>),4689<code>"nil"</code> (a string, not the value <b>nil</b>),
@@ -4637,7 +4695,7 @@ The possible results of this function are · 5 unmodified lines
4637<code>"thread"</code>,4695<code>"thread"</code>,
4638and <code>"userdata"</code>.4696and <code>"userdata"</code>.
4639 4697
4640<p><a name="pdf-unpack"></a><hr /><h3><code>unpack (list [, i [, j]])</code></h3>4698<p><a name="pdf-unpack"></a><hr></hr><h3><code>unpack (list [, i [, j]])</code></h3>
4641Returns the elements from the given table.4699Returns the elements from the given table.
4642This function is equivalent to4700This function is equivalent to
4643<pre>4701<pre>
@@ -4648,12 +4706,12 @@ of elements. · 4 unmodified lines
4648By default, <code>i</code> is 1 and <code>j</code> is the length of the list,4706By default, <code>i</code> is 1 and <code>j</code> is the length of the list,
4649as defined by the length operator (see <a href="#len-op">2.5.5</a>).4707as defined by the length operator (see <a href="#len-op">2.5.5</a>).
4650 4708
4651<p><a name="pdf-_VERSION"></a><hr /><h3><code>_VERSION</code></h3>4709<p><a name="pdf-_VERSION"></a><hr></hr><h3><code>_VERSION</code></h3>
4652A global variable (not a function) that4710A global variable (not a function) that
4653holds a string containing the current interpreter version.4711holds a string containing the current interpreter version.
4654The current contents of this variable is <code>"Lua 5.1"</code>.4712The current contents of this variable is <code>"Lua 5.1"</code>.
4655 4713
4656<p><a name="pdf-xpcall"></a><hr /><h3><code>xpcall (f, err)</code></h3>4714<p><a name="pdf-xpcall"></a><hr></hr><h3><code>xpcall (f, err)</code></h3>
4657 4715
4658<p>This function is similar to <code>pcall</code>,4716<p>This function is similar to <code>pcall</code>,
4659except that you can set a new error handler.4717except that you can set a new error handler.
@@ -4677,14 +4735,14 @@ In case of any error, · 17 unmodified lines
4677the basic library and come inside the table <code>coroutine</code>.4735the basic library and come inside the table <code>coroutine</code>.
4678See <a href="#coroutine">2.11</a> for a general description of coroutines.4736See <a href="#coroutine">2.11</a> for a general description of coroutines.
4679 4737
4680<p><a name="pdf-coroutine.create"></a><hr /><h3><code>coroutine.create (f)</code></h3>4738<p><a name="pdf-coroutine.create"></a><hr></hr><h3><code>coroutine.create (f)</code></h3>
4681 4739
4682<p>Creates a new coroutine, with body <code>f</code>.4740<p>Creates a new coroutine, with body <code>f</code>.
4683<code>f</code> must be a Lua function.4741<code>f</code> must be a Lua function.
4684Returns this new coroutine,4742Returns this new coroutine,
4685an object with type <code>"thread"</code>.4743an object with type <code>"thread"</code>.
4686 4744
4687<p><a name="pdf-coroutine.resume"></a><hr /><h3><code>coroutine.resume (co [, val1, ..., valn])</code></h3>4745<p><a name="pdf-coroutine.resume"></a><hr></hr><h3><code>coroutine.resume (co [, val1, ..., valn])</code></h3>
4688 4746
4689<p>Starts or continues the execution of coroutine <code>co</code>.4747<p>Starts or continues the execution of coroutine <code>co</code>.
4690The first time you resume a coroutine,4748The first time you resume a coroutine,
@@ -4703,12 +4761,12 @@ as the results from the yield. · 12 unmodified lines
4703If there is any error,4761If there is any error,
4704<code>resume</code> returns <b>false</b> plus the error message.4762<code>resume</code> returns <b>false</b> plus the error message.
4705 4763
4706<p><a name="pdf-coroutine.running"></a><hr /><h3><code>coroutine.running ()</code></h3>4764<p><a name="pdf-coroutine.running"></a><hr></hr><h3><code>coroutine.running ()</code></h3>
4707 4765
4708<p>Returns the running coroutine,4766<p>Returns the running coroutine,
4709or <b>nil</b> when called by the main thread.4767or <b>nil</b> when called by the main thread.
4710 4768
4711<p><a name="pdf-coroutine.status"></a><hr /><h3><code>coroutine.status (co)</code></h3>4769<p><a name="pdf-coroutine.status"></a><hr></hr><h3><code>coroutine.status (co)</code></h3>
4712 4770
4713<p>Returns the status of coroutine <code>co</code>, as a string:4771<p>Returns the status of coroutine <code>co</code>, as a string:
4714<code>"running"</code>,4772<code>"running"</code>,
@@ -4720,7 +4778,7 @@ or if it has not started running yet; · 5 unmodified lines
4720and <code>"dead"</code> if the coroutine has finished its body function,4778and <code>"dead"</code> if the coroutine has finished its body function,
4721or if it has stopped with an error.4779or if it has stopped with an error.
4722 4780
4723<p><a name="pdf-coroutine.wrap"></a><hr /><h3><code>coroutine.wrap (f)</code></h3>4781<p><a name="pdf-coroutine.wrap"></a><hr></hr><h3><code>coroutine.wrap (f)</code></h3>
4724 4782
4725<p>Creates a new coroutine, with body <code>f</code>.4783<p>Creates a new coroutine, with body <code>f</code>.
4726<code>f</code> must be a Lua function.4784<code>f</code> must be a Lua function.
@@ -4731,7 +4789,7 @@ Returns the same values returned by <code>resume</code>, · 4 unmodified lines
4731except the first boolean.4789except the first boolean.
4732In case of error, propagates the error.4790In case of error, propagates the error.
4733 4791
4734<p><a name="pdf-coroutine.yield"></a><hr /><h3><code>coroutine.yield ([val1, ..., valn])</code></h3>4792<p><a name="pdf-coroutine.yield"></a><hr></hr><h3><code>coroutine.yield ([val1, ..., valn])</code></h3>
4735 4793
4736<p>Suspends the execution of the calling coroutine.4794<p>Suspends the execution of the calling coroutine.
4737The coroutine can be running neither a C function,4795The coroutine can be running neither a C function,
@@ -4746,7 +4804,7 @@ It exports two of its functions directly in the global environment: · 8 unmodified lines
4746<a href="#pdf-require"><code>require</code></a> and <a href="#pdf-module"><code>module</code></a>.4804<a href="#pdf-require"><code>require</code></a> and <a href="#pdf-module"><code>module</code></a>.
4747Everything else is exported in a table <code>package</code>.4805Everything else is exported in a table <code>package</code>.
4748 4806
4749<p><a name="pdf-module"></a><hr /><h3><code>module (name [, ...])</code></h3>4807<p><a name="pdf-module"></a><hr></hr><h3><code>module (name [, ...])</code></h3>
4750 4808
4751<p>Creates a module.4809<p>Creates a module.
4752If there is a table in <code>package.loaded[name]</code>,4810If there is a table in <code>package.loaded[name]</code>,
@@ -4776,7 +4834,7 @@ field <code>b</code> of global <code>a</code>. · 23 unmodified lines
4776the module name,4834the module name,
4777where each option is a function to be applied over the module.4835where each option is a function to be applied over the module.
4778 4836
4779<p><a name="pdf-require"></a><hr /><h3><code>require (modname)</code></h3>4837<p><a name="pdf-require"></a><hr></hr><h3><code>require (modname)</code></h3>
4780 4838
4781<p>Loads the given module.4839<p>Loads the given module.
4782The function starts by looking into the table <code>package.loaded</code>4840The function starts by looking into the table <code>package.loaded</code>
@@ -4830,14 +4888,14 @@ If the loader returns any value, · 47 unmodified lines
4830If the loader returns no value and4888If the loader returns no value and
4831has not assigned any value to <code>package.loaded[modname]</code>,4889has not assigned any value to <code>package.loaded[modname]</code>,
4832then <code>require</code> assigns <b>true</b> to that entry.4890then <code>require</code> assigns <b>true</b> to that entry.
4833In any case, require returns the4891In any case, <code>require</code> returns the
4834final value of <code>package.loaded[modname]</code>.4892final value of <code>package.loaded[modname]</code>.
4835 4893
4836<p>If there is any error loading or running the module,4894<p>If there is any error loading or running the module,
4837or if it cannot find any loader for that module,4895or if it cannot find any loader for that module,
4838then <code>require</code> signals an error. 4896then <code>require</code> signals an error.
4839 4897
4840<p><a name="pdf-package.cpath"></a><hr /><h3><code>package.cpath</code></h3>4898<p><a name="pdf-package.cpath"></a><hr></hr><h3><code>package.cpath</code></h3>
4841 4899
4842<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a C loader.4900<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a C loader.
4843 4901
@@ -4846,7 +4904,7 @@ it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code · 2 unmodified lines
4846using the environment variable <code>LUA_CPATH</code>4904using the environment variable <code>LUA_CPATH</code>
4847(plus another default path defined in <code>luaconf.h</code>).4905(plus another default path defined in <code>luaconf.h</code>).
4848 4906
4849<p><a name="pdf-package.loaded"></a><hr /><h3><code>package.loaded</code></h3>4907<p><a name="pdf-package.loaded"></a><hr></hr><h3><code>package.loaded</code></h3>
4850 4908
4851<p>A table used by <a href="#pdf-require"><code>require</code></a> to control which4909<p>A table used by <a href="#pdf-require"><code>require</code></a> to control which
4852modules are already loaded.4910modules are already loaded.
@@ -4854,7 +4912,7 @@ When you require a module <code>modname</code> and · 1 unmodified line
4854<code>package.loaded[modname]</code> is not false,4912<code>package.loaded[modname]</code> is not false,
4855<a href="#pdf-require"><code>require</code></a> simply returns the value stored there.4913<a href="#pdf-require"><code>require</code></a> simply returns the value stored there.
4856 4914
4857<p><a name="pdf-package.loadlib"></a><hr /><h3><code>package.loadlib (libname, funcname)</code></h3>4915<p><a name="pdf-package.loadlib"></a><hr></hr><h3><code>package.loadlib (libname, funcname)</code></h3>
4858 4916
4859<p>Dynamically links the host program with the C library <code>libname</code>.4917<p>Dynamically links the host program with the C library <code>libname</code>.
4860Inside this library, looks for a function <code>funcname</code>4918Inside this library, looks for a function <code>funcname</code>
@@ -4864,7 +4922,8 @@ and returns this function as a C function. · 3 unmodified lines
4864<p>This is a low-level function.4922<p>This is a low-level function.
4865It completely bypasses the package and module system.4923It completely bypasses the package and module system.
4866Unlike <a href="#pdf-require"><code>require</code></a>,4924Unlike <a href="#pdf-require"><code>require</code></a>,
4867it does not perform any path searching or automatically adds extensions.4925it does not perform any path searching and
4926does not automatically adds extensions.
4868<code>libname</code> must be the complete file name of the C library,4927<code>libname</code> must be the complete file name of the C library,
4869including if necessary a path and extension.4928including if necessary a path and extension.
4870<code>funcname</code> must be the exact name exported by the C library4929<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 · 4 unmodified lines
4875(Windows, Linux, Mac OS X, Solaris, BSD,4934(Windows, Linux, Mac OS X, Solaris, BSD,
4876plus other Unix systems that support the <code>dlfcn</code> standard).4935plus other Unix systems that support the <code>dlfcn</code> standard).
4877 4936
4878<p><a name="pdf-package.path"></a><hr /><h3><code>package.path</code></h3>4937<p><a name="pdf-package.path"></a><hr></hr><h3><code>package.path</code></h3>
4879 4938
4880<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a Lua loader.4939<p>The path used by <a href="#pdf-require"><code>require</code></a> to search for a Lua loader.
4881 4940
@@ -4901,12 +4960,12 @@ will try to load the files · 19 unmodified lines
4901<code>./foo.lua</code>, <code>./foo.lc</code>, and4960<code>./foo.lua</code>, <code>./foo.lc</code>, and
4902<code>/usr/local/foo/init.lua</code>, in that order.4961<code>/usr/local/foo/init.lua</code>, in that order.
4903 4962
4904<p><a name="pdf-package.preload"></a><hr /><h3><code>package.preload</code></h3>4963<p><a name="pdf-package.preload"></a><hr></hr><h3><code>package.preload</code></h3>
4905 4964
4906<p>A table to store loaders for specific modules4965<p>A table to store loaders for specific modules
4907(see <a href="#pdf-require"><code>require</code></a>).4966(see <a href="#pdf-require"><code>require</code></a>).
4908 4967
4909<p><a name="pdf-package.seeall"></a><hr /><h3><code>package.seeall (module)</code></h3>4968<p><a name="pdf-package.seeall"></a><hr></hr><h3><code>package.seeall (module)</code></h3>
4910 4969
4911<p>Sets a metatable for <code>module</code> with4970<p>Sets a metatable for <code>module</code> with
4912its <code>__index</code> field referring to the global environment,4971its <code>__index</code> field referring to the global environment,
@@ -4932,7 +4991,7 @@ Therefore, you can use the string functions in object-oriented style. · 19 unmodified lines
4932For instance, <code>string.byte(s, i)</code>4991For instance, <code>string.byte(s, i)</code>
4933can be written as <code>s:byte(i)</code>.4992can be written as <code>s:byte(i)</code>.
4934 4993
4935<p><a name="pdf-string.byte"></a><hr /><h3><code>string.byte (s [, i [, j]])</code></h3>4994<p><a name="pdf-string.byte"></a><hr></hr><h3><code>string.byte (s [, i [, j]])</code></h3>
4936Returns the internal numerical codes of the characters <code>s[i]</code>,4995Returns the internal numerical codes of the characters <code>s[i]</code>,
4937<code>s[i+1]</code>, ..., <code>s[j]</code>.4996<code>s[i+1]</code>, ..., <code>s[j]</code>.
4938The default value for <code>i</code> is 1;4997The default value for <code>i</code> is 1;
@@ -4940,7 +4999,7 @@ the default value for <code>j</code> is <code>i</code>. · 1 unmodified line
4940 4999
4941<p>Note that numerical codes are not necessarily portable across platforms.5000<p>Note that numerical codes are not necessarily portable across platforms.
4942 5001
4943<p><a name="pdf-string.char"></a><hr /><h3><code>string.char (i1, i2, ...)</code></h3>5002<p><a name="pdf-string.char"></a><hr></hr><h3><code>string.char (i1, i2, ...)</code></h3>
4944Receives 0 or more integers.5003Receives 0 or more integers.
4945Returns a string with length equal to the number of arguments,5004Returns a string with length equal to the number of arguments,
4946in which each character has the internal numerical code equal5005in which each character has the internal numerical code equal
@@ -4948,14 +5007,14 @@ to its corresponding argument. · 1 unmodified line
4948 5007
4949<p>Note that numerical codes are not necessarily portable across platforms.5008<p>Note that numerical codes are not necessarily portable across platforms.
4950 5009
4951<p><a name="pdf-string.dump"></a><hr /><h3><code>string.dump (function)</code></h3>5010<p><a name="pdf-string.dump"></a><hr></hr><h3><code>string.dump (function)</code></h3>
4952 5011
4953<p>Returns a string containing a binary representation of the given function,5012<p>Returns a string containing a binary representation of the given function,
4954so that a later <a href="#pdf-loadstring"><code>loadstring</code></a> on that string returns5013so that a later <a href="#pdf-loadstring"><code>loadstring</code></a> on that string returns
4955a copy of the function.5014a copy of the function.
4956<code>function</code> must be a Lua function without upvalues.5015<code>function</code> must be a Lua function without upvalues.
4957 5016
4958<p><a name="pdf-string.find"></a><hr /><h3><code>string.find (s, pattern [, init [, plain]])</code></h3>5017<p><a name="pdf-string.find"></a><hr></hr><h3><code>string.find (s, pattern [, init [, plain]])</code></h3>
4959Looks for the first match of5018Looks for the first match of
4960<code>pattern</code> in the string <code>s</code>.5019<code>pattern</code> in the string <code>s</code>.
4961If it finds a match, then <code>find</code> returns the indices of <code>s</code>5020If it finds a match, then <code>find</code> returns the indices of <code>s</code>
@@ -4975,7 +5034,7 @@ then in a successful match · 13 unmodified lines
4975the captured values are also returned,5034the captured values are also returned,
4976after the two indices.5035after the two indices.
4977 5036
4978<p><a name="format"></a><a name="pdf-string.format"></a><hr /><h3><code>string.format (formatstring, e1, e2, ...)</code></h3>5037<p><a name="format"></a><a name="pdf-string.format"></a><hr></hr><h3><code>string.format (formatstring, e1, e2, ...)</code></h3>
4979Returns a formatted version of its variable number of arguments5038Returns a formatted version of its variable number of arguments
4980following the description given in its first argument (which must be a string).5039following the description given in its first argument (which must be a string).
4981The format string follows the same rules as the <code>printf</code> family of5040The 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. · 26 unmodified lines
5008<p>This function does not accept string values5067<p>This function does not accept string values
5009containing embedded zeros.5068containing embedded zeros.
5010 5069
5011<p><a name="pdf-string.gmatch"></a><hr /><h3><code>string.gmatch (s, pattern)</code></h3>5070<p><a name="pdf-string.gmatch"></a><hr></hr><h3><code>string.gmatch (s, pattern)</code></h3>
5012Returns an iterator function that,5071Returns an iterator function that,
5013each time it is called,5072each time it is called,
5014returns the next captures from <code>pattern</code> over string <code>s</code>.5073returns the next captures from <code>pattern</code> over string <code>s</code>.
@@ -5035,7 +5094,7 @@ given string into a table: · 20 unmodified lines
5035 end5094 end
5036</pre>5095</pre>
5037 5096
5038<p><a name="pdf-string.gsub"></a><hr /><h3><code>string.gsub (s, pattern, repl [, n])</code></h3>5097<p><a name="pdf-string.gsub"></a><hr></hr><h3><code>string.gsub (s, pattern, repl [, n])</code></h3>
5039Returns a copy of <code>s</code>5098Returns a copy of <code>s</code>
5040in which all occurrences of the <code>pattern</code> have been5099in which all occurrences of the <code>pattern</code> have been
5041replaced by a replacement string specified by <code>repl</code>,5100replaced by a replacement string specified by <code>repl</code>,
@@ -5061,12 +5120,8 @@ match occurs, with all captured substrings passed as arguments, · 19 unmodified lines
5061in order;5120in order;
5062if the pattern specifies no captures,5121if the pattern specifies no captures,
5063then the whole match is passed as a sole argument.5122then the whole match is passed as a sole argument.
5064If <code>repl</code> is a table, then this table is queried with the
5065value of the first capture or of the whole match,
5066if the pattern specifies no captures.
5067 5123
5068<p>In both cases,5124<p>If the value returned by the table query or by the function call
5069if the value returned by the function or by the table query
5070is a string or a number,5125is a string or a number,
5071then it is used as the replacement string;5126then it is used as the replacement string;
5072otherwise, if it is <b>false</b> or <b>nil</b>,5127otherwise, 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 · 29 unmodified lines
5102 --> x="lua-5.1.tar.gz"5157 --> x="lua-5.1.tar.gz"
5103</pre>5158</pre>
5104 5159
5105<p><a name="pdf-string.len"></a><hr /><h3><code>string.len (s)</code></h3>5160<p><a name="pdf-string.len"></a><hr></hr><h3><code>string.len (s)</code></h3>
5106Receives a string and returns its length.5161Receives a string and returns its length.
5107The empty string <code>""</code> has length 0.5162The empty string <code>""</code> has length 0.
5108Embedded zeros are counted,5163Embedded zeros are counted,
5109so <code>"a\000bc\000"</code> has length 5.5164so <code>"a\000bc\000"</code> has length 5.
5110 5165
5111<p><a name="pdf-string.lower"></a><hr /><h3><code>string.lower (s)</code></h3>5166<p><a name="pdf-string.lower"></a><hr></hr><h3><code>string.lower (s)</code></h3>
5112Receives a string and returns a copy of that string with all5167Receives a string and returns a copy of that string with all
5113uppercase letters changed to lowercase.5168uppercase letters changed to lowercase.
5114All other characters are left unchanged.5169All other characters are left unchanged.
5115The definition of what an uppercase letter is depends on the current locale.5170The definition of what an uppercase letter is depends on the current locale.
5116 5171
5117<p><a name="pdf-string.match"></a><hr /><h3><code>string.match (s, pattern [, init])</code></h3>5172<p><a name="pdf-string.match"></a><hr></hr><h3><code>string.match (s, pattern [, init])</code></h3>
5118Looks for the first <em>match</em> of5173Looks for the first <em>match</em> of
5119<code>pattern</code> in the string <code>s</code>.5174<code>pattern</code> in the string <code>s</code>.
5120If it finds one, then <code>match</code> returns5175If it finds one, then <code>match</code> returns
@@ -5126,14 +5181,14 @@ A third, optional numerical argument <code>init</code> specifies · 5 unmodified lines
5126where to start the search;5181where to start the search;
5127its default value is 1 and may be negative.5182its default value is 1 and may be negative.
5128 5183
5129<p><a name="pdf-string.rep"></a><hr /><h3><code>string.rep (s, n)</code></h3>5184<p><a name="pdf-string.rep"></a><hr></hr><h3><code>string.rep (s, n)</code></h3>
5130Returns a string that is the concatenation of <code>n</code> copies of5185Returns a string that is the concatenation of <code>n</code> copies of
5131the string <code>s</code>.5186the string <code>s</code>.
5132 5187
5133<p><a name="pdf-string.reverse"></a><hr /><h3><code>string.reverse (s)</code></h3>5188<p><a name="pdf-string.reverse"></a><hr></hr><h3><code>string.reverse (s)</code></h3>
5134Returns a string that is the string <code>s</code> reversed.5189Returns a string that is the string <code>s</code> reversed.
5135 5190
5136<p><a name="pdf-string.sub"></a><hr /><h3><code>string.sub (s, i [, j])</code></h3>5191<p><a name="pdf-string.sub"></a><hr></hr><h3><code>string.sub (s, i [, j])</code></h3>
5137Returns the substring of <code>s</code> that5192Returns the substring of <code>s</code> that
5138starts at <code>i</code> and continues until <code>j</code>;5193starts at <code>i</code> and continues until <code>j</code>;
5139<code>i</code> and <code>j</code> may be negative.5194<code>i</code> and <code>j</code> may be negative.
@@ -5145,7 +5200,7 @@ with length <code>j</code>, · 5 unmodified lines
5145and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>5200and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>
5146with length <code>i</code>.5201with length <code>i</code>.
5147 5202
5148<p><a name="pdf-string.upper"></a><hr /><h3><code>string.upper (s)</code></h3>5203<p><a name="pdf-string.upper"></a><hr></hr><h3><code>string.upper (s)</code></h3>
5149Receives a string and returns a copy of that string with all5204Receives a string and returns a copy of that string with all
5150lowercase letters changed to uppercase.5205lowercase letters changed to uppercase.
5151All other characters are left unchanged.5206All other characters are left unchanged.
@@ -5279,17 +5334,17 @@ It provides all its functions inside the table <code>table</code>. · 127 unmodified lines
5279 5334
5280<p>Most functions in the table library assume that the table5335<p>Most functions in the table library assume that the table
5281represents an array or a list.5336represents an array or a list.
5282For those functions, when we talk about "the length" of a table5337For those functions, when we talk about the "length" of a table
5283we mean the result of the length operator.5338we mean the result of the length operator.
5284 5339
5285<p><a name="pdf-table.concat"></a><hr /><h3><code>table.concat (table [, sep [, i [, j]]])</code></h3>5340<p><a name="pdf-table.concat"></a><hr></hr><h3><code>table.concat (table [, sep [, i [, j]]])</code></h3>
5286Returns <code>table[i]..sep..table[i+1] ... sep..table[j]</code>.5341Returns <code>table[i]..sep..table[i+1] ... sep..table[j]</code>.
5287The default value for <code>sep</code> is the empty string,5342The default value for <code>sep</code> is the empty string,
5288the default for <code>i</code> is 1,5343the default for <code>i</code> is 1,
5289and the default for <code>j</code> is the length of the table.5344and the default for <code>j</code> is the length of the table.
5290If <code>i</code> is greater than <code>j</code>, returns the empty string.5345If <code>i</code> is greater than <code>j</code>, returns the empty string.
5291 5346
5292<p><a name="pdf-table.insert"></a><hr /><h3><code>table.insert (table, [pos,] value)</code></h3>5347<p><a name="pdf-table.insert"></a><hr></hr><h3><code>table.insert (table, [pos,] value)</code></h3>
5293 5348
5294<p>Inserts element <code>value</code> at position <code>pos</code> in <code>table</code>,5349<p>Inserts element <code>value</code> at position <code>pos</code> in <code>table</code>,
5295shifting up other elements to open space, if necessary.5350shifting 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> · 2 unmodified lines
5298so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end5353so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
5299of table <code>t</code>.5354of table <code>t</code>.
5300 5355
5301<p><a name="pdf-table.maxn"></a><hr /><h3><code>table.maxn (table)</code></h3>5356<p><a name="pdf-table.maxn"></a><hr></hr><h3><code>table.maxn (table)</code></h3>
5302 5357
5303<p>Returns the largest positive numerical index of the given table,5358<p>Returns the largest positive numerical index of the given table,
5304or zero if the table has no positive numerical indices.5359or zero if the table has no positive numerical indices.
5305(To do its job this function does a linear traversal of5360(To do its job this function does a linear traversal of
5306the whole table.) 5361the whole table.)
5307 5362
5308<p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3>5363<p><a name="pdf-table.remove"></a><hr></hr><h3><code>table.remove (table [, pos])</code></h3>
5309 5364
5310<p>Removes from <code>table</code> the element at position <code>pos</code>,5365<p>Removes from <code>table</code> the element at position <code>pos</code>,
5311shifting down other elements to close the space, if necessary.5366shifting down other elements to close the space, if necessary.
@@ -5315,7 +5370,7 @@ where <code>n</code> is the length of the table, · 3 unmodified lines
5315so that a call <code>table.remove(t)</code> removes the last element5370so that a call <code>table.remove(t)</code> removes the last element
5316of table <code>t</code>.5371of table <code>t</code>.
5317 5372
5318<p><a name="pdf-table.sort"></a><hr /><h3><code>table.sort (table [, comp])</code></h3>5373<p><a name="pdf-table.sort"></a><hr></hr><h3><code>table.sort (table [, comp])</code></h3>
5319Sorts table elements in a given order, <em>in-place</em>,5374Sorts table elements in a given order, <em>in-place</em>,
5320from <code>table[1]</code> to <code>table[n]</code>,5375from <code>table[1]</code> to <code>table[n]</code>,
5321where <code>n</code> is the length of the table.5376where <code>n</code> is the length of the table.
@@ -5336,16 +5391,17 @@ may have their relative positions changed by the sort. · 14 unmodified lines
5336<p>This library is an interface to the standard C math library.5391<p>This library is an interface to the standard C math library.
5337It provides all its functions inside the table <code>math</code>.5392It provides all its functions inside the table <code>math</code>.
5338The library provides the following functions:5393The library provides the following functions:
5339<a name="pdf-math.abs"></a><a name="pdf-math.acos"></a><a name="pdf-math.asin"></a><a name="pdf-math.atan"></a>5394<a name="pdf-math.abs"></a> <a name="pdf-math.acos"></a> <a name="pdf-math.asin"></a> <a name="pdf-math.atan"></a>
5340<a name="pdf-math.atan2"></a><a name="pdf-math.ceil"></a><a name="pdf-math.cos"></a><a name="pdf-math.cosh"></a>5395<a name="pdf-math.atan2"></a> <a name="pdf-math.ceil"></a> <a name="pdf-math.cos"></a> <a name="pdf-math.cosh"></a>
5341<a name="pdf-math.def"></a><a name="pdf-math.exp"></a>5396<a name="pdf-math.deg"></a> <a name="pdf-math.exp"></a> <a name="pdf-math.floor"></a> <a name="pdf-math.fmod"></a>
5342<a name="pdf-math.floor"></a><a name="pdf-math.log"></a><a name="pdf-math.log10"></a>5397<a name="pdf-math.frexp"></a> <a name="pdf-math.ldexp"></a> <a name="pdf-math.log"></a> <a name="pdf-math.log10"></a>
5343<a name="pdf-math.fmod"></a><a name="pdf-math.pow"></a><a name="pdf-math.sin"></a>5398<a name="pdf-math.max"></a> <a name="pdf-math.min"></a> <a name="pdf-math.modf"></a> <a name="pdf-math.pow"></a>
5344<a name="pdf-math.sqrt"></a><a name="pdf-math.tan"></a><a name="pdf-math.ldexp"></a>5399<a name="pdf-math.rad"></a> <a name="pdf-math.random"></a> <a name="pdf-math.randomseed"></a>
5345<a name="pdf-math.sinh"></a><a name="pdf-math.tanh"></a>5400<a name="pdf-math.sin"></a> <a name="pdf-math.sinh"></a> <a name="pdf-math.sqrt"></a> <a name="pdf-math.tan"></a>
5401<a name="pdf-math.tanh"></a>
5346<pre>5402<pre>
5347 math.abs math.acos math.asin math.atan math.atan25403 math.abs math.acos math.asin math.atan math.atan2
5348 math.ceil math.cosh math.cos math.deg math.exp5404 math.ceil math.cos math.cosh math.deg math.exp
5349 math.floor math.fmod math.frexp math.ldexp math.log5405 math.floor math.fmod math.frexp math.ldexp math.log
5350 math.log10 math.max math.min math.modf math.pow5406 math.log10 math.max math.min math.modf math.pow
5351 math.rad math.random math.randomseed math.sin5407 math.rad math.random math.randomseed math.sin
@@ -5413,16 +5469,16 @@ all I/O functions return <b>nil</b> on failure · 61 unmodified lines
5413(plus an error message as a second result)5469(plus an error message as a second result)
5414and some value different from <b>nil</b> on success.5470and some value different from <b>nil</b> on success.
5415 5471
5416<p><a name="pdf-io.close"></a><hr /><h3><code>io.close ([file])</code></h3>5472<p><a name="pdf-io.close"></a><hr></hr><h3><code>io.close ([file])</code></h3>
5417 5473
5418<p>Equivalent to <code>file:close()</code>.5474<p>Equivalent to <code>file:close()</code>.
5419Without a <code>file</code>, closes the default output file.5475Without a <code>file</code>, closes the default output file.
5420 5476
5421<p><a name="pdf-io.flush"></a><hr /><h3><code>io.flush ()</code></h3>5477<p><a name="pdf-io.flush"></a><hr></hr><h3><code>io.flush ()</code></h3>
5422 5478
5423<p>Equivalent to <code>file:flush</code> over the default output file.5479<p>Equivalent to <code>file:flush</code> over the default output file.
5424 5480
5425<p><a name="pdf-io.input"></a><hr /><h3><code>io.input ([file])</code></h3>5481<p><a name="pdf-io.input"></a><hr></hr><h3><code>io.input ([file])</code></h3>
5426 5482
5427<p>When called with a file name, it opens the named file (in text mode),5483<p>When called with a file name, it opens the named file (in text mode),
5428and sets its handle as the default input file.5484and sets its handle as the default input file.
@@ -5434,7 +5490,7 @@ it returns the current default input file. · 5 unmodified lines
5434<p>In case of errors this function raises the error,5490<p>In case of errors this function raises the error,
5435instead of returning an error code.5491instead of returning an error code.
5436 5492
5437<p><a name="pdf-io.lines"></a><hr /><h3><code>io.lines ([filename])</code></h3>5493<p><a name="pdf-io.lines"></a><hr></hr><h3><code>io.lines ([filename])</code></h3>
5438 5494
5439<p>Opens the given file name in read mode5495<p>Opens the given file name in read mode
5440and returns an iterator function that,5496and returns an iterator function that,
@@ -5453,7 +5509,7 @@ to <code>io.input():lines()</code>; · 12 unmodified lines
5453that is, it iterates over the lines of the default input file.5509that is, it iterates over the lines of the default input file.
5454In that case it does not close the file when the loop ends.5510In that case it does not close the file when the loop ends.
5455 5511
5456<p><a name="pdf-io.open"></a><hr /><h3><code>io.open (filename [, mode])</code></h3>5512<p><a name="pdf-io.open"></a><hr></hr><h3><code>io.open (filename [, mode])</code></h3>
5457 5513
5458<p>This function opens a file,5514<p>This function opens a file,
5459in the mode specified in the string <code>mode</code>.5515in 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. · 15 unmodified lines
5475This string is exactly what is used in the5531This string is exactly what is used in the
5476standard C function <code>fopen</code>.5532standard C function <code>fopen</code>.
5477 5533
5478<p><a name="pdf-io.output"></a><hr /><h3><code>io.output ([file])</code></h3>5534<p><a name="pdf-io.output"></a><hr></hr><h3><code>io.output ([file])</code></h3>
5479 5535
5480<p>Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output file.5536<p>Similar to <a href="#pdf-io.input"><code>io.input</code></a>, but operates over the default output file.
5481 5537
5482<p><a name="pdf-io.popen"></a><hr /><h3><code>io.popen ([prog [, mode]])</code></h3>5538<p><a name="pdf-io.popen"></a><hr></hr><h3><code>io.popen ([prog [, mode]])</code></h3>
5483 5539
5484<p>Starts program <code>prog</code> in a separated process and returns5540<p>Starts program <code>prog</code> in a separated process and returns
5485a file handle that you can use to read data from that program5541a file handle that you can use to read data from that program
@@ -5490,39 +5546,39 @@ or to write data to that program · 4 unmodified lines
5490<p>This function is system dependent and is not available5546<p>This function is system dependent and is not available
5491on all platforms.5547on all platforms.
5492 5548
5493<p><a name="pdf-io.read"></a><hr /><h3><code>io.read (format1, ...)</code></h3>5549<p><a name="pdf-io.read"></a><hr></hr><h3><code>io.read (format1, ...)</code></h3>
5494 5550
5495<p>Equivalent to <code>io.input():read</code>.5551<p>Equivalent to <code>io.input():read</code>.
5496 5552
5497<p><a name="pdf-io.tmpfile"></a><hr /><h3><code>io.tmpfile ()</code></h3>5553<p><a name="pdf-io.tmpfile"></a><hr></hr><h3><code>io.tmpfile ()</code></h3>
5498 5554
5499<p>Returns a handle for a temporary file.5555<p>Returns a handle for a temporary file.
5500This file is opened in update mode5556This file is opened in update mode
5501and it is automatically removed when the program ends.5557and it is automatically removed when the program ends.
5502 5558
5503<p><a name="pdf-io.type"></a><hr /><h3><code>io.type (obj)</code></h3>5559<p><a name="pdf-io.type"></a><hr></hr><h3><code>io.type (obj)</code></h3>
5504 5560
5505<p>Checks whether <code>obj</code> is a valid file handle.5561<p>Checks whether <code>obj</code> is a valid file handle.
5506Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,5562Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,
5507<code>"closed file"</code> if <code>obj</code> is a closed file handle,5563<code>"closed file"</code> if <code>obj</code> is a closed file handle,
5508and <b>nil</b> if <code>obj</code> is not a file handle.5564and <b>nil</b> if <code>obj</code> is not a file handle.
5509 5565
5510<p><a name="pdf-io.write"></a><hr /><h3><code>io.write (value1, ...)</code></h3>5566<p><a name="pdf-io.write"></a><hr></hr><h3><code>io.write (value1, ...)</code></h3>
5511 5567
5512<p>Equivalent to <code>io.output():write</code>.5568<p>Equivalent to <code>io.output():write</code>.
5513 5569
5514<p><a name="pdf-file:close"></a><hr /><h3><code>file:close ()</code></h3>5570<p><a name="pdf-file:close"></a><hr></hr><h3><code>file:close ()</code></h3>
5515 5571
5516<p>Closes <code>file</code>.5572<p>Closes <code>file</code>.
5517Note that files are automatically closed when5573Note that files are automatically closed when
5518their handles are garbage collected,5574their handles are garbage collected,
5519but that takes an unpredictable time to happen.5575but that takes an unpredictable amount of time to happen.
5520 5576
5521<p><a name="flush"></a><a name="pdf-file:flush"></a><hr /><h3><code>file:flush ()</code></h3>5577<p><a name="flush"></a><a name="pdf-file:flush"></a><hr></hr><h3><code>file:flush ()</code></h3>
5522 5578
5523<p>Saves any written data to <code>file</code>.5579<p>Saves any written data to <code>file</code>.
5524 5580
5525<p><a name="pdf-file:lines"></a><hr /><h3><code>file:lines ()</code></h3>5581<p><a name="pdf-file:lines"></a><hr></hr><h3><code>file:lines ()</code></h3>
5526 5582
5527<p>Returns an iterator function that,5583<p>Returns an iterator function that,
5528each time it is called,5584each time it is called,
@@ -5535,7 +5591,7 @@ will iterate over all lines of the file. · 6 unmodified lines
5535(Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file5591(Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
5536when the loop ends.)5592when the loop ends.)
5537 5593
5538<p><a name="pdf-file:read"></a><hr /><h3><code>file:read (format1, ...)</code></h3>5594<p><a name="pdf-file:read"></a><hr></hr><h3><code>file:read (format1, ...)</code></h3>
5539 5595
5540<p>Reads the file <code>file</code>,5596<p>Reads the file <code>file</code>,
5541according to the given formats, which specify what to read.5597according to the given formats, which specify what to read.
@@ -5562,16 +5618,16 @@ it reads nothing and returns an empty string, · 20 unmodified lines
5562or <b>nil</b> on end of file.5618or <b>nil</b> on end of file.
5563</ul>5619</ul>
5564 5620
5565<p><a name="pdf-file:seek"></a><hr /><h3><code>file:seek ([whence] [, offset])</code></h3>5621<p><a name="pdf-file:seek"></a><hr></hr><h3><code>file:seek ([whence] [, offset])</code></h3>
5566 5622
5567<p>Sets and gets the file position,5623<p>Sets and gets the file position,
5568measured from the beginning of the file,5624measured from the beginning of the file,
5569to the position given by <code>offset</code> plus a base5625to the position given by <code>offset</code> plus a base
5570specified by the string <code>whence</code>, as follows:5626specified by the string <code>whence</code>, as follows:
5571<ul>5627<ul>
5572<li><b>"set"</b> base is position 0 (beginning of the file);5628<li><b>"set"</b> --- base is position 0 (beginning of the file);
5573<li><b>"cur"</b> base is current position;5629<li><b>"cur"</b> --- base is current position;
5574<li><b>"end"</b> base is end of file;5630<li><b>"end"</b> --- base is end of file;
5575</ul>5631</ul>
5576In case of success, function <code>seek</code> returns the final file position,5632In case of success, function <code>seek</code> returns the final file position,
5577measured in bytes from the beginning of the file.5633measured in bytes from the beginning of the file.
@@ -5587,7 +5643,7 @@ beginning of the file (and returns 0); · 9 unmodified lines
5587and the call <code>file:seek("end")</code> sets the position to the5643and the call <code>file:seek("end")</code> sets the position to the
5588end of the file, and returns its size.5644end of the file, and returns its size.
5589 5645
5590<p><a name="pdf-file:setvbuf"></a><hr /><h3><code>file:setvbuf (mode [, size])</code></h3>5646<p><a name="pdf-file:setvbuf"></a><hr></hr><h3><code>file:setvbuf (mode [, size])</code></h3>
5591 5647
5592<p>Sets the buffering mode for an output file.5648<p>Sets the buffering mode for an output file.
5593There are three available modes:5649There are three available modes:
@@ -5606,7 +5662,7 @@ For the last two cases, <code>sizes</code> · 12 unmodified lines
5606specifies the size of the buffer, in bytes.5662specifies the size of the buffer, in bytes.
5607The default is an appropriate size.5663The default is an appropriate size.
5608 5664
5609<p><a name="pdf-file:write"></a><hr /><h3><code>file:write (value1, ...)</code></h3>5665<p><a name="pdf-file:write"></a><hr></hr><h3><code>file:write (value1, ...)</code></h3>
5610 5666
5611<p>Writes the value of each of its arguments to5667<p>Writes the value of each of its arguments to
5612the <code>file</code>.5668the <code>file</code>.
@@ -5618,12 +5674,12 @@ use <a href="#pdf-tostring"><code>tostring</code></a> or <a href="#pdf-string.fo · 5 unmodified lines
5618 5674
5619<p>This library is implemented through table <code>os</code>.5675<p>This library is implemented through table <code>os</code>.
5620 5676
5621<p><a name="pdf-os.clock"></a><hr /><h3><code>os.clock ()</code></h3>5677<p><a name="pdf-os.clock"></a><hr></hr><h3><code>os.clock ()</code></h3>
5622 5678
5623<p>Returns an approximation of the amount in seconds of CPU time5679<p>Returns an approximation of the amount in seconds of CPU time
5624used by the program.5680used by the program.
5625 5681
5626<p><a name="pdf-os.date"></a><hr /><h3><code>os.date ([format [, time]])</code></h3>5682<p><a name="pdf-os.date"></a><hr></hr><h3><code>os.date ([format [, time]])</code></h3>
5627 5683
5628<p>Returns a string or a table containing date and time,5684<p>Returns a string or a table containing date and time,
5629formatted according to the given string <code>format</code>.5685formatted 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>. · 23 unmodified lines
5653the host system and on the current locale5709the host system and on the current locale
5654(that is, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>).5710(that is, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>).
5655 5711
5656<p><a name="pdf-os.difftime"></a><hr /><h3><code>os.difftime (t2, t1)</code></h3>5712<p><a name="pdf-os.difftime"></a><hr></hr><h3><code>os.difftime (t2, t1)</code></h3>
5657 5713
5658<p>Returns the number of seconds from time <code>t1</code> to time <code>t2</code>.5714<p>Returns the number of seconds from time <code>t1</code> to time <code>t2</code>.
5659In Posix, Windows, and some other systems,5715In POSIX, Windows, and some other systems,
5660this value is exactly <code>t2</code><em>-</em><code>t1</code>.5716this value is exactly <code>t2</code><em>-</em><code>t1</code>.
5661 5717
5662<p><a name="pdf-os.execute"></a><hr /><h3><code>os.execute ([command])</code></h3>5718<p><a name="pdf-os.execute"></a><hr></hr><h3><code>os.execute ([command])</code></h3>
5663 5719
5664<p>This function is equivalent to the C function <code>system</code>.5720<p>This function is equivalent to the C function <code>system</code>.
5665It passes <code>command</code> to be executed by an operating system shell.5721It 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. · 1 unmodified line
5667If <code>command</code> is absent, then it returns nonzero if a shell is available5723If <code>command</code> is absent, then it returns nonzero if a shell is available
5668and zero otherwise.5724and zero otherwise.
5669 5725
5670<p><a name="pdf-os.exit"></a><hr /><h3><code>os.exit ([code])</code></h3>5726<p><a name="pdf-os.exit"></a><hr></hr><h3><code>os.exit ([code])</code></h3>
5671 5727
5672<p>Calls the C function <code>exit</code>,5728<p>Calls the C function <code>exit</code>,
5673with an optional <code>code</code>,5729with an optional <code>code</code>,
5674to terminate the host program.5730to terminate the host program.
5675The default value for <code>code</code> is the success code.5731The default value for <code>code</code> is the success code.
5676 5732
5677<p><a name="pdf-os.getenv"></a><hr /><h3><code>os.getenv (varname)</code></h3>5733<p><a name="pdf-os.getenv"></a><hr></hr><h3><code>os.getenv (varname)</code></h3>
5678 5734
5679<p>Returns the value of the process environment variable <code>varname</code>,5735<p>Returns the value of the process environment variable <code>varname</code>,
5680or <b>nil</b> if the variable is not defined.5736or <b>nil</b> if the variable is not defined.
5681 5737
5682<p><a name="pdf-os.remove"></a><hr /><h3><code>os.remove (filename)</code></h3>5738<p><a name="pdf-os.remove"></a><hr></hr><h3><code>os.remove (filename)</code></h3>
5683 5739
5684<p>Deletes the file or directory with the given name.5740<p>Deletes the file or directory with the given name.
5685Directories must be empty to be removed.5741Directories must be empty to be removed.
5686If this function fails, it returns <b>nil</b>,5742If this function fails, it returns <b>nil</b>,
5687plus a string describing the error.5743plus a string describing the error.
5688 5744
5689<p><a name="pdf-os.rename"></a><hr /><h3><code>os.rename (oldname, newname)</code></h3>5745<p><a name="pdf-os.rename"></a><hr></hr><h3><code>os.rename (oldname, newname)</code></h3>
5690 5746
5691<p>Renames file or directory named <code>oldname</code> to <code>newname</code>.5747<p>Renames file or directory named <code>oldname</code> to <code>newname</code>.
5692If this function fails, it returns <b>nil</b>,5748If this function fails, it returns <b>nil</b>,
5693plus a string describing the error.5749plus a string describing the error.
5694 5750
5695<p><a name="pdf-os.setlocale"></a><hr /><h3><code>os.setlocale (locale [, category])</code></h3>5751<p><a name="pdf-os.setlocale"></a><hr></hr><h3><code>os.setlocale (locale [, category])</code></h3>
5696 5752
5697<p>Sets the current locale of the program.5753<p>Sets the current locale of the program.
5698<code>locale</code> is a string specifying a locale;5754<code>locale</code> is a string specifying a locale;
@@ -5703,7 +5759,7 @@ the default category is <code>"all"</code>. · 4 unmodified lines
5703The function returns the name of the new locale,5759The function returns the name of the new locale,
5704or <b>nil</b> if the request cannot be honored.5760or <b>nil</b> if the request cannot be honored.
5705 5761
5706<p><a name="pdf-os.time"></a><hr /><h3><code>os.time ([table])</code></h3>5762<p><a name="pdf-os.time"></a><hr></hr><h3><code>os.time ([table])</code></h3>
5707 5763
5708<p>Returns the current time when called without arguments,5764<p>Returns the current time when called without arguments,
5709or a time representing the date and time specified by the given table.5765or 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 < · 2 unmodified lines
5712(for a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function).5768(for a description of these fields, see the <a href="#pdf-os.date"><code>os.date</code></a> function).
5713 5769
5714<p>The returned value is a number, whose meaning depends on your system.5770<p>The returned value is a number, whose meaning depends on your system.
5715In Posix, Windows, and some other systems, this number counts the number5771In POSIX, Windows, and some other systems, this number counts the number
5716of seconds since some given start time (the "epoch").5772of seconds since some given start time (the "epoch").
5717In other systems, the meaning is not specified,5773In other systems, the meaning is not specified,
5718and the number returned by <code>time</code> can be used only as an argument to5774and the number returned by <code>time</code> can be used only as an argument to
5719<code>date</code> and <code>difftime</code>.5775<code>date</code> and <code>difftime</code>.
5720 5776
5721<p><a name="pdf-os.tmpname"></a><hr /><h3><code>os.tmpname ()</code></h3>5777<p><a name="pdf-os.tmpname"></a><hr></hr><h3><code>os.tmpname ()</code></h3>
5722 5778
5723<p>Returns a string with a file name that can5779<p>Returns a string with a file name that can
5724be used for a temporary file.5780be used for a temporary file.
@@ -5745,7 +5801,7 @@ and therefore can compromise otherwise secure code. · 20 unmodified lines
5745<p>All functions in this library are provided5801<p>All functions in this library are provided
5746inside the <code>debug</code> table.5802inside the <code>debug</code> table.
5747 5803
5748<p><a name="pdf-debug.debug"></a><hr /><h3><code>debug.debug ()</code></h3>5804<p><a name="pdf-debug.debug"></a><hr></hr><h3><code>debug.debug ()</code></h3>
5749 5805
5750<p>Enters an interactive mode with the user,5806<p>Enters an interactive mode with the user,
5751running each string that the user enters.5807running each string that the user enters.
@@ -5758,17 +5814,17 @@ so that the caller continues its execution. · 6 unmodified lines
5758<p>Note that commands for <code>debug.debug</code> are not lexically nested5814<p>Note that commands for <code>debug.debug</code> are not lexically nested
5759within any function, and so have no direct access to local variables.5815within any function, and so have no direct access to local variables.
5760 5816
5761<p><a name="pdf-debug.getfenv"></a><hr /><h3><code>debug.getfenv (o)</code></h3>5817<p><a name="pdf-debug.getfenv"></a><hr></hr><h3><code>debug.getfenv (o)</code></h3>
5762Returns the environment of object <code>o</code>.5818Returns the environment of object <code>o</code>.
5763 5819
5764<p><a name="pdf-debug.gethook"></a><hr /><h3><code>debug.gethook ()</code></h3>5820<p><a name="pdf-debug.gethook"></a><hr></hr><h3><code>debug.gethook ()</code></h3>
5765 5821
5766<p>Returns the current hook settings, as three values:5822<p>Returns the current hook settings, as three values:
5767the current hook function, the current hook mask,5823the current hook function, the current hook mask,
5768and the current hook count5824and the current hook count
5769(as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).5825(as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).
5770 5826
5771<p><a name="pdf-debug.getinfo"></a><hr /><h3><code>debug.getinfo (function [, what])</code></h3>5827<p><a name="pdf-debug.getinfo"></a><hr></hr><h3><code>debug.getinfo (function [, what])</code></h3>
5772 5828
5773<p>Returns a table with information about a function.5829<p>Returns a table with information about a function.
5774You can give the function directly,5830You can give the function directly,
@@ -5792,7 +5848,7 @@ a name of the current function, if a reasonable name can be found, · 17 unmodified lines
5792and <code>debug.getinfo(print)</code> returns a table with all available information5848and <code>debug.getinfo(print)</code> returns a table with all available information
5793about the <a href="#pdf-print"><code>print</code></a> function.5849about the <a href="#pdf-print"><code>print</code></a> function.
5794 5850
5795<p><a name="pdf-debug.getlocal"></a><hr /><h3><code>debug.getlocal (level, local)</code></h3>5851<p><a name="pdf-debug.getlocal"></a><hr></hr><h3><code>debug.getlocal (level, local)</code></h3>
5796 5852
5797<p>This function returns the name and the value of the local variable5853<p>This function returns the name and the value of the local variable
5798with index <code>local</code> of the function at level <code>level</code> of the stack.5854with 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. · 8 unmodified lines
5807represent internal variables5863represent internal variables
5808(loop control variables, temporaries, and C function locals).5864(loop control variables, temporaries, and C function locals).
5809 5865
5810<p><a name="pdf-debug.getmetatable"></a><hr /><h3><code>debug.getmetatable (object)</code></h3>5866<p><a name="pdf-debug.getmetatable"></a><hr></hr><h3><code>debug.getmetatable (object)</code></h3>
5811 5867
5812<p>Returns the metatable of the given <code>object</code>5868<p>Returns the metatable of the given <code>object</code>
5813or <b>nil</b> if it does not have a metatable.5869or <b>nil</b> if it does not have a metatable.
5814 5870
5815<p><a name="pdf-debug.getregistry"></a><hr /><h3><code>debug.getregistry ()</code></h3>5871<p><a name="pdf-debug.getregistry"></a><hr></hr><h3><code>debug.getregistry ()</code></h3>
5816 5872
5817<p>Returns the registry table (see <a href="#registry">3.5</a>).5873<p>Returns the registry table (see <a href="#registry">3.5</a>).
5818 5874
5819<p><a name="pdf-debug.getupvalue"></a><hr /><h3><code>debug.getupvalue (func, up)</code></h3>5875<p><a name="pdf-debug.getupvalue"></a><hr></hr><h3><code>debug.getupvalue (func, up)</code></h3>
5820 5876
5821<p>This function returns the name and the value of the upvalue5877<p>This function returns the name and the value of the upvalue
5822with index <code>up</code> of the function <code>func</code>.5878with index <code>up</code> of the function <code>func</code>.
5823The function returns <b>nil</b> if there is no upvalue with the given index.5879The function returns <b>nil</b> if there is no upvalue with the given index.
5824 5880
5825<p><a name="pdf-debug.setfenv"></a><hr /><h3><code>debug.setfenv (object, table)</code></h3>5881<p><a name="pdf-debug.setfenv"></a><hr></hr><h3><code>debug.setfenv (object, table)</code></h3>
5826 5882
5827<p>Sets the environment of the given <code>object</code> to the given <code>table</code>.5883<p>Sets the environment of the given <code>object</code> to the given <code>table</code>.
5828 5884
5829<p><a name="pdf-debug.sethook"></a><hr /><h3><code>debug.sethook (hook, mask [, count])</code></h3>5885<p><a name="pdf-debug.sethook"></a><hr></hr><h3><code>debug.sethook (hook, mask [, count])</code></h3>
5830 5886
5831<p>Sets the given function as a hook.5887<p>Sets the given function as a hook.
5832The string <code>mask</code> and the number <code>count</code> describe5888The string <code>mask</code> and the number <code>count</code> describe
@@ -5859,7 +5915,7 @@ unless the event is <code>"tail return"</code>. · 26 unmodified lines
5859In this case, Lua is only simulating the return,5915In this case, Lua is only simulating the return,
5860and a call to <code>getinfo</code> will return invalid data.5916and a call to <code>getinfo</code> will return invalid data.
5861 5917
5862<p><a name="pdf-debug.setlocal"></a><hr /><h3><code>debug.setlocal (level, local, value)</code></h3>5918<p><a name="pdf-debug.setlocal"></a><hr></hr><h3><code>debug.setlocal (level, local, value)</code></h3>
5863 5919
5864<p>This function assigns the value <code>value</code> to the local variable5920<p>This function assigns the value <code>value</code> to the local variable
5865with index <code>local</code> of the function at level <code>level</code> of the stack.5921with 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. · 3 unmodified lines
5869(You can call <code>getinfo</code> to check whether the level is valid.)5925(You can call <code>getinfo</code> to check whether the level is valid.)
5870Otherwise, it returns the name of the local variable.5926Otherwise, it returns the name of the local variable.
5871 5927
5872<p><a name="pdf-debug.setmetatable"></a><hr /><h3><code>debug.setmetatable (object, table)</code></h3>5928<p><a name="pdf-debug.setmetatable"></a><hr></hr><h3><code>debug.setmetatable (object, table)</code></h3>
5873 5929
5874<p>Sets the metatable for the given <code>object</code> to the given id@{table}5930<p>Sets the metatable for the given <code>object</code> to the given <code>table</code>
5875(which can be <b>nil</b>).5931(which can be <b>nil</b>).
5876 5932
5877<p><a name="pdf-debug.setupvalue"></a><hr /><h3><code>debug.setupvalue (func, up, value)</code></h3>5933<p><a name="pdf-debug.setupvalue"></a><hr></hr><h3><code>debug.setupvalue (func, up, value)</code></h3>
5878 5934
5879<p>This function assigns the value <code>value</code> to the upvalue5935<p>This function assigns the value <code>value</code> to the upvalue
5880with index <code>up</code> of the function <code>func</code>.5936with 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 · 1 unmodified line
5882with the given index.5938with the given index.
5883Otherwise, it returns the name of the upvalue.5939Otherwise, it returns the name of the upvalue.
5884 5940
5885<p><a name="pdf-debug.traceback"></a><hr /><h3><code>debug.traceback ([message])</code></h3>5941<p><a name="pdf-debug.traceback"></a><hr></hr><h3><code>debug.traceback ([message])</code></h3>
5886 5942
5887<p>Returns a string with a traceback of the call stack.5943<p>Returns a string with a traceback of the call stack.
5888An optional <code>message</code> string is appended5944An optional <code>message</code> string is appended
@@ -5969,7 +6025,7 @@ by issuing a different prompt. · 80 unmodified lines
5969<p>If the global variable <code>_PROMPT</code> contains a string,6025<p>If the global variable <code>_PROMPT</code> contains a string,
5970then its value is used as the prompt.6026then its value is used as the prompt.
5971Similarly, if the global variable <code>_PROMPT2</code> contains a string,6027Similarly, if the global variable <code>_PROMPT2</code> contains a string,
5972it its value is used as the secondary prompt6028its value is used as the secondary prompt
5973(issued during incomplete statements).6029(issued during incomplete statements).
5974Therefore, both prompts can be changed directly on the command line.6030Therefore, both prompts can be changed directly on the command line.
5975For instance,6031For instance,
@@ -6001,7 +6057,7 @@ then · 25 unmodified lines
6001</pre>6057</pre>
6002is a more portable solution.) 6058is a more portable solution.)
6003 6059
6004<p><hr />6060<p><hr></hr>
6005 6061
6006<p><h1>Incompatibilities with the Previous Version</h1>6062<p><h1>Incompatibilities with the Previous Version</h1>
6007 6063
@@ -6110,7 +6166,7 @@ Function <code>luaL_openlib</code> was replaced by <a href="#luaL_register"><cod · 102 unmodified lines
6110 6166
6111 6167
6112<p>Here is the complete syntax of Lua in extended BNF.6168<p>Here is the complete syntax of Lua in extended BNF.
6113It does not describe operator priorities nor some syntactical restrictions,6169It does not describe operator priorities or some syntactical restrictions,
6114such as <b>return</b> and <b>break</b> statements6170such as <b>return</b> and <b>break</b> statements
6115can only appear as the <em>last</em> statement of a block.6171can only appear as the <em>last</em> statement of a block.
6116 6172
etc/Makefile+15−6
@@ -8,14 +8,15 @@ SRC= $(TOP)/src · 7 unmodified lines
8TST= $(TOP)/test8TST= $(TOP)/test
9 9
10CC= gcc10CC= gcc
11CFLAGS= -O2 -Wall $(MYCFLAGS)11CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS)
12MYCFLAGS= -ansi -I$(INC)12MYCFLAGS=
13MYLDFLAGS= -Wl,-E13MYLDFLAGS= -Wl,-E
14MYLIBS= -lm -ldl14MYLIBS= -lm
15#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
15RM= rm -f16RM= rm -f
16 17
17all:18default:
18 @echo 'choose a target: min noparser one clean'19 @echo 'Please choose a target: min noparser one clean'
19 20
20min: min.c21min: min.c
21 $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)22 $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)
@@ -31,5 +32,13 @@ one: · 9 unmodified lines
31 $(CC) $(CFLAGS) all.c $(MYLIBS)32 $(CC) $(CFLAGS) all.c $(MYLIBS)
32 ./a.out $(TST)/hello.lua33 ./a.out $(TST)/hello.lua
33 34
35strict:
36 -$(BIN)/lua -e 'print(a);b=2'
37 -$(BIN)/lua -lstrict -e 'print(a)'
38 -$(BIN)/lua -e 'function f() b=2 end f()'
39 -$(BIN)/lua -lstrict -e 'function f() b=2 end f()'
40
34clean:41clean:
35 $(RM) noparser.o a.out core core.* *.o luac.out42 $(RM) a.out core core.* *.o luac.out
43
44.PHONY: default min noparser one strict clean
etc/README+7−2
@@ -1,9 +1,12 @@
1This directory contains some useful files and code.1This directory contains some useful files and code.
2Unlike the code in ../src, everything here is in the public domain.2Unlike the code in ../src, everything here is in the public domain.
3 3
4If any of the makes fail, you're probably not using the same libraries
5used to build Lua. Set MYLIBS in Makefile accordingly.
6
4all.c7all.c
5 Full Lua interpreter in a single file.8 Full Lua interpreter in a single file.
6 Do "make one".9 Do "make one" for a demo.
7 10
8lua.hpp11lua.hpp
9 Lua header files for C++ using 'extern "C"'.12 Lua header files for C++ using 'extern "C"'.
@@ -21,11 +24,13 @@ luavs.bat · 11 unmodified lines
21min.c24min.c
22 A minimal Lua interpreter.25 A minimal Lua interpreter.
23 Good for learning and for starting your own.26 Good for learning and for starting your own.
27 Do "make min" for a demo.
24 28
25noparser.c29noparser.c
26 Linking with noparser.o avoids loading the parsing modules in lualib.a.30 Linking with noparser.o avoids loading the parsing modules in lualib.a.
27 Do "make noparser" to see a demo.31 Do "make noparser" for a demo.
28 32
29strict.lua33strict.lua
30 Traps uses of undeclared global variables.34 Traps uses of undeclared global variables.
35 Do "make strict" for a demo.
31 36
etc/lua.pc+9−9
@@ -1,19 +1,19 @@
1# lua.pc -- pkg-config data for Lua1# lua.pc -- pkg-config data for Lua
2 2
3# vars from install Makefile3# vars from install Makefile
4# grep '^INSTALL_.*=' ../Makefile
5INSTALL_TOP= /usr/local
6INSTALL_BIN= $(INSTALL_TOP)/bin
7INSTALL_INC= $(INSTALL_TOP)/include
8INSTALL_LIB= $(INSTALL_TOP)/lib
9INSTALL_MAN= $(INSTALL_TOP)/man/man1
10INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
11INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
12 4
13# grep '^V=' ../Makefile5# grep '^V=' ../Makefile
14V= 5.16V= 5.1
15 7
16prefix=${INSTALL_TOP}8# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
9prefix= /usr/local
10INSTALL_BIN= ${prefix}/bin
11INSTALL_INC= ${prefix}/include
12INSTALL_LIB= ${prefix}/lib
13INSTALL_MAN= ${prefix}/man/man1
14INSTALL_LMOD= ${prefix}/share/lua/${V}
15INSTALL_CMOD= ${prefix}/lib/lua/${V}
16
17exec_prefix=${prefix}17exec_prefix=${prefix}
18libdir=${exec_prefix}/lib18libdir=${exec_prefix}/lib
19includedir=${prefix}/include19includedir=${prefix}/include
src/Makefile+2−0
@@ -107,6 +107,8 @@ posix: · 106 unmodified lines
107solaris:107solaris:
108 $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"108 $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
109 109
110# list targets that do not create files (but not all makes understand .PHONY)
111.PHONY: all $(PLATS) default o a clean depend echo none
110 112
111# DO NOT DELETE113# DO NOT DELETE
112 114
src/liolib.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp $2** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp $
3** Standard I/O (and system) library3** Standard I/O (and system) library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -283,7 +283,7 @@ static int read_line (lua_State *L, FILE *f) { · 277 unmodified lines
283 return (lua_strlen(L, -1) > 0); /* check whether read something */283 return (lua_strlen(L, -1) > 0); /* check whether read something */
284 }284 }
285 l = strlen(p);285 l = strlen(p);
286 if (p[l-1] != '\n')286 if (l == 0 || p[l-1] != '\n')
287 luaL_addsize(&b, l);287 luaL_addsize(&b, l);
288 else {288 else {
289 luaL_addsize(&b, l - 1); /* do not include `eol' */289 luaL_addsize(&b, l - 1); /* do not include `eol' */
src/llex.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: llex.c,v 2.18 2006/01/23 20:06:19 roberto Exp $2** $Id: llex.c,v 2.19 2006/02/06 18:28:16 roberto Exp $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -166,7 +166,7 @@ static int check_next (LexState *ls, const char *set) { · 160 unmodified lines
166 166
167 167
168static void buffreplace (LexState *ls, char from, char to) {168static void buffreplace (LexState *ls, char from, char to) {
169 int n = luaZ_bufflen(ls->buff);169 size_t n = luaZ_bufflen(ls->buff);
170 char *p = luaZ_buffer(ls->buff);170 char *p = luaZ_buffer(ls->buff);
171 while (n--)171 while (n--)
172 if (p[n] == from) p[n] = to;172 if (p[n] == from) p[n] = to;
src/loslib.c+5−4
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: loslib.c,v 1.16 2005/12/22 16:19:56 roberto Exp $2** $Id: loslib.c,v 1.17 2006/01/27 13:54:31 roberto Exp $
3** Standard Operating System library3** Standard Operating System library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -21,6 +21,7 @@ · 15 unmodified lines
21 21
22 22
23static int os_pushresult (lua_State *L, int i, const char *filename) {23static int os_pushresult (lua_State *L, int i, const char *filename) {
24 int en = errno; /* calls to Lua API may change this value */
24 if (i) {25 if (i) {
25 lua_pushboolean(L, 1);26 lua_pushboolean(L, 1);
26 return 1;27 return 1;
@@ -28,10 +29,10 @@ static int os_pushresult (lua_State *L, int i, const char *filename) { · 1 unmodified line
28 else {29 else {
29 lua_pushnil(L);30 lua_pushnil(L);
30 if (filename)31 if (filename)
31 lua_pushfstring(L, "%s: %s", filename, strerror(errno));32 lua_pushfstring(L, "%s: %s", filename, strerror(en));
32 else33 else
33 lua_pushfstring(L, "%s", strerror(errno));34 lua_pushfstring(L, "%s", strerror(en));
34 lua_pushinteger(L, errno);35 lua_pushinteger(L, en);
35 return 3;36 return 3;
36 }37 }
37}38}
src/lstate.h+5−5
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lstate.h,v 2.23 2005/07/09 13:22:34 roberto Exp $2** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
3** Global State3** Global State
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -49,8 +49,8 @@ typedef struct CallInfo { · 43 unmodified lines
49 StkId base; /* base for this function */49 StkId base; /* base for this function */
50 StkId func; /* function index in the stack */50 StkId func; /* function index in the stack */
51 StkId top; /* top for this function */51 StkId top; /* top for this function */
52 int nresults; /* expected number of results from this function */
53 const Instruction *savedpc;52 const Instruction *savedpc;
53 int nresults; /* expected number of results from this function */
54 int tailcalls; /* number of tail calls lost under this entry */54 int tailcalls; /* number of tail calls lost under this entry */
55} CallInfo;55} CallInfo;
56 56
@@ -71,9 +71,9 @@ typedef struct global_State { · 14 unmodified lines
71 void *ud; /* auxiliary data to `frealloc' */71 void *ud; /* auxiliary data to `frealloc' */
72 lu_byte currentwhite;72 lu_byte currentwhite;
73 lu_byte gcstate; /* state of garbage collector */73 lu_byte gcstate; /* state of garbage collector */
74 int sweepstrgc; /* position of sweep in `strt' */
74 GCObject *rootgc; /* list of all collectable objects */75 GCObject *rootgc; /* list of all collectable objects */
75 GCObject **sweepgc; /* position of sweep in `rootgc' */76 GCObject **sweepgc; /* position of sweep in `rootgc' */
76 int sweepstrgc; /* position of sweep in `strt' */
77 GCObject *gray; /* list of gray objects */77 GCObject *gray; /* list of gray objects */
78 GCObject *grayagain; /* list of objects to be traversed atomically */78 GCObject *grayagain; /* list of objects to be traversed atomically */
79 GCObject *weak; /* list of weak tables (to be cleared) */79 GCObject *weak; /* list of weak tables (to be cleared) */
@@ -99,6 +99,7 @@ typedef struct global_State { · 19 unmodified lines
99*/99*/
100struct lua_State {100struct lua_State {
101 CommonHeader;101 CommonHeader;
102 lu_byte status;
102 StkId top; /* first free slot in the stack */103 StkId top; /* first free slot in the stack */
103 StkId base; /* base of current function */104 StkId base; /* base of current function */
104 global_State *l_G;105 global_State *l_G;
@@ -106,14 +107,13 @@ struct lua_State { · 1 unmodified line
106 const Instruction *savedpc; /* `savedpc' of current function */107 const Instruction *savedpc; /* `savedpc' of current function */
107 StkId stack_last; /* last free slot in the stack */108 StkId stack_last; /* last free slot in the stack */
108 StkId stack; /* stack base */109 StkId stack; /* stack base */
109 int stacksize;
110 CallInfo *end_ci; /* points after end of ci array*/110 CallInfo *end_ci; /* points after end of ci array*/
111 CallInfo *base_ci; /* array of CallInfo's */111 CallInfo *base_ci; /* array of CallInfo's */
112 int stacksize;
112 int size_ci; /* size of array `base_ci' */113 int size_ci; /* size of array `base_ci' */
113 unsigned short nCcalls; /* number of nested C calls */114 unsigned short nCcalls; /* number of nested C calls */
114 lu_byte hookmask;115 lu_byte hookmask;
115 lu_byte allowhook;116 lu_byte allowhook;
116 lu_byte status;
117 int basehookcount;117 int basehookcount;
118 int hookcount;118 int hookcount;
119 lua_Hook hook;119 lua_Hook hook;
src/luaconf.h+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: luaconf.h,v 1.79 2006/01/23 19:51:43 roberto Exp $2** $Id: luaconf.h,v 1.80 2006/01/27 13:54:39 roberto Exp $
3** Configuration file for Lua3** Configuration file for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -541,7 +541,7 @@ · 535 unmodified lines
541*/541*/
542 542
543/* On a Pentium, resort to a trick */543/* On a Pentium, resort to a trick */
544#if !defined(LUA_ANSI) && !defined(__SSE2__) && \544#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
545 (defined(__i386) || defined (_M_IX86) || defined(__i386__))545 (defined(__i386) || defined (_M_IX86) || defined(__i386__))
546union luai_Cast { double l_d; long l_l; };546union luai_Cast { double l_d; long l_l; };
547#define lua_number2int(i,d) \547#define lua_number2int(i,d) \