History

Lua 5.1.3-rc1

Lua Team committed 18 years ago

Commit ea97e791 parent 4d388a360 files · +732 −439Browse files

Unified · Split

60 files
  1. Makefile +7 −13
  2. doc/contents.html +55 −15
  3. doc/manual.css +6 −0
  4. doc/manual.html +513 −285
  5. doc/readme.html +2 −2
  6. etc/lua.pc +1 −1
  7. src/Makefile +1 −2
  8. src/lapi.c +7 −2
  9. src/lapi.h +1 −1
  10. src/lauxlib.c +2 −2
  11. src/lauxlib.h +1 −1
  12. src/lbaselib.c +41 −32
  13. src/lcode.c +2 −2
  14. src/lcode.h +1 −1
  15. src/ldblib.c +1 −1
  16. src/ldebug.c +3 −3
  17. src/ldebug.h +1 −1
  18. src/ldo.c +12 −10
  19. src/ldo.h +1 −1
  20. src/ldump.c +1 −1
  21. src/lfunc.c +1 −1
  22. src/lfunc.h +1 −1
  23. src/lgc.c +1 −1
  24. src/lgc.h +1 −1
  25. src/linit.c +1 −1
  26. src/liolib.c +7 −5
  27. src/llex.c +1 −1
  28. src/llex.h +1 −1
  29. src/llimits.h +1 −1
  30. src/lmathlib.c +1 −1
  31. src/lmem.c +1 −1
  32. src/lmem.h +1 −1
  33. src/loadlib.c +1 −1
  34. src/lobject.c +1 −1
  35. src/lobject.h +1 −1
  36. src/lopcodes.c +1 −1
  37. src/lopcodes.h +1 −1
  38. src/loslib.c +1 −1
  39. src/lparser.c +3 −1
  40. src/lparser.h +1 −1
  41. src/lstate.c +3 −3
  42. src/lstate.h +2 −1
  43. src/lstring.c +1 −1
  44. src/lstring.h +1 −1
  45. src/lstrlib.c +5 −5
  46. src/ltable.c +3 −3
  47. src/ltable.h +1 −1
  48. src/ltablib.c +3 −2
  49. src/ltm.c +1 −1
  50. src/ltm.h +1 −1
  51. src/lua.c +4 −2
  52. src/lua.h +7 −4
  53. src/luaconf.h +3 −2
  54. src/lualib.h +1 −1
  55. src/lundump.c +1 −1
  56. src/lundump.h +1 −1
  57. src/lvm.c +4 −6
  58. src/lvm.h +1 −1
  59. src/lzio.c +1 −1
  60. src/lzio.h +1 −1
Makefile+7−13
@@ -20,20 +20,15 @@ INSTALL_MAN= $(INSTALL_TOP)/man/man1 · 19 unmodified lines
2020 INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
2121 INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
2222
23−# How to install. You may prefer "install" instead of "cp" if you have it.
24−# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
25−#
26−INSTALL_EXEC= $(CP)
27−INSTALL_DATA= $(CP)
28−#INSTALL_EXEC= $(INSTALL) -m 0755
29−#INSTALL_DATA= $(INSTALL) -m 0644
23+# How to install. If you don't have "install" (unlikely) then get install-sh at
24+# http://dev.w3.org/cvsweb/libwww/config/install-sh
25+# or use cp instead.
26+INSTALL_EXEC= $(INSTALL) -p -m 0755
27+INSTALL_DATA= $(INSTALL) -p -m 0644
3028
3129 # Utilities.
32−CP= cp
33−FIND= find
3430 INSTALL= install
3531 MKDIR= mkdir
36−RANLIB= ranlib
3732
3833 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
3934
@@ -48,7 +43,7 @@ TO_MAN= lua.1 luac.1 · 8 unmodified lines
4843
4944 # Lua version and release.
5045 V= 5.1
51−R= 5.1.2
46+R= 5.1.3
5247
5348 all: $(PLAT)
5449
@@ -64,10 +59,9 @@ install: dummy · 9 unmodified lines
6459 cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
6560 cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
6661 cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
67−# $(RANLIB) $(INSTALL_LIB)/$(TO_LIB)
6862
6963 local:
70− $(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"
64+ $(MAKE) install INSTALL_TOP=..
7165
7266 none:
7367 @echo "Please do"
doc/contents.html+55−15
@@ -1,6 +1,6 @@
11 <HTML>
22 <HEAD>
3−<TITLE>Lua 5.1 reference manual - contents</TITLE>
3+<TITLE>Lua 5.1 Reference Manual - contents</TITLE>
44 <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
55 <STYLE TYPE="text/css">
66 ul {
@@ -33,21 +33,28 @@ This is an online version of · 26 unmodified lines
3333 </BLOCKQUOTE>
3434 <P>
3535
36−Buy a paper copy and
36+Buy a copy of this book and
3737 <A HREF="http://www.lua.org/donations.html">help to support</A>
3838 the Lua project.
3939 <P>
4040
41+The reference manual is the official definition of the Lua language.
42+For a complete introduction to Lua programming, see the book
43+<A HREF="http://www.lua.org/docs.html#books">Programming in Lua</A>.
44+<P>
45+
4146 <A HREF="manual.html">start</A>
4247 &middot;
4348 <A HREF="#contents">contents</A>
4449 &middot;
4550 <A HREF="#index">index</A>
4651 &middot;
47−<A HREF="http://www.lua.org/manual/5.1/errata.html">errata</A>
52+<A HREF="http://www.lua.org/manual/5.1/pt/">portugu&ecirc;s</A>
53+&middot;
54+<A HREF="http://www.lua.org/manual/5.1/es/">espa&ntilde;ol</A>
4855 <HR>
4956 <SMALL>
50−Copyright &copy; 2006-2007 Lua.org, PUC-Rio.
57+Copyright &copy; 2006-2008 Lua.org, PUC-Rio.
5158 Freely available under the terms of the
5259 <a href="http://www.lua.org/license.html#5">Lua license</a>.
5360 </SMALL>
@@ -55,7 +62,8 @@ Freely available under the terms of the · 1 unmodified line
5562
5663 <H2><A NAME="contents">Contents</A></H2>
5764 <UL style="padding: 0">
58−<LI><A HREF="manual.html#1">1 - Introduction</A>
65+<LI><A HREF="manual.html">1 - Introduction</A>
66+<P>
5967 <LI><A HREF="manual.html#2">2 - The Language</A>
6068 <UL>
6169 <LI><A HREF="manual.html#2.1">2.1 - Lexical Conventions</A>
@@ -97,6 +105,7 @@ Freely available under the terms of the · 35 unmodified lines
97105 </UL>
98106 <LI><A HREF="manual.html#2.11">2.11 - Coroutines</A>
99107 </UL>
108+<P>
100109 <LI><A HREF="manual.html#3">3 - The Application Program Interface</A>
101110 <UL>
102111 <LI><A HREF="manual.html#3.1">3.1 - The Stack</A>
@@ -108,10 +117,12 @@ Freely available under the terms of the · 5 unmodified lines
108117 <LI><A HREF="manual.html#3.7">3.7 - Functions and Types</A>
109118 <LI><A HREF="manual.html#3.8">3.8 - The Debug Interface</A>
110119 </UL>
120+<P>
111121 <LI><A HREF="manual.html#4">4 - The Auxiliary Library</A>
112122 <UL>
113123 <LI><A HREF="manual.html#4.1">4.1 - Functions and Types</A>
114124 </UL>
125+<P>
115126 <LI><A HREF="manual.html#5">5 - Standard Libraries</A>
116127 <UL>
117128 <LI><A HREF="manual.html#5.1">5.1 - Basic Functions</A>
@@ -127,13 +138,16 @@ Freely available under the terms of the · 9 unmodified lines
127138 <LI><A HREF="manual.html#5.8">5.8 - Operating System Facilities</A>
128139 <LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A>
129140 </UL>
141+<P>
130142 <LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
143+<P>
131144 <LI><A HREF="manual.html#7">7 - Incompatibilities with the Previous Version</A>
132145 <UL>
133146 <LI><A HREF="manual.html#7.1">7.1 - Changes in the Language</A>
134147 <LI><A HREF="manual.html#7.2">7.2 - Changes in the Libraries</A>
135148 <LI><A HREF="manual.html#7.3">7.3 - Changes in the API</A>
136149 </UL>
150+<P>
137151 <LI><A HREF="manual.html#8">8 - The Complete Syntax of Lua</A>
138152 </UL>
139153
@@ -171,16 +185,16 @@ Freely available under the terms of the · 31 unmodified lines
171185 <A HREF="manual.html#pdf-type">type</A><BR>
172186 <A HREF="manual.html#pdf-unpack">unpack</A><BR>
173187 <A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
188+<P>
174189
175−</TD>
176−<TD>
177−<H3>&nbsp;</H3>
178190 <A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
179191 <A HREF="manual.html#pdf-coroutine.resume">coroutine.resume</A><BR>
180192 <A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR>
181193 <A HREF="manual.html#pdf-coroutine.status">coroutine.status</A><BR>
182194 <A HREF="manual.html#pdf-coroutine.wrap">coroutine.wrap</A><BR>
183195 <A HREF="manual.html#pdf-coroutine.yield">coroutine.yield</A><BR>
196+<P>
197+
184198 <A HREF="manual.html#pdf-debug.debug">debug.debug</A><BR>
185199 <A HREF="manual.html#pdf-debug.getfenv">debug.getfenv</A><BR>
186200 <A HREF="manual.html#pdf-debug.gethook">debug.gethook</A><BR>
@@ -195,6 +209,10 @@ Freely available under the terms of the · 8 unmodified lines
195209 <A HREF="manual.html#pdf-debug.setmetatable">debug.setmetatable</A><BR>
196210 <A HREF="manual.html#pdf-debug.setupvalue">debug.setupvalue</A><BR>
197211 <A HREF="manual.html#pdf-debug.traceback">debug.traceback</A><BR>
212+
213+</TD>
214+<TD>
215+<H3>&nbsp;</H3>
198216 <A HREF="manual.html#pdf-file:close">file:close</A><BR>
199217 <A HREF="manual.html#pdf-file:flush">file:flush</A><BR>
200218 <A HREF="manual.html#pdf-file:lines">file:lines</A><BR>
@@ -202,6 +220,8 @@ Freely available under the terms of the · 1 unmodified line
202220 <A HREF="manual.html#pdf-file:seek">file:seek</A><BR>
203221 <A HREF="manual.html#pdf-file:setvbuf">file:setvbuf</A><BR>
204222 <A HREF="manual.html#pdf-file:write">file:write</A><BR>
223+<P>
224+
205225 <A HREF="manual.html#pdf-io.close">io.close</A><BR>
206226 <A HREF="manual.html#pdf-io.flush">io.flush</A><BR>
207227 <A HREF="manual.html#pdf-io.input">io.input</A><BR>
@@ -210,17 +230,22 @@ Freely available under the terms of the · 2 unmodified lines
210230 <A HREF="manual.html#pdf-io.output">io.output</A><BR>
211231 <A HREF="manual.html#pdf-io.popen">io.popen</A><BR>
212232 <A HREF="manual.html#pdf-io.read">io.read</A><BR>
233+<A HREF="manual.html#pdf-io.stderr">io.stderr</A><BR>
234+<A HREF="manual.html#pdf-io.stdin">io.stdin</A><BR>
235+<A HREF="manual.html#pdf-io.stdout">io.stdout</A><BR>
213236 <A HREF="manual.html#pdf-io.tmpfile">io.tmpfile</A><BR>
214237 <A HREF="manual.html#pdf-io.type">io.type</A><BR>
215238 <A HREF="manual.html#pdf-io.write">io.write</A><BR>
239+<P>
240+
216241 <A HREF="manual.html#pdf-math.abs">math.abs</A><BR>
217242 <A HREF="manual.html#pdf-math.acos">math.acos</A><BR>
218243 <A HREF="manual.html#pdf-math.asin">math.asin</A><BR>
219−<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
220244 <A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
245+<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
221246 <A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>
222−<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
223247 <A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
248+<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
224249 <A HREF="manual.html#pdf-math.deg">math.deg</A><BR>
225250 <A HREF="manual.html#pdf-math.exp">math.exp</A><BR>
226251 <A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
@@ -228,8 +253,8 @@ Freely available under the terms of the · 1 unmodified line
228253 <A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
229254 <A HREF="manual.html#pdf-math.huge">math.huge</A><BR>
230255 <A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>
231−<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
232256 <A HREF="manual.html#pdf-math.log">math.log</A><BR>
257+<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
233258 <A HREF="manual.html#pdf-math.max">math.max</A><BR>
234259 <A HREF="manual.html#pdf-math.min">math.min</A><BR>
235260 <A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
@@ -238,11 +263,13 @@ Freely available under the terms of the · 2 unmodified lines
238263 <A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
239264 <A HREF="manual.html#pdf-math.random">math.random</A><BR>
240265 <A HREF="manual.html#pdf-math.randomseed">math.randomseed</A><BR>
241−<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
242266 <A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
267+<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
243268 <A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
244−<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
245269 <A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
270+<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
271+<P>
272+
246273 <A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
247274 <A HREF="manual.html#pdf-os.date">os.date</A><BR>
248275 <A HREF="manual.html#pdf-os.difftime">os.difftime</A><BR>
@@ -254,12 +281,17 @@ Freely available under the terms of the · 5 unmodified lines
254281 <A HREF="manual.html#pdf-os.setlocale">os.setlocale</A><BR>
255282 <A HREF="manual.html#pdf-os.time">os.time</A><BR>
256283 <A HREF="manual.html#pdf-os.tmpname">os.tmpname</A><BR>
284+<P>
285+
257286 <A HREF="manual.html#pdf-package.cpath">package.cpath</A><BR>
258287 <A HREF="manual.html#pdf-package.loaded">package.loaded</A><BR>
288+<A HREF="manual.html#pdf-package.loaders">package.loaders</A><BR>
259289 <A HREF="manual.html#pdf-package.loadlib">package.loadlib</A><BR>
260290 <A HREF="manual.html#pdf-package.path">package.path</A><BR>
261291 <A HREF="manual.html#pdf-package.preload">package.preload</A><BR>
262292 <A HREF="manual.html#pdf-package.seeall">package.seeall</A><BR>
293+<P>
294+
263295 <A HREF="manual.html#pdf-string.byte">string.byte</A><BR>
264296 <A HREF="manual.html#pdf-string.char">string.char</A><BR>
265297 <A HREF="manual.html#pdf-string.dump">string.dump</A><BR>
@@ -274,6 +306,8 @@ Freely available under the terms of the · 8 unmodified lines
274306 <A HREF="manual.html#pdf-string.reverse">string.reverse</A><BR>
275307 <A HREF="manual.html#pdf-string.sub">string.sub</A><BR>
276308 <A HREF="manual.html#pdf-string.upper">string.upper</A><BR>
309+<P>
310+
277311 <A HREF="manual.html#pdf-table.concat">table.concat</A><BR>
278312 <A HREF="manual.html#pdf-table.insert">table.insert</A><BR>
279313 <A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR>
@@ -292,6 +326,8 @@ Freely available under the terms of the · 12 unmodified lines
292326 <A HREF="manual.html#lua_Reader">lua_Reader</A><BR>
293327 <A HREF="manual.html#lua_State">lua_State</A><BR>
294328 <A HREF="manual.html#lua_Writer">lua_Writer</A><BR>
329+<P>
330+
295331 <A HREF="manual.html#lua_atpanic">lua_atpanic</A><BR>
296332 <A HREF="manual.html#lua_call">lua_call</A><BR>
297333 <A HREF="manual.html#lua_checkstack">lua_checkstack</A><BR>
@@ -323,6 +359,8 @@ Freely available under the terms of the · 25 unmodified lines
323359 <A HREF="manual.html#lua_isfunction">lua_isfunction</A><BR>
324360 <A HREF="manual.html#lua_islightuserdata">lua_islightuserdata</A><BR>
325361 <A HREF="manual.html#lua_isnil">lua_isnil</A><BR>
362+<A HREF="manual.html#lua_isnone">lua_isnone</A><BR>
363+<A HREF="manual.html#lua_isnoneornil">lua_isnoneornil</A><BR>
326364 <A HREF="manual.html#lua_isnumber">lua_isnumber</A><BR>
327365 <A HREF="manual.html#lua_isstring">lua_isstring</A><BR>
328366 <A HREF="manual.html#lua_istable">lua_istable</A><BR>
@@ -391,6 +429,8 @@ Freely available under the terms of the · 62 unmodified lines
391429 <H3>auxiliary library</H3>
392430 <A HREF="manual.html#luaL_Buffer">luaL_Buffer</A><BR>
393431 <A HREF="manual.html#luaL_Reg">luaL_Reg</A><BR>
432+<P>
433+
394434 <A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR>
395435 <A HREF="manual.html#luaL_addlstring">luaL_addlstring</A><BR>
396436 <A HREF="manual.html#luaL_addsize">luaL_addsize</A><BR>
@@ -446,10 +486,10 @@ Freely available under the terms of the · 49 unmodified lines
446486 <HR>
447487 <SMALL>
448488 Last update:
449−Fri Mar 23 08:33:19 BRT 2007
489+Thu Jan 17 14:50:23 BRST 2008
450490 </SMALL>
451491 <!--
452−Last change: minor edit
492+Last change: revised for Lua 5.1.3
453493 -->
454494
455495 </BODY>
doc/manual.css+6−0
@@ -5,3 +5,9 @@ h3 code { · 4 unmodified lines
55 pre {
66 font-size: 105% ;
77 }
8+
9+span.apii {
10+ float: right ;
11+ font-family: inherit ;
12+}
13+
doc/manual.html+513−285
@@ -18,7 +18,7 @@ Lua 5.1 Reference Manual · 17 unmodified lines
1818 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
1919 <p>
2020 <small>
21−Copyright &copy; 2006-2007 Lua.org, PUC-Rio.
21+Copyright &copy; 2006-2008 Lua.org, PUC-Rio.
2222 Freely available under the terms of the
2323 <a href="http://www.lua.org/license.html#5">Lua license</a>.
2424 </small>
@@ -32,6 +32,7 @@ Freely available under the terms of the · 7 unmodified lines
3232 <!-- ====================================================================== -->
3333 <p>
3434
35+<!-- $Id: manual.of,v 1.43 2008/01/17 16:19:44 roberto Exp $ -->
3536
3637
3738
@@ -554,9 +555,9 @@ and a list of expressions on the right side. · 516 unmodified lines
554555 The elements in both lists are separated by commas:
555556
556557 <pre>
557− stat ::= varlist1 `<b>=</b>&acute; explist1
558− varlist1 ::= var {`<b>,</b>&acute; var}
559− explist1 ::= exp {`<b>,</b>&acute; exp}
558+ stat ::= varlist `<b>=</b>&acute; explist
559+ varlist ::= var {`<b>,</b>&acute; var}
560+ explist ::= exp {`<b>,</b>&acute; exp}
560561 </pre><p>
561562 Expressions are discussed in <a href="#2.5">&sect;2.5</a>.
562563
@@ -663,7 +664,7 @@ Functions and chunks may return more than one value, · 100 unmodified lines
663664 so the syntax for the <b>return</b> statement is
664665
665666 <pre>
666− stat ::= <b>return</b> [explist1]
667+ stat ::= <b>return</b> [explist]
667668 </pre>
668669
669670 <p>
@@ -771,7 +772,7 @@ stopping when this new value is <b>nil</b>. · 101 unmodified lines
771772 The generic <b>for</b> loop has the following syntax:
772773
773774 <pre>
774− stat ::= <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b>
775+ stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
775776 namelist ::= Name {`<b>,</b>&acute; Name}
776777 </pre><p>
777778 A <b>for</b> statement like
@@ -843,7 +844,7 @@ Local variables may be declared anywhere inside a block. · 65 unmodified lines
843844 The declaration may include an initial assignment:
844845
845846 <pre>
846− stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist1]
847+ stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist]
847848 </pre><p>
848849 If present, an initial assignment has the same semantics
849850 of a multiple assignment (see <a href="#2.4.3">&sect;2.4.3</a>).
@@ -1221,7 +1222,7 @@ except that <code>v</code> is evaluated only once. · 371 unmodified lines
12211222 Arguments have the following syntax:
12221223
12231224 <pre>
1224− args ::= `<b>(</b>&acute; [explist1] `<b>)</b>&acute;
1225+ args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute;
12251226 args ::= tableconstructor
12261227 args ::= String
12271228 </pre><p>
@@ -1286,7 +1287,7 @@ The syntax for function definition is · 58 unmodified lines
12861287
12871288 <pre>
12881289 function ::= <b>function</b> funcbody
1289− funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
1290+ funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
12901291 </pre>
12911292
12921293 <p>
@@ -1355,7 +1356,7 @@ Parameters act as local variables that are · 62 unmodified lines
13551356 initialized with the argument values:
13561357
13571358 <pre>
1358− parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
1359+ parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
13591360 </pre><p>
13601361 When a function is called,
13611362 the list of arguments is adjusted to
@@ -1551,11 +1552,11 @@ you must use the C&nbsp;API for that. · 189 unmodified lines
15511552
15521553
15531554 <p>
1554−Tables and userdata have individual metatables
1555+Tables and full userdata have individual metatables
15551556 (although multiple tables and userdata can share their metatables);
15561557 values of all other types share one single metatable per type.
15571558 So, there is one single metatable for all numbers,
1558−and for all strings, etc.
1559+one for all strings, etc.
15591560
15601561
15611562 <p>
@@ -1638,7 +1639,7 @@ the behavior of the <code>op1 + op2</code> is · 76 unmodified lines
16381639 local h = getbinhandler(op1, op2, "__add")
16391640 if h then
16401641 -- call the handler with both operands
1641− return h(op1, op2)
1642+ return (h(op1, op2))
16421643 else -- no handler available: default behavior
16431644 error(&middot;&middot;&middot;)
16441645 end
@@ -1695,7 +1696,7 @@ the unary <code>-</code> operation. · 50 unmodified lines
16951696 local h = metatable(op).__unm
16961697 if h then
16971698 -- call the handler with the operand
1698− return h(op)
1699+ return (h(op))
16991700 else -- no handler available: default behavior
17001701 error(&middot;&middot;&middot;)
17011702 end
@@ -1716,7 +1717,7 @@ the <code>..</code> (concatenation) operation. · 14 unmodified lines
17161717 else
17171718 local h = getbinhandler(op1, op2, "__concat")
17181719 if h then
1719− return h(op1, op2)
1720+ return (h(op1, op2))
17201721 else
17211722 error(&middot;&middot;&middot;)
17221723 end
@@ -1739,7 +1740,7 @@ the <code>#</code> operation. · 16 unmodified lines
17391740 local h = metatable(op).__len
17401741 if h then
17411742 -- call the handler with the operand
1742− return h(op)
1743+ return (h(op))
17431744 else -- no handler available: default behavior
17441745 error(&middot;&middot;&middot;)
17451746 end
@@ -1779,7 +1780,7 @@ The "eq" event is defined as follows: · 33 unmodified lines
17791780 -- try metamethod
17801781 local h = getcomphandler(op1, op2, "__eq")
17811782 if h then
1782− return h(op1, op2)
1783+ return (h(op1, op2))
17831784 else
17841785 return false
17851786 end
@@ -1801,7 +1802,7 @@ the <code>&lt;</code> operation. · 15 unmodified lines
18011802 else
18021803 local h = getcomphandler(op1, op2, "__lt")
18031804 if h then
1804− return h(op1, op2)
1805+ return (h(op1, op2))
18051806 else
18061807 error(&middot;&middot;&middot;);
18071808 end
@@ -1824,7 +1825,7 @@ the <code>&lt;=</code> operation. · 16 unmodified lines
18241825 else
18251826 local h = getcomphandler(op1, op2, "__le")
18261827 if h then
1827− return h(op1, op2)
1828+ return (h(op1, op2))
18281829 else
18291830 h = getcomphandler(op1, op2, "__lt")
18301831 if h then
@@ -1861,8 +1862,8 @@ The indexing access <code>table[key]</code>. · 30 unmodified lines
18611862 end
18621863 end
18631864 if type(h) == "function" then
1864− return h(table, key) -- call the handler
1865− else return h[key] -- or repeat operation on it
1865+ return (h(table, key)) -- call the handler
1866+ else return h[key] -- or repeat operation on it
18661867 end
18671868 end
18681869 </pre><p>
@@ -1887,7 +1888,7 @@ The indexing assignment <code>table[key] = value</code>. · 18 unmodified lines
18871888 end
18881889 end
18891890 if type(h) == "function" then
1890− return h(table, key,value) -- call the handler
1891+ h(table, key,value) -- call the handler
18911892 else h[key] = value -- or repeat operation on it
18921893 end
18931894 end
@@ -2062,6 +2063,7 @@ order of their creation, · 168 unmodified lines
20622063 among those collected in that cycle.
20632064 That is, the first finalizer to be called is the one associated
20642065 with the userdata created last in the program.
2066+The userdata itself is freed only in the next garbage-collection cycle.
20652067
20662068
20672069
@@ -2427,17 +2429,14 @@ any error jumps to the most recent active recover point. · 359 unmodified lines
24272429
24282430
24292431 <p>
2430−Almost any function in the API may raise an error,
2432+Most functions in the API may throw an error,
24312433 for instance due to a memory allocation error.
2432−The following functions run in protected mode
2433−(that is, they create a protected environment to run),
2434−so they never raise an error:
2435−<a href="#lua_newstate"><code>lua_newstate</code></a>, <a href="#lua_close"><code>lua_close</code></a>, <a href="#lua_load"><code>lua_load</code></a>,
2436−<a href="#lua_pcall"><code>lua_pcall</code></a>, and <a href="#lua_cpcall"><code>lua_cpcall</code></a>.
2434+The documentation for each function indicates whether
2435+it can throw errors.
24372436
24382437
24392438 <p>
2440−Inside a C&nbsp;function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
2439+Inside a C&nbsp;function you can throw an error by calling <a href="#lua_error"><code>lua_error</code></a>.
24412440
24422441
24432442
@@ -2448,6 +2447,30 @@ Inside a C&nbsp;function you can raise an error by calling <a href="#lua_error"> · 4 unmodified lines
24482447 <p>
24492448 Here we list all functions and types from the C&nbsp;API in
24502449 alphabetical order.
2450+Each function has an indicator like this:
2451+<span class="apii">[-o, +p, <em>x</em>]</span>
2452+
2453+
2454+<p>
2455+The first field, <code>o</code>,
2456+is how many elements the function pops from the stack.
2457+The second field, <code>p</code>,
2458+is how many elements the function pushes onto the stack.
2459+(Any function always pushes its results after popping its arguments.)
2460+A field in the form <code>x|y</code> means the function may push (or pop)
2461+<code>x</code> or <code>y</code> elements,
2462+depending on the situation;
2463+an interrogation mark '<code>?</code>' means that
2464+we cannot know how many elements the function pops/pushes
2465+by looking only at its arguments
2466+(e.g., they may depend on what is on the stack).
2467+The third field, <code>x</code>,
2468+tells whether the function may throw errors:
2469+'<code>-</code>' means the function never throws any error;
2470+'<code>m</code>' means the function may throw an error
2471+only due to not enough memory;
2472+'<code>e</code>' means the function may throw other kinds of errors;
2473+'<code>v</code>' means the function may throw an error on purpose.
24512474
24522475
24532476
@@ -2506,7 +2529,8 @@ ANSI&nbsp;C ensures both behaviors. · 52 unmodified lines
25062529
25072530
25082531
2509−<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3>
2532+<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
2533+<span class="apii">[-0, +0, <em>-</em>]</span>
25102534 <pre>lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
25112535
25122536 <p>
@@ -2529,7 +2553,8 @@ The panic function can access the error message at the top of the stack. · 16 unmodified lines
25292553
25302554
25312555
2532−<hr><h3><a name="lua_call"><code>lua_call</code></a></h3>
2556+<hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
2557+<span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
25332558 <pre>void lua_call (lua_State *L, int nargs, int nresults);</pre>
25342559
25352560 <p>
@@ -2639,7 +2664,8 @@ of numerical arguments and returns their average and sum: · 103 unmodified lines
26392664
26402665
26412666
2642−<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3>
2667+<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
2668+<span class="apii">[-0, +0, <em>-</em>]</span>
26432669 <pre>int lua_checkstack (lua_State *L, int extra);</pre>
26442670
26452671 <p>
@@ -2653,7 +2679,8 @@ it is left unchanged. · 7 unmodified lines
26532679
26542680
26552681
2656−<hr><h3><a name="lua_close"><code>lua_close</code></a></h3>
2682+<hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
2683+<span class="apii">[-0, +0, <em>-</em>]</span>
26572684 <pre>void lua_close (lua_State *L);</pre>
26582685
26592686 <p>
@@ -2671,23 +2698,25 @@ to avoid growing too large. · 11 unmodified lines
26712698
26722699
26732700
2674−<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3>
2701+<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
2702+<span class="apii">[-n, +1, <em>e</em>]</span>
26752703 <pre>void lua_concat (lua_State *L, int n);</pre>
26762704
26772705 <p>
26782706 Concatenates the <code>n</code> values at the top of the stack,
26792707 pops them, and leaves the result at the top.
2680−If <code>n</code>&nbsp;is&nbsp;1, the result is the single string on the stack
2708+If <code>n</code>&nbsp;is&nbsp;1, the result is the single value on the stack
26812709 (that is, the function does nothing);
26822710 if <code>n</code> is 0, the result is the empty string.
2683−Concatenation is done following the usual semantics of Lua
2711+Concatenation is performed following the usual semantics of Lua
26842712 (see <a href="#2.5.4">&sect;2.5.4</a>).
26852713
26862714
26872715
26882716
26892717
2690−<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3>
2718+<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3><p>
2719+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
26912720 <pre>int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);</pre>
26922721
26932722 <p>
@@ -2704,7 +2733,8 @@ All values returned by <code>func</code> are discarded. · 10 unmodified lines
27042733
27052734
27062735
2707−<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3>
2736+<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
2737+<span class="apii">[-0, +1, <em>m</em>]</span>
27082738 <pre>void lua_createtable (lua_State *L, int narr, int nrec);</pre>
27092739
27102740 <p>
@@ -2719,7 +2749,8 @@ Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</c · 8 unmodified lines
27192749
27202750
27212751
2722−<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3>
2752+<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
2753+<span class="apii">[-0, +0, <em>m</em>]</span>
27232754 <pre>int lua_dump (lua_State *L, lua_Writer writer, void *data);</pre>
27242755
27252756 <p>
@@ -2747,7 +2778,8 @@ This function does not pop the Lua function from the stack. · 21 unmodified lines
27472778
27482779
27492780
2750−<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3>
2781+<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3><p>
2782+<span class="apii">[-0, +0, <em>e</em>]</span>
27512783 <pre>int lua_equal (lua_State *L, int index1, int index2);</pre>
27522784
27532785 <p>
@@ -2762,7 +2794,8 @@ Also returns&nbsp;0 if any of the indices is non valid. · 8 unmodified lines
27622794
27632795
27642796
2765−<hr><h3><a name="lua_error"><code>lua_error</code></a></h3>
2797+<hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
2798+<span class="apii">[-1, +0, <em>v</em>]</span>
27662799 <pre>int lua_error (lua_State *L);</pre>
27672800
27682801 <p>
@@ -2777,7 +2810,8 @@ and therefore never returns. · 8 unmodified lines
27772810
27782811
27792812
2780−<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3>
2813+<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
2814+<span class="apii">[-0, +0, <em>e</em>]</span>
27812815 <pre>int lua_gc (lua_State *L, int what, int data);</pre>
27822816
27832817 <p>
@@ -2838,7 +2872,8 @@ The function returns the previous value of the step multiplier. · 54 unmodified lines
28382872
28392873
28402874
2841−<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3>
2875+<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
2876+<span class="apii">[-0, +0, <em>-</em>]</span>
28422877 <pre>lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
28432878
28442879 <p>
@@ -2850,7 +2885,8 @@ opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>. · 5 unmodified lines
28502885
28512886
28522887
2853−<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3>
2888+<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3><p>
2889+<span class="apii">[-0, +1, <em>-</em>]</span>
28542890 <pre>void lua_getfenv (lua_State *L, int index);</pre>
28552891
28562892 <p>
@@ -2861,12 +2897,13 @@ the value at the given index. · 4 unmodified lines
28612897
28622898
28632899
2864−<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3>
2900+<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
2901+<span class="apii">[-0, +1, <em>e</em>]</span>
28652902 <pre>void lua_getfield (lua_State *L, int index, const char *k);</pre>
28662903
28672904 <p>
28682905 Pushes onto the stack the value <code>t[k]</code>,
2869−where <code>t</code> is the value at the given valid index <code>index</code>.
2906+where <code>t</code> is the value at the given valid index.
28702907 As in Lua, this function may trigger a metamethod
28712908 for the "index" event (see <a href="#2.8">&sect;2.8</a>).
28722909
@@ -2874,7 +2911,8 @@ for the "index" event (see <a href="#2.8">&sect;2.8</a>). · 1 unmodified line
28742911
28752912
28762913
2877−<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3>
2914+<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
2915+<span class="apii">[-0, +1, <em>e</em>]</span>
28782916 <pre>void lua_getglobal (lua_State *L, const char *name);</pre>
28792917
28802918 <p>
@@ -2888,7 +2926,8 @@ It is defined as a macro: · 7 unmodified lines
28882926
28892927
28902928
2891−<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3>
2929+<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
2930+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
28922931 <pre>int lua_getmetatable (lua_State *L, int index);</pre>
28932932
28942933 <p>
@@ -2902,12 +2941,13 @@ the function returns&nbsp;0 and pushes nothing on the stack. · 7 unmodified lines
29022941
29032942
29042943
2905−<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3>
2944+<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
2945+<span class="apii">[-1, +1, <em>e</em>]</span>
29062946 <pre>void lua_gettable (lua_State *L, int index);</pre>
29072947
29082948 <p>
29092949 Pushes onto the stack the value <code>t[k]</code>,
2910−where <code>t</code> is the value at the given valid index <code>index</code>
2950+where <code>t</code> is the value at the given valid index
29112951 and <code>k</code> is the value at the top of the stack.
29122952
29132953
@@ -2921,7 +2961,8 @@ for the "index" event (see <a href="#2.8">&sect;2.8</a>). · 7 unmodified lines
29212961
29222962
29232963
2924−<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3>
2964+<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
2965+<span class="apii">[-0, +0, <em>-</em>]</span>
29252966 <pre>int lua_gettop (lua_State *L);</pre>
29262967
29272968 <p>
@@ -2934,7 +2975,8 @@ this result is equal to the number of elements in the stack · 6 unmodified lines
29342975
29352976
29362977
2937−<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3>
2978+<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
2979+<span class="apii">[-1, +1, <em>-</em>]</span>
29382980 <pre>void lua_insert (lua_State *L, int index);</pre>
29392981
29402982 <p>
@@ -2963,7 +3005,8 @@ which is usually the largest signed integral type the machine handles · 22 unmodified lines
29633005
29643006
29653007
2966−<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3>
3008+<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
3009+<span class="apii">[-0, +0, <em>-</em>]</span>
29673010 <pre>int lua_isboolean (lua_State *L, int index);</pre>
29683011
29693012 <p>
@@ -2974,7 +3017,8 @@ and 0&nbsp;otherwise. · 4 unmodified lines
29743017
29753018
29763019
2977−<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3>
3020+<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
3021+<span class="apii">[-0, +0, <em>-</em>]</span>
29783022 <pre>int lua_iscfunction (lua_State *L, int index);</pre>
29793023
29803024 <p>
@@ -2985,7 +3029,8 @@ and 0&nbsp;otherwise. · 4 unmodified lines
29853029
29863030
29873031
2988−<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3>
3032+<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
3033+<span class="apii">[-0, +0, <em>-</em>]</span>
29893034 <pre>int lua_isfunction (lua_State *L, int index);</pre>
29903035
29913036 <p>
@@ -2996,7 +3041,8 @@ Returns 1 if the value at the given acceptable index is a function · 4 unmodified lines
29963041
29973042
29983043
2999−<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3>
3044+<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
3045+<span class="apii">[-0, +0, <em>-</em>]</span>
30003046 <pre>int lua_islightuserdata (lua_State *L, int index);</pre>
30013047
30023048 <p>
@@ -3007,7 +3053,8 @@ and 0&nbsp;otherwise. · 4 unmodified lines
30073053
30083054
30093055
3010−<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3>
3056+<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
3057+<span class="apii">[-0, +0, <em>-</em>]</span>
30113058 <pre>int lua_isnil (lua_State *L, int index);</pre>
30123059
30133060 <p>
@@ -3018,11 +3065,12 @@ and 0&nbsp;otherwise. · 4 unmodified lines
30183065
30193066
30203067
3021−<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3>
3068+<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
3069+<span class="apii">[-0, +0, <em>-</em>]</span>
30223070 <pre>int lua_isnone (lua_State *L, int index);</pre>
30233071
30243072 <p>
3025−Returns 1 if the the given acceptable index is not valid
3073+Returns 1 if the given acceptable index is not valid
30263074 (that is, it refers to an element outside the current stack),
30273075 and 0&nbsp;otherwise.
30283076
@@ -3030,11 +3078,12 @@ and 0&nbsp;otherwise. · 1 unmodified line
30303078
30313079
30323080
3033−<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3>
3081+<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
3082+<span class="apii">[-0, +0, <em>-</em>]</span>
30343083 <pre>int lua_isnoneornil (lua_State *L, int index);</pre>
30353084
30363085 <p>
3037−Returns 1 if the the given acceptable index is not valid
3086+Returns 1 if the given acceptable index is not valid
30383087 (that is, it refers to an element outside the current stack)
30393088 or if the value at this index is <b>nil</b>,
30403089 and 0&nbsp;otherwise.
@@ -3043,7 +3092,8 @@ and 0&nbsp;otherwise. · 2 unmodified lines
30433092
30443093
30453094
3046−<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3>
3095+<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
3096+<span class="apii">[-0, +0, <em>-</em>]</span>
30473097 <pre>int lua_isnumber (lua_State *L, int index);</pre>
30483098
30493099 <p>
@@ -3055,7 +3105,8 @@ and 0&nbsp;otherwise. · 5 unmodified lines
30553105
30563106
30573107
3058−<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3>
3108+<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
3109+<span class="apii">[-0, +0, <em>m</em>]</span>
30593110 <pre>int lua_isstring (lua_State *L, int index);</pre>
30603111
30613112 <p>
@@ -3067,7 +3118,8 @@ and 0&nbsp;otherwise. · 5 unmodified lines
30673118
30683119
30693120
3070−<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3>
3121+<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
3122+<span class="apii">[-0, +0, <em>-</em>]</span>
30713123 <pre>int lua_istable (lua_State *L, int index);</pre>
30723124
30733125 <p>
@@ -3078,7 +3130,8 @@ and 0&nbsp;otherwise. · 4 unmodified lines
30783130
30793131
30803132
3081−<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3>
3133+<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
3134+<span class="apii">[-0, +0, <em>-</em>]</span>
30823135 <pre>int lua_isthread (lua_State *L, int index);</pre>
30833136
30843137 <p>
@@ -3089,7 +3142,8 @@ and 0&nbsp;otherwise. · 4 unmodified lines
30893142
30903143
30913144
3092−<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3>
3145+<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
3146+<span class="apii">[-0, +0, <em>-</em>]</span>
30933147 <pre>int lua_isuserdata (lua_State *L, int index);</pre>
30943148
30953149 <p>
@@ -3100,7 +3154,8 @@ Returns 1 if the value at the given acceptable index is a userdata · 4 unmodified lines
31003154
31013155
31023156
3103−<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3>
3157+<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3><p>
3158+<span class="apii">[-0, +0, <em>e</em>]</span>
31043159 <pre>int lua_lessthan (lua_State *L, int index1, int index2);</pre>
31053160
31063161 <p>
@@ -3115,7 +3170,8 @@ Also returns&nbsp;0 if any of the indices is non valid. · 8 unmodified lines
31153170
31163171
31173172
3118−<hr><h3><a name="lua_load"><code>lua_load</code></a></h3>
3173+<hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
3174+<span class="apii">[-0, +1, <em>-</em>]</span>
31193175 <pre>int lua_load (lua_State *L,
31203176 lua_Reader reader,
31213177 void *data,
@@ -3165,7 +3221,8 @@ which is used for error messages and in debug information (see <a href="#3.8">&s · 43 unmodified lines
31653221
31663222
31673223
3168−<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3>
3224+<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
3225+<span class="apii">[-0, +0, <em>-</em>]</span>
31693226 <pre>lua_State *lua_newstate (lua_Alloc f, void *ud);</pre>
31703227
31713228 <p>
@@ -3181,7 +3238,8 @@ simply passes to the allocator in every call. · 9 unmodified lines
31813238
31823239
31833240
3184−<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3>
3241+<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
3242+<span class="apii">[-0, +1, <em>m</em>]</span>
31853243 <pre>void lua_newtable (lua_State *L);</pre>
31863244
31873245 <p>
@@ -3192,7 +3250,8 @@ It is equivalent to <code>lua_createtable(L, 0, 0)</code>. · 4 unmodified lines
31923250
31933251
31943252
3195−<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3>
3253+<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
3254+<span class="apii">[-0, +1, <em>m</em>]</span>
31963255 <pre>lua_State *lua_newthread (lua_State *L);</pre>
31973256
31983257 <p>
@@ -3212,7 +3271,8 @@ like any Lua object. · 13 unmodified lines
32123271
32133272
32143273
3215−<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3>
3274+<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
3275+<span class="apii">[-0, +1, <em>m</em>]</span>
32163276 <pre>void *lua_newuserdata (lua_State *L, size_t size);</pre>
32173277
32183278 <p>
@@ -3240,7 +3300,8 @@ Lua frees its corresponding memory. · 21 unmodified lines
32403300
32413301
32423302
3243−<hr><h3><a name="lua_next"><code>lua_next</code></a></h3>
3303+<hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
3304+<span class="apii">[-1, +(2|0), <em>e</em>]</span>
32443305 <pre>int lua_next (lua_State *L, int index);</pre>
32453306
32463307 <p>
@@ -3295,7 +3356,8 @@ Lua to operate with another type for numbers (e.g., float or long). · 48 unmodified lines
32953356
32963357
32973358
3298−<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3>
3359+<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3><p>
3360+<span class="apii">[-0, +0, <em>-</em>]</span>
32993361 <pre>size_t lua_objlen (lua_State *L, int index);</pre>
33003362
33013363 <p>
@@ -3310,7 +3372,8 @@ for other values, it is&nbsp;0. · 8 unmodified lines
33103372
33113373
33123374
3313−<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3>
3375+<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
3376+<span class="apii">[-(nargs + 1), +(nresults|1), <em>-</em>]</span>
33143377 <pre>int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);</pre>
33153378
33163379 <p>
@@ -3375,7 +3438,8 @@ error while running the error handler function. · 58 unmodified lines
33753438
33763439
33773440
3378−<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3>
3441+<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
3442+<span class="apii">[-n, +0, <em>-</em>]</span>
33793443 <pre>void lua_pop (lua_State *L, int n);</pre>
33803444
33813445 <p>
@@ -3385,7 +3449,8 @@ Pops <code>n</code> elements from the stack. · 3 unmodified lines
33853449
33863450
33873451
3388−<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3>
3452+<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
3453+<span class="apii">[-0, +1, <em>-</em>]</span>
33893454 <pre>void lua_pushboolean (lua_State *L, int b);</pre>
33903455
33913456 <p>
@@ -3395,7 +3460,8 @@ Pushes a boolean value with value <code>b</code> onto the stack. · 3 unmodified lines
33953460
33963461
33973462
3398−<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3>
3463+<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
3464+<span class="apii">[-n, +1, <em>m</em>]</span>
33993465 <pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
34003466
34013467 <p>
@@ -3420,7 +3486,8 @@ associated with the function. · 18 unmodified lines
34203486
34213487
34223488
3423−<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3>
3489+<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
3490+<span class="apii">[-0, +1, <em>m</em>]</span>
34243491 <pre>void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
34253492
34263493 <p>
@@ -3446,7 +3513,8 @@ and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code>< · 19 unmodified lines
34463513
34473514
34483515
3449−<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3>
3516+<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
3517+<span class="apii">[-0, +1, <em>m</em>]</span>
34503518 <pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
34513519
34523520 <p>
@@ -3480,7 +3548,8 @@ The conversion specifiers can only be · 27 unmodified lines
34803548
34813549
34823550
3483−<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3>
3551+<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
3552+<span class="apii">[-0, +1, <em>-</em>]</span>
34843553 <pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
34853554
34863555 <p>
@@ -3490,7 +3559,8 @@ Pushes a number with value <code>n</code> onto the stack. · 3 unmodified lines
34903559
34913560
34923561
3493−<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3>
3562+<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
3563+<span class="apii">[-0, +1, <em>-</em>]</span>
34943564 <pre>void lua_pushlightuserdata (lua_State *L, void *p);</pre>
34953565
34963566 <p>
@@ -3510,7 +3580,8 @@ light userdata with the same C&nbsp;address. · 13 unmodified lines
35103580
35113581
35123582
3513−<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3>
3583+<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
3584+<span class="apii">[-0, +1, <em>m</em>]</span>
35143585 <pre>void lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
35153586
35163587 <p>
@@ -3525,7 +3596,8 @@ The string can contain embedded zeros. · 8 unmodified lines
35253596
35263597
35273598
3528−<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3>
3599+<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
3600+<span class="apii">[-0, +1, <em>-</em>]</span>
35293601 <pre>void lua_pushnil (lua_State *L);</pre>
35303602
35313603 <p>
@@ -3535,7 +3607,8 @@ Pushes a nil value onto the stack. · 3 unmodified lines
35353607
35363608
35373609
3538−<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3>
3610+<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
3611+<span class="apii">[-0, +1, <em>-</em>]</span>
35393612 <pre>void lua_pushnumber (lua_State *L, lua_Number n);</pre>
35403613
35413614 <p>
@@ -3545,7 +3618,8 @@ Pushes a number with value <code>n</code> onto the stack. · 3 unmodified lines
35453618
35463619
35473620
3548−<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3>
3621+<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
3622+<span class="apii">[-0, +1, <em>m</em>]</span>
35493623 <pre>void lua_pushstring (lua_State *L, const char *s);</pre>
35503624
35513625 <p>
@@ -3561,7 +3635,8 @@ it is assumed to end at the first zero. · 9 unmodified lines
35613635
35623636
35633637
3564−<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3>
3638+<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
3639+<span class="apii">[-0, +1, <em>-</em>]</span>
35653640 <pre>int lua_pushthread (lua_State *L);</pre>
35663641
35673642 <p>
@@ -3572,7 +3647,8 @@ Returns 1 if this thread is the main thread of its state. · 4 unmodified lines
35723647
35733648
35743649
3575−<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3>
3650+<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
3651+<span class="apii">[-0, +1, <em>-</em>]</span>
35763652 <pre>void lua_pushvalue (lua_State *L, int index);</pre>
35773653
35783654 <p>
@@ -3583,7 +3659,8 @@ onto the stack. · 4 unmodified lines
35833659
35843660
35853661
3586−<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3>
3662+<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
3663+<span class="apii">[-0, +1, <em>m</em>]</span>
35873664 <pre>const char *lua_pushvfstring (lua_State *L,
35883665 const char *fmt,
35893666 va_list argp);</pre>
@@ -3596,7 +3673,8 @@ instead of a variable number of arguments. · 6 unmodified lines
35963673
35973674
35983675
3599−<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3>
3676+<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
3677+<span class="apii">[-0, +0, <em>-</em>]</span>
36003678 <pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
36013679
36023680 <p>
@@ -3610,7 +3688,8 @@ Also returns&nbsp;0 if any of the indices are non valid. · 7 unmodified lines
36103688
36113689
36123690
3613−<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3>
3691+<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
3692+<span class="apii">[-1, +1, <em>-</em>]</span>
36143693 <pre>void lua_rawget (lua_State *L, int index);</pre>
36153694
36163695 <p>
@@ -3621,12 +3700,13 @@ Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw · 4 unmodified lines
36213700
36223701
36233702
3624−<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3>
3703+<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
3704+<span class="apii">[-0, +1, <em>-</em>]</span>
36253705 <pre>void lua_rawgeti (lua_State *L, int index, int n);</pre>
36263706
36273707 <p>
36283708 Pushes onto the stack the value <code>t[n]</code>,
3629−where <code>t</code> is the value at the given valid index <code>index</code>.
3709+where <code>t</code> is the value at the given valid index.
36303710 The access is raw;
36313711 that is, it does not invoke metamethods.
36323712
@@ -3634,7 +3714,8 @@ that is, it does not invoke metamethods. · 1 unmodified line
36343714
36353715
36363716
3637−<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3>
3717+<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
3718+<span class="apii">[-2, +0, <em>m</em>]</span>
36383719 <pre>void lua_rawset (lua_State *L, int index);</pre>
36393720
36403721 <p>
@@ -3645,13 +3726,14 @@ Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw · 4 unmodified lines
36453726
36463727
36473728
3648−<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3>
3729+<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
3730+<span class="apii">[-1, +0, <em>m</em>]</span>
36493731 <pre>void lua_rawseti (lua_State *L, int index, int n);</pre>
36503732
36513733 <p>
36523734 Does the equivalent of <code>t[n] = v</code>,
3653−where <code>t</code> is the value at the given valid index <code>index</code>
3654−and <code>v</code> is the value at the top of the stack,
3735+where <code>t</code> is the value at the given valid index
3736+and <code>v</code> is the value at the top of the stack.
36553737
36563738
36573739 <p>
@@ -3684,7 +3766,8 @@ The reader function may return pieces of any size greater than zero. · 26 unmodified lines
36843766
36853767
36863768
3687−<hr><h3><a name="lua_register"><code>lua_register</code></a></h3>
3769+<hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
3770+<span class="apii">[-0, +0, <em>m</em>]</span>
36883771 <pre>void lua_register (lua_State *L,
36893772 const char *name,
36903773 lua_CFunction f);</pre>
@@ -3701,7 +3784,8 @@ It is defined as a macro: · 10 unmodified lines
37013784
37023785
37033786
3704−<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3>
3787+<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
3788+<span class="apii">[-1, +0, <em>-</em>]</span>
37053789 <pre>void lua_remove (lua_State *L, int index);</pre>
37063790
37073791 <p>
@@ -3714,7 +3798,8 @@ because a pseudo-index is not an actual stack position. · 6 unmodified lines
37143798
37153799
37163800
3717−<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3>
3801+<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
3802+<span class="apii">[-1, +0, <em>-</em>]</span>
37183803 <pre>void lua_replace (lua_State *L, int index);</pre>
37193804
37203805 <p>
@@ -3726,7 +3811,8 @@ without shifting any element · 5 unmodified lines
37263811
37273812
37283813
3729−<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3>
3814+<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
3815+<span class="apii">[-?, +?, <em>-</em>]</span>
37303816 <pre>int lua_resume (lua_State *L, int narg);</pre>
37313817
37323818 <p>
@@ -3759,7 +3845,8 @@ and then call <a href="#lua_resume"><code>lua_resume</code></a>. · 26 unmodified lines
37593845
37603846
37613847
3762−<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3>
3848+<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
3849+<span class="apii">[-0, +0, <em>-</em>]</span>
37633850 <pre>void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
37643851
37653852 <p>
@@ -3770,7 +3857,8 @@ with user data <code>ud</code>. · 4 unmodified lines
37703857
37713858
37723859
3773−<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3>
3860+<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3><p>
3861+<span class="apii">[-1, +0, <em>-</em>]</span>
37743862 <pre>int lua_setfenv (lua_State *L, int index);</pre>
37753863
37763864 <p>
@@ -3785,13 +3873,14 @@ Otherwise it returns 1. · 8 unmodified lines
37853873
37863874
37873875
3788−<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3>
3876+<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
3877+<span class="apii">[-1, +0, <em>e</em>]</span>
37893878 <pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
37903879
37913880 <p>
37923881 Does the equivalent to <code>t[k] = v</code>,
3793−where <code>t</code> is the value at the given valid index <code>index</code>
3794−and <code>v</code> is the value at the top of the stack,
3882+where <code>t</code> is the value at the given valid index
3883+and <code>v</code> is the value at the top of the stack.
37953884
37963885
37973886 <p>
@@ -3803,7 +3892,8 @@ for the "newindex" event (see <a href="#2.8">&sect;2.8</a>). · 5 unmodified lines
38033892
38043893
38053894
3806−<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3>
3895+<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
3896+<span class="apii">[-1, +0, <em>e</em>]</span>
38073897 <pre>void lua_setglobal (lua_State *L, const char *name);</pre>
38083898
38093899 <p>
@@ -3818,7 +3908,8 @@ It is defined as a macro: · 8 unmodified lines
38183908
38193909
38203910
3821−<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3>
3911+<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
3912+<span class="apii">[-1, +0, <em>-</em>]</span>
38223913 <pre>int lua_setmetatable (lua_State *L, int index);</pre>
38233914
38243915 <p>
@@ -3830,12 +3921,13 @@ acceptable index. · 5 unmodified lines
38303921
38313922
38323923
3833−<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3>
3924+<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
3925+<span class="apii">[-2, +0, <em>e</em>]</span>
38343926 <pre>void lua_settable (lua_State *L, int index);</pre>
38353927
38363928 <p>
38373929 Does the equivalent to <code>t[k] = v</code>,
3838−where <code>t</code> is the value at the given valid index <code>index</code>,
3930+where <code>t</code> is the value at the given valid index,
38393931 <code>v</code> is the value at the top of the stack,
38403932 and <code>k</code> is the value just below the top.
38413933
@@ -3849,7 +3941,8 @@ for the "newindex" event (see <a href="#2.8">&sect;2.8</a>). · 7 unmodified lines
38493941
38503942
38513943
3852−<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3>
3944+<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
3945+<span class="apii">[-?, +?, <em>-</em>]</span>
38533946 <pre>void lua_settop (lua_State *L, int index);</pre>
38543947
38553948 <p>
@@ -3882,7 +3975,8 @@ which creates a Lua state from scratch. · 26 unmodified lines
38823975
38833976
38843977
3885−<hr><h3><a name="lua_status"><code>lua_status</code></a></h3>
3978+<hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
3979+<span class="apii">[-0, +0, <em>-</em>]</span>
38863980 <pre>int lua_status (lua_State *L);</pre>
38873981
38883982 <p>
@@ -3898,7 +3992,8 @@ or <a name="pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the thread is suspended · 9 unmodified lines
38983992
38993993
39003994
3901−<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3>
3995+<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
3996+<span class="apii">[-0, +0, <em>-</em>]</span>
39023997 <pre>int lua_toboolean (lua_State *L, int index);</pre>
39033998
39043999 <p>
@@ -3916,7 +4011,8 @@ use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's · 11 unmodified lines
39164011
39174012
39184013
3919−<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3>
4014+<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
4015+<span class="apii">[-0, +0, <em>-</em>]</span>
39204016 <pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
39214017
39224018 <p>
@@ -3928,8 +4024,9 @@ otherwise, returns <code>NULL</code>. · 5 unmodified lines
39284024
39294025
39304026
3931−<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3>
3932−<pre>lua_Integer lua_tointeger (lua_State *L, int idx);</pre>
4027+<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
4028+<span class="apii">[-0, +0, <em>-</em>]</span>
4029+<pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
39334030
39344031 <p>
39354032 Converts the Lua value at the given acceptable index
@@ -3947,7 +4044,8 @@ it is truncated in some non-specified way. · 11 unmodified lines
39474044
39484045
39494046
3950−<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3>
4047+<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
4048+<span class="apii">[-0, +0, <em>m</em>]</span>
39514049 <pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
39524050
39534051 <p>
@@ -3977,7 +4075,8 @@ will be valid after the corresponding value is removed from the stack. · 23 unmodified lines
39774075
39784076
39794077
3980−<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3>
4078+<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
4079+<span class="apii">[-0, +0, <em>-</em>]</span>
39814080 <pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
39824081
39834082 <p>
@@ -3991,7 +4090,8 @@ otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns&nbsp;0. · 7 unmodified lines
39914090
39924091
39934092
3994−<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3>
4093+<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
4094+<span class="apii">[-0, +0, <em>-</em>]</span>
39954095 <pre>const void *lua_topointer (lua_State *L, int index);</pre>
39964096
39974097 <p>
@@ -4010,7 +4110,8 @@ Typically this function is used only for debug information. · 12 unmodified lines
40104110
40114111
40124112
4013−<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3>
4113+<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
4114+<span class="apii">[-0, +0, <em>m</em>]</span>
40144115 <pre>const char *lua_tostring (lua_State *L, int index);</pre>
40154116
40164117 <p>
@@ -4020,7 +4121,8 @@ Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code · 3 unmodified lines
40204121
40214122
40224123
4023−<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3>
4124+<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
4125+<span class="apii">[-0, +0, <em>-</em>]</span>
40244126 <pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
40254127
40264128 <p>
@@ -4033,7 +4135,8 @@ otherwise, the function returns <code>NULL</code>. · 6 unmodified lines
40334135
40344136
40354137
4036−<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3>
4138+<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
4139+<span class="apii">[-0, +0, <em>-</em>]</span>
40374140 <pre>void *lua_touserdata (lua_State *L, int index);</pre>
40384141
40394142 <p>
@@ -4047,7 +4150,8 @@ Otherwise, returns <code>NULL</code>. · 7 unmodified lines
40474150
40484151
40494152
4050−<hr><h3><a name="lua_type"><code>lua_type</code></a></h3>
4153+<hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
4154+<span class="apii">[-0, +0, <em>-</em>]</span>
40514155 <pre>int lua_type (lua_State *L, int index);</pre>
40524156
40534157 <p>
@@ -4071,7 +4175,8 @@ and · 17 unmodified lines
40714175
40724176
40734177
4074−<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3>
4178+<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
4179+<span class="apii">[-0, +0, <em>-</em>]</span>
40754180 <pre>const char *lua_typename (lua_State *L, int tp);</pre>
40764181
40774182 <p>
@@ -4089,7 +4194,7 @@ which must be one the values returned by <a href="#lua_type"><code>lua_type</cod · 11 unmodified lines
40894194 void* ud);</pre>
40904195
40914196 <p>
4092−The writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
4197+The type of the writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
40934198 Every time it produces another piece of chunk,
40944199 <a href="#lua_dump"><code>lua_dump</code></a> calls the writer,
40954200 passing along the buffer to be written (<code>p</code>),
@@ -4107,7 +4212,8 @@ calling the writer again. · 11 unmodified lines
41074212
41084213
41094214
4110−<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3>
4215+<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
4216+<span class="apii">[-?, +?, <em>-</em>]</span>
41114217 <pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
41124218
41134219 <p>
@@ -4122,7 +4228,8 @@ and pushes them onto the stack <code>to</code>. · 8 unmodified lines
41224228
41234229
41244230
4125−<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3>
4231+<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
4232+<span class="apii">[-?, +?, <em>-</em>]</span>
41264233 <pre>int lua_yield (lua_State *L, int nresults);</pre>
41274234
41284235 <p>
@@ -4254,7 +4361,8 @@ the number of upvalues of the function. · 125 unmodified lines
42544361
42554362
42564363
4257−<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3>
4364+<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
4365+<span class="apii">[-0, +0, <em>-</em>]</span>
42584366 <pre>lua_Hook lua_gethook (lua_State *L);</pre>
42594367
42604368 <p>
@@ -4264,7 +4372,8 @@ Returns the current hook function. · 3 unmodified lines
42644372
42654373
42664374
4267−<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3>
4375+<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
4376+<span class="apii">[-0, +0, <em>-</em>]</span>
42684377 <pre>int lua_gethookcount (lua_State *L);</pre>
42694378
42704379 <p>
@@ -4274,7 +4383,8 @@ Returns the current hook count. · 3 unmodified lines
42744383
42754384
42764385
4277−<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3>
4386+<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
4387+<span class="apii">[-0, +0, <em>-</em>]</span>
42784388 <pre>int lua_gethookmask (lua_State *L);</pre>
42794389
42804390 <p>
@@ -4284,7 +4394,8 @@ Returns the current hook mask. · 3 unmodified lines
42844394
42854395
42864396
4287−<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3>
4397+<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
4398+<span class="apii">[-(0|1), +(0|1|2), <em>-</em>]</span>
42884399 <pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
42894400
42904401 <p>
@@ -4357,7 +4468,8 @@ This function returns 0 on error · 66 unmodified lines
43574468
43584469
43594470
4360−<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3>
4471+<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
4472+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
43614473 <pre>const char *lua_getlocal (lua_State *L, lua_Debug *ar, int n);</pre>
43624474
43634475 <p>
@@ -4387,7 +4499,8 @@ the number of active local variables. · 23 unmodified lines
43874499
43884500
43894501
4390−<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3>
4502+<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
4503+<span class="apii">[-0, +0, <em>-</em>]</span>
43914504 <pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
43924505
43934506 <p>
@@ -4408,7 +4521,8 @@ it returns 0. · 14 unmodified lines
44084521
44094522
44104523
4411−<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3>
4524+<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
4525+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
44124526 <pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
44134527
44144528 <p>
@@ -4468,7 +4582,8 @@ this execution occurs without any calls to hooks. · 53 unmodified lines
44684582
44694583
44704584
4471−<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3>
4585+<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
4586+<span class="apii">[-0, +0, <em>-</em>]</span>
44724587 <pre>int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
44734588
44744589 <p>
@@ -4519,7 +4634,8 @@ A hook is disabled by setting <code>mask</code> to zero. · 44 unmodified lines
45194634
45204635
45214636
4522−<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3>
4637+<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
4638+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
45234639 <pre>const char *lua_setlocal (lua_State *L, lua_Debug *ar, int n);</pre>
45244640
45254641 <p>
@@ -4540,7 +4656,8 @@ the number of active local variables. · 14 unmodified lines
45404656
45414657
45424658
4543−<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3>
4659+<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
4660+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
45444661 <pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
45454662
45464663 <p>
@@ -4590,7 +4707,7 @@ and so they provide nothing that cannot be done with this API. · 43 unmodified lines
45904707 Several functions in the auxiliary library are used to
45914708 check C&nbsp;function arguments.
45924709 Their names are always <code>luaL_check*</code> or <code>luaL_opt*</code>.
4593−All of these functions raise an error if the check is not satisfied.
4710+All of these functions throw an error if the check is not satisfied.
45944711 Because the error message is formatted for arguments
45954712 (e.g., "<code>bad argument #1</code>"),
45964713 you should not use these functions for other stack values.
@@ -4605,7 +4722,8 @@ in alphabetical order. · 8 unmodified lines
46054722
46064723
46074724
4608−<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3>
4725+<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
4726+<span class="apii">[-0, +0, <em>m</em>]</span>
46094727 <pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
46104728
46114729 <p>
@@ -4616,7 +4734,8 @@ Adds the character <code>c</code> to the buffer <code>B</code> · 4 unmodified lines
46164734
46174735
46184736
4619−<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3>
4737+<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
4738+<span class="apii">[-0, +0, <em>m</em>]</span>
46204739 <pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
46214740
46224741 <p>
@@ -4629,7 +4748,8 @@ The string may contain embedded zeros. · 6 unmodified lines
46294748
46304749
46314750
4632−<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3>
4751+<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
4752+<span class="apii">[-0, +0, <em>m</em>]</span>
46334753 <pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
46344754
46354755 <p>
@@ -4641,7 +4761,8 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>). · 5 unmodified lines
46414761
46424762
46434763
4644−<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3>
4764+<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
4765+<span class="apii">[-0, +0, <em>m</em>]</span>
46454766 <pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
46464767
46474768 <p>
@@ -4654,7 +4775,8 @@ The string may not contain embedded zeros. · 6 unmodified lines
46544775
46554776
46564777
4657−<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3>
4778+<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
4779+<span class="apii">[-1, +0, <em>m</em>]</span>
46584780 <pre>void luaL_addvalue (luaL_Buffer *B);</pre>
46594781
46604782 <p>
@@ -4673,7 +4795,8 @@ which is the value to be added to the buffer. · 12 unmodified lines
46734795
46744796
46754797
4676−<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3>
4798+<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
4799+<span class="apii">[-0, +0, <em>v</em>]</span>
46774800 <pre>void luaL_argcheck (lua_State *L,
46784801 int cond,
46794802 int narg,
@@ -4691,7 +4814,8 @@ where <code>func</code> is retrieved from the call stack: · 11 unmodified lines
46914814
46924815
46934816
4694−<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3>
4817+<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
4818+<span class="apii">[-0, +0, <em>v</em>]</span>
46954819 <pre>int luaL_argerror (lua_State *L, int narg, const char *extramsg);</pre>
46964820
46974821 <p>
@@ -4760,7 +4884,8 @@ plus the final string on its top. · 62 unmodified lines
47604884
47614885
47624886
4763−<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3>
4887+<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
4888+<span class="apii">[-0, +0, <em>-</em>]</span>
47644889 <pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
47654890
47664891 <p>
@@ -4773,7 +4898,8 @@ the buffer must be declared as a variable · 6 unmodified lines
47734898
47744899
47754900
4776−<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3>
4901+<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
4902+<span class="apii">[-0, +(0|1), <em>e</em>]</span>
47774903 <pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
47784904
47794905 <p>
@@ -4793,7 +4919,8 @@ this function returns 0 (without pushing any value on the stack). · 13 unmodified lines
47934919
47944920
47954921
4796−<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3>
4922+<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
4923+<span class="apii">[-0, +0, <em>v</em>]</span>
47974924 <pre>void luaL_checkany (lua_State *L, int narg);</pre>
47984925
47994926 <p>
@@ -4804,7 +4931,8 @@ of any type (including <b>nil</b>) at position <code>narg</code>. · 4 unmodified lines
48044931
48054932
48064933
4807−<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3>
4934+<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3><p>
4935+<span class="apii">[-0, +0, <em>v</em>]</span>
48084936 <pre>int luaL_checkint (lua_State *L, int narg);</pre>
48094937
48104938 <p>
@@ -4815,7 +4943,8 @@ and returns this number cast to an <code>int</code>. · 4 unmodified lines
48154943
48164944
48174945
4818−<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3>
4946+<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
4947+<span class="apii">[-0, +0, <em>v</em>]</span>
48194948 <pre>lua_Integer luaL_checkinteger (lua_State *L, int narg);</pre>
48204949
48214950 <p>
@@ -4826,7 +4955,8 @@ and returns this number cast to a <a href="#lua_Integer"><code>lua_Integer</code · 4 unmodified lines
48264955
48274956
48284957
4829−<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3>
4958+<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3><p>
4959+<span class="apii">[-0, +0, <em>v</em>]</span>
48304960 <pre>long luaL_checklong (lua_State *L, int narg);</pre>
48314961
48324962 <p>
@@ -4837,7 +4967,8 @@ and returns this number cast to a <code>long</code>. · 4 unmodified lines
48374967
48384968
48394969
4840−<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3>
4970+<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
4971+<span class="apii">[-0, +0, <em>v</em>]</span>
48414972 <pre>const char *luaL_checklstring (lua_State *L, int narg, size_t *l);</pre>
48424973
48434974 <p>
@@ -4847,10 +4978,16 @@ if <code>l</code> is not <code>NULL</code> fills <code>*l</code> · 3 unmodified lines
48474978 with the string's length.
48484979
48494980
4981+<p>
4982+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
4983+so all conversions and caveats of that function apply here.
48504984
48514985
48524986
4853−<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3>
4987+
4988+
4989+<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
4990+<span class="apii">[-0, +0, <em>v</em>]</span>
48544991 <pre>lua_Number luaL_checknumber (lua_State *L, int narg);</pre>
48554992
48564993 <p>
@@ -4861,7 +4998,8 @@ and returns this number. · 4 unmodified lines
48614998
48624999
48635000
4864−<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3>
5001+<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
5002+<span class="apii">[-0, +0, <em>v</em>]</span>
48655003 <pre>int luaL_checkoption (lua_State *L,
48665004 int narg,
48675005 const char *def,
@@ -4891,7 +5029,8 @@ to use strings instead of numbers to select options.) · 23 unmodified lines
48915029
48925030
48935031
4894−<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3>
5032+<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
5033+<span class="apii">[-0, +0, <em>v</em>]</span>
48955034 <pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
48965035
48975036 <p>
@@ -4903,7 +5042,8 @@ raising an error if the stack cannot grow to that size. · 5 unmodified lines
49035042
49045043
49055044
4906−<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3>
5045+<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
5046+<span class="apii">[-0, +0, <em>v</em>]</span>
49075047 <pre>const char *luaL_checkstring (lua_State *L, int narg);</pre>
49085048
49095049 <p>
@@ -4911,20 +5051,28 @@ Checks whether the function argument <code>narg</code> is a string · 1 unmodified line
49115051 and returns this string.
49125052
49135053
5054+<p>
5055+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
5056+so all conversions and caveats of that function apply here.
5057+
5058+
49145059
49155060
49165061
4917−<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3>
5062+<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
5063+<span class="apii">[-0, +0, <em>v</em>]</span>
49185064 <pre>void luaL_checktype (lua_State *L, int narg, int t);</pre>
49195065
49205066 <p>
49215067 Checks whether the function argument <code>narg</code> has type <code>t</code>.
5068+See <a href="#lua_type"><code>lua_type</code></a> for the encoding of types for <code>t</code>.
49225069
49235070
49245071
49255072
49265073
4927−<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3>
5074+<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
5075+<span class="apii">[-0, +0, <em>v</em>]</span>
49285076 <pre>void *luaL_checkudata (lua_State *L, int narg, const char *tname);</pre>
49295077
49305078 <p>
@@ -4935,7 +5083,8 @@ of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newm · 4 unmodified lines
49355083
49365084
49375085
4938−<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3>
5086+<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
5087+<span class="apii">[-0, +?, <em>m</em>]</span>
49395088 <pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
49405089
49415090 <p>
@@ -4952,7 +5101,8 @@ or 1 in case of errors. · 10 unmodified lines
49525101
49535102
49545103
4955−<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3>
5104+<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
5105+<span class="apii">[-0, +?, <em>m</em>]</span>
49565106 <pre>int luaL_dostring (lua_State *L, const char *str);</pre>
49575107
49585108 <p>
@@ -4969,7 +5119,8 @@ or 1 in case of errors. · 10 unmodified lines
49695119
49705120
49715121
4972−<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3>
5122+<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
5123+<span class="apii">[-0, +0, <em>v</em>]</span>
49735124 <pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
49745125
49755126 <p>
@@ -4991,7 +5142,8 @@ as <code>return luaL_error(<em>args</em>)</code>. · 15 unmodified lines
49915142
49925143
49935144
4994−<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3>
5145+<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
5146+<span class="apii">[-0, +(0|1), <em>m</em>]</span>
49955147 <pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
49965148
49975149 <p>
@@ -5005,7 +5157,8 @@ returns 0 and pushes nothing. · 7 unmodified lines
50055157
50065158
50075159
5008−<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3>
5160+<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
5161+<span class="apii">[-0, +1, <em>-</em>]</span>
50095162 <pre>void luaL_getmetatable (lua_State *L, const char *tname);</pre>
50105163
50115164 <p>
@@ -5016,7 +5169,8 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code> · 4 unmodified lines
50165169
50175170
50185171
5019−<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3>
5172+<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
5173+<span class="apii">[-0, +1, <em>m</em>]</span>
50205174 <pre>const char *luaL_gsub (lua_State *L,
50215175 const char *s,
50225176 const char *p,
@@ -5032,7 +5186,8 @@ Pushes the resulting string on the stack and returns it. · 9 unmodified lines
50325186
50335187
50345188
5035−<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3>
5189+<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
5190+<span class="apii">[-0, +1, <em>m</em>]</span>
50365191 <pre>int luaL_loadbuffer (lua_State *L,
50375192 const char *buff,
50385193 size_t sz,
@@ -5053,7 +5208,8 @@ used for debug information and error messages. · 14 unmodified lines
50535208
50545209
50555210
5056−<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3>
5211+<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
5212+<span class="apii">[-0, +1, <em>m</em>]</span>
50575213 <pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
50585214
50595215 <p>
@@ -5079,7 +5235,8 @@ it does not run it. · 19 unmodified lines
50795235
50805236
50815237
5082−<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3>
5238+<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
5239+<span class="apii">[-0, +1, <em>m</em>]</span>
50835240 <pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
50845241
50855242 <p>
@@ -5100,7 +5257,8 @@ it does not run it. · 14 unmodified lines
51005257
51015258
51025259
5103−<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3>
5260+<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
5261+<span class="apii">[-0, +1, <em>m</em>]</span>
51045262 <pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
51055263
51065264 <p>
@@ -5120,7 +5278,8 @@ with <code>tname</code> in the registry. · 13 unmodified lines
51205278
51215279
51225280
5123−<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3>
5281+<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
5282+<span class="apii">[-0, +0, <em>-</em>]</span>
51245283 <pre>lua_State *luaL_newstate (void);</pre>
51255284
51265285 <p>
@@ -5140,7 +5299,8 @@ or <code>NULL</code> if there is a memory allocation error. · 13 unmodified lines
51405299
51415300
51425301
5143−<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3>
5302+<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
5303+<span class="apii">[-0, +0, <em>m</em>]</span>
51445304 <pre>void luaL_openlibs (lua_State *L);</pre>
51455305
51465306 <p>
@@ -5150,7 +5310,8 @@ Opens all standard Lua libraries into the given state. · 3 unmodified lines
51505310
51515311
51525312
5153−<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3>
5313+<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3><p>
5314+<span class="apii">[-0, +0, <em>v</em>]</span>
51545315 <pre>int luaL_optint (lua_State *L, int narg, int d);</pre>
51555316
51565317 <p>
@@ -5164,7 +5325,8 @@ Otherwise, raises an error. · 7 unmodified lines
51645325
51655326
51665327
5167−<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3>
5328+<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
5329+<span class="apii">[-0, +0, <em>v</em>]</span>
51685330 <pre>lua_Integer luaL_optinteger (lua_State *L,
51695331 int narg,
51705332 lua_Integer d);</pre>
@@ -5180,7 +5342,8 @@ Otherwise, raises an error. · 9 unmodified lines
51805342
51815343
51825344
5183−<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3>
5345+<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3><p>
5346+<span class="apii">[-0, +0, <em>v</em>]</span>
51845347 <pre>long luaL_optlong (lua_State *L, int narg, long d);</pre>
51855348
51865349 <p>
@@ -5194,7 +5357,8 @@ Otherwise, raises an error. · 7 unmodified lines
51945357
51955358
51965359
5197−<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3>
5360+<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
5361+<span class="apii">[-0, +0, <em>v</em>]</span>
51985362 <pre>const char *luaL_optlstring (lua_State *L,
51995363 int narg,
52005364 const char *d,
@@ -5216,7 +5380,8 @@ fills the position <code>*l</code> with the results's length. · 15 unmodified lines
52165380
52175381
52185382
5219−<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3>
5383+<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
5384+<span class="apii">[-0, +0, <em>v</em>]</span>
52205385 <pre>lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);</pre>
52215386
52225387 <p>
@@ -5230,7 +5395,8 @@ Otherwise, raises an error. · 7 unmodified lines
52305395
52315396
52325397
5233−<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3>
5398+<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
5399+<span class="apii">[-0, +0, <em>v</em>]</span>
52345400 <pre>const char *luaL_optstring (lua_State *L,
52355401 int narg,
52365402 const char *d);</pre>
@@ -5246,7 +5412,8 @@ Otherwise, raises an error. · 9 unmodified lines
52465412
52475413
52485414
5249−<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3>
5415+<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
5416+<span class="apii">[-0, +0, <em>-</em>]</span>
52505417 <pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
52515418
52525419 <p>
@@ -5261,7 +5428,8 @@ it to the buffer. · 8 unmodified lines
52615428
52625429
52635430
5264−<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3>
5431+<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
5432+<span class="apii">[-?, +1, <em>m</em>]</span>
52655433 <pre>void luaL_pushresult (luaL_Buffer *B);</pre>
52665434
52675435 <p>
@@ -5272,7 +5440,8 @@ the top of the stack. · 4 unmodified lines
52725440
52735441
52745442
5275−<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3>
5443+<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
5444+<span class="apii">[-1, +0, <em>m</em>]</span>
52765445 <pre>int luaL_ref (lua_State *L, int t);</pre>
52775446
52785447 <p>
@@ -5318,7 +5487,8 @@ in which both <code>name</code> and <code>func</code> are <code>NULL</code>. · 39 unmodified lines
53185487
53195488
53205489
5321−<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3>
5490+<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3><p>
5491+<span class="apii">[-(0|1), +1, <em>m</em>]</span>
53225492 <pre>void luaL_register (lua_State *L,
53235493 const char *libname,
53245494 const luaL_Reg *l);</pre>
@@ -5352,17 +5522,19 @@ on the top of the stack. · 27 unmodified lines
53525522
53535523
53545524
5355−<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3>
5356−<pre>const char *luaL_typename (lua_State *L, int idx);</pre>
5525+<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
5526+<span class="apii">[-0, +0, <em>-</em>]</span>
5527+<pre>const char *luaL_typename (lua_State *L, int index);</pre>
53575528
53585529 <p>
5359−Returns the name of the type of the value at index <code>idx</code>.
5530+Returns the name of the type of the value at the given index.
53605531
53615532
53625533
53635534
53645535
5365−<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3>
5536+<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3><p>
5537+<span class="apii">[-0, +0, <em>v</em>]</span>
53665538 <pre>int luaL_typerror (lua_State *L, int narg, const char *tname);</pre>
53675539
53685540 <p>
@@ -5379,7 +5551,8 @@ and <code><em>rt</em></code> is the type name of the actual argument. · 10 unmodified lines
53795551
53805552
53815553
5382−<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3>
5554+<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
5555+<span class="apii">[-0, +0, <em>-</em>]</span>
53835556 <pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
53845557
53855558 <p>
@@ -5398,7 +5571,8 @@ If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a · 12 unmodified lines
53985571
53995572
54005573
5401−<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3>
5574+<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
5575+<span class="apii">[-0, +1, <em>m</em>]</span>
54025576 <pre>void luaL_where (lua_State *L, int lvl);</pre>
54035577
54045578 <p>
@@ -5433,7 +5607,7 @@ Some of these functions provide essential services to the language · 28 unmodified lines
54335607 others provide access to "outside" services (e.g., I/O);
54345608 and others could be implemented in Lua itself,
54355609 but are quite useful or have critical performance requirements that
5436−deserve an implementation in C (e.g., <code>sort</code>).
5610+deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
54375611
54385612
54395613 <p>
@@ -5476,7 +5650,8 @@ it can open them individually by calling · 36 unmodified lines
54765650 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
54775651 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
54785652 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
5479−<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O and the Operating System libraries),
5653+<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
5654+<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
54805655 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
54815656 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>
54825657 and should not be called directly:
@@ -5665,6 +5840,8 @@ The environment of the returned function is the global environment. · 182 unmodified lines
56655840 <p>
56665841 <code>chunkname</code> is used as the chunk name for error messages
56675842 and debug information.
5843+When absent,
5844+it defaults to "<code>=(load)</code>".
56685845
56695846
56705847
@@ -5698,6 +5875,11 @@ To load and run a given string, use the idiom · 27 unmodified lines
56985875 assert(loadstring(s))()
56995876 </pre>
57005877
5878+<p>
5879+When absent,
5880+<code>chunkname</code> defaults to the given string.
5881+
5882+
57015883
57025884
57035885 <p>
@@ -6160,7 +6342,15 @@ Otherwise, it tries to find a <em>loader</em> for the module. · 456 unmodified lines
61606342
61616343 <p>
61626344 To find a loader,
6163−first <code>require</code> queries <code>package.preload[modname]</code>.
6345+<code>require</code> is guided by the <a href="#pdf-package.loaders"><code>package.loaders</code></a> array.
6346+By changing this array,
6347+we can change how <code>require</code> looks for a module.
6348+The following explanation is based on the default configuration
6349+for <a href="#pdf-package.loaders"><code>package.loaders</code></a>.
6350+
6351+
6352+<p>
6353+First <code>require</code> queries <code>package.preload[modname]</code>.
61646354 If it has a value,
61656355 this value (which should be a function) is the loader.
61666356 Otherwise <code>require</code> searches for a Lua loader using the
@@ -6168,38 +6358,7 @@ path stored in <a href="#pdf-package.path"><code>package.path</code></a>. · 1 unmodified line
61686358 If that also fails, it searches for a C&nbsp;loader using the
61696359 path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
61706360 If that also fails,
6171−it tries an <em>all-in-one</em> loader (see below).
6172−
6173−
6174−<p>
6175−When loading a C&nbsp;library,
6176−<code>require</code> first uses a dynamic link facility to link the
6177−application with the library.
6178−Then it tries to find a C&nbsp;function inside this library to
6179−be used as the loader.
6180−The name of this C&nbsp;function is the string "<code>luaopen_</code>"
6181−concatenated with a copy of the module name where each dot
6182−is replaced by an underscore.
6183−Moreover, if the module name has a hyphen,
6184−its prefix up to (and including) the first hyphen is removed.
6185−For instance, if the module name is <code>a.v1-b.c</code>,
6186−the function name will be <code>luaopen_b_c</code>.
6187−
6188−
6189−<p>
6190−If <code>require</code> finds neither a Lua library nor a
6191−C&nbsp;library for a module,
6192−it calls the <em>all-in-one loader</em>.
6193−This loader searches the C&nbsp;path for a library for
6194−the root name of the given module.
6195−For instance, when requiring <code>a.b.c</code>,
6196−it will search for a C&nbsp;library for <code>a</code>.
6197−If found, it looks into it for an open function for
6198−the submodule;
6199−in our example, that would be <code>luaopen_a_b_c</code>.
6200−With this facility, a package can pack several C&nbsp;submodules
6201−into one single library,
6202−with each submodule keeping its original open function.
6361+it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.loaders"><code>package.loaders</code></a>).
62036362
62046363
62056364 <p>
@@ -6234,7 +6393,7 @@ The path used by <a href="#pdf-require"><code>require</code></a> to search for a · 28 unmodified lines
62346393 Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
62356394 it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
62366395 using the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
6237−(plus another default path defined in <code>luaconf.h</code>).
6396+or a default path defined in <code>luaconf.h</code>.
62386397
62396398
62406399
@@ -6254,6 +6413,94 @@ When you require a module <code>modname</code> and · 13 unmodified lines
62546413
62556414
62566415
6416+<p>
6417+<hr><h3><a name="pdf-package.loaders"><code>package.loaders</code></a></h3>
6418+
6419+
6420+<p>
6421+A table used by <a href="#pdf-require"><code>require</code></a> to control how to load modules.
6422+
6423+
6424+<p>
6425+Each entry in this table is a <em>searcher function</em>.
6426+When looking for a module,
6427+<a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
6428+with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
6429+sole parameter.
6430+The function may return another function (the module <em>loader</em>)
6431+or a string explaining why it did not find that module
6432+(or <b>nil</b> if it has nothing to say).
6433+Lua initializes this table with four functions.
6434+
6435+
6436+<p>
6437+The first searcher simply looks for a loader in the
6438+<a href="#pdf-package.preload"><code>package.preload</code></a> table.
6439+
6440+
6441+<p>
6442+The second searcher looks for a loader as a Lua library,
6443+using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
6444+A path is a sequence of <em>templates</em> separated by semicolons.
6445+For each template,
6446+the searcher will change each interrogation
6447+mark in the template by <code>filename</code>,
6448+which is the module name with each dot replaced by a
6449+"directory separator" (such as "<code>/</code>" in Unix);
6450+then it will try to open the resulting file name.
6451+So, for instance, if the Lua path is the string
6452+
6453+<pre>
6454+ "./?.lua;./?.lc;/usr/local/?/init.lua"
6455+</pre><p>
6456+the search for a Lua file for module <code>foo</code>
6457+will try to open the files
6458+<code>./foo.lua</code>, <code>./foo.lc</code>, and
6459+<code>/usr/local/foo/init.lua</code>, in that order.
6460+
6461+
6462+<p>
6463+The third searcher looks for a loader as a C&nbsp;library,
6464+using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
6465+For instance,
6466+if the C&nbsp;path is the string
6467+
6468+<pre>
6469+ "./?.so;./?.dll;/usr/local/?/init.so"
6470+</pre><p>
6471+the searcher for module <code>foo</code>
6472+will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>,
6473+and <code>/usr/local/foo/init.so</code>, in that order.
6474+Once it finds a C&nbsp;library,
6475+this searcher first uses a dynamic link facility to link the
6476+application with the library.
6477+Then it tries to find a C&nbsp;function inside the library to
6478+be used as the loader.
6479+The name of this C&nbsp;function is the string "<code>luaopen_</code>"
6480+concatenated with a copy of the module name where each dot
6481+is replaced by an underscore.
6482+Moreover, if the module name has a hyphen,
6483+its prefix up to (and including) the first hyphen is removed.
6484+For instance, if the module name is <code>a.v1-b.c</code>,
6485+the function name will be <code>luaopen_b_c</code>.
6486+
6487+
6488+<p>
6489+The fourth searcher tries an <em>all-in-one loader</em>.
6490+It searches the C&nbsp;path for a library for
6491+the root name of the given module.
6492+For instance, when requiring <code>a.b.c</code>,
6493+it will search for a C&nbsp;library for <code>a</code>.
6494+If found, it looks into it for an open function for
6495+the submodule;
6496+in our example, that would be <code>luaopen_a_b_c</code>.
6497+With this facility, a package can pack several C&nbsp;submodules
6498+into one single library,
6499+with each submodule keeping its original open function.
6500+
6501+
6502+
6503+
62576504 <p>
62586505 <hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
62596506
@@ -6303,24 +6550,6 @@ Any "<code>;;</code>" in the value of the environment variable · 43 unmodified lines
63036550 is replaced by the default path.
63046551
63056552
6306−<p>
6307−A path is a sequence of <em>templates</em> separated by semicolons.
6308−For each template, <a href="#pdf-require"><code>require</code></a> will change each interrogation
6309−mark in the template by <code>filename</code>,
6310−which is <code>modname</code> with each dot replaced by a
6311−"directory separator" (such as "<code>/</code>" in Unix);
6312−then it will try to load the resulting file name.
6313−So, for instance, if the Lua path is
6314−
6315−<pre>
6316− "./?.lua;./?.lc;/usr/local/?/init.lua"
6317−</pre><p>
6318−the search for a Lua loader for module <code>foo</code>
6319−will try to load the files
6320−<code>./foo.lua</code>, <code>./foo.lc</code>, and
6321−<code>/usr/local/foo/init.lua</code>, in that order.
6322−
6323−
63246553
63256554
63266555 <p>
@@ -6524,11 +6753,12 @@ work as an anchor, as this would prevent the iteration. · 197 unmodified lines
65246753 <p>
65256754 <hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
65266755 Returns a copy of <code>s</code>
6527−in which all occurrences of the <code>pattern</code> have been
6756+in which all (or the first <code>n</code>, if given)
6757+occurrences of the <code>pattern</code> have been
65286758 replaced by a replacement string specified by <code>repl</code>,
65296759 which may be a string, a table, or a function.
65306760 <code>gsub</code> also returns, as its second value,
6531−the total number of substitutions made.
6761+the total number of matches that occurred.
65326762
65336763
65346764 <p>
@@ -6565,13 +6795,6 @@ then there is no replacement · 30 unmodified lines
65656795 (that is, the original match is kept in the string).
65666796
65676797
6568−<p>
6569−The optional last parameter <code>n</code> limits
6570−the maximum number of substitutions to occur.
6571−For instance, when <code>n</code> is 1 only the first occurrence of
6572−<code>pattern</code> is replaced.
6573−
6574−
65756798 <p>
65766799 Here are some examples:
65776800
@@ -7005,14 +7228,14 @@ Returns the arc tangent of <code>x</code> (in radians). · 427 unmodified lines
70057228
70067229
70077230 <p>
7008−<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (x, y)</code></a></h3>
7231+<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (y, x)</code></a></h3>
70097232
70107233
70117234 <p>
7012−Returns the arc tangent of <code>x/y</code> (in radians),
7235+Returns the arc tangent of <code>y/x</code> (in radians),
70137236 but uses the signs of both parameters to find the
70147237 quadrant of the result.
7015−(It also handles correctly the case of <code>y</code> being zero.)
7238+(It also handles correctly the case of <code>x</code> being zero.)
70167239
70177240
70187241
@@ -7062,7 +7285,7 @@ Returns the angle <code>x</code> (given in radians) in degrees. · 43 unmodified lines
70627285
70637286
70647287 <p>
7065−Returns the the value <em>e<sup>x</sup></em>.
7288+Returns the value <em>e<sup>x</sup></em>.
70667289
70677290
70687291
@@ -7215,13 +7438,13 @@ pseudo-random generator function <code>rand</code> provided by ANSI&nbsp;C. · 146 unmodified lines
72157438
72167439 <p>
72177440 When called without arguments,
7218−returns a pseudo-random real number
7441+returns a uniform pseudo-random real number
72197442 in the range <em>[0,1)</em>.
7220−When called with a number <code>m</code>,
7443+When called with an integer number <code>m</code>,
72217444 <code>math.random</code> returns
7222−a pseudo-random integer in the range <em>[1, m]</em>.
7223−When called with two numbers <code>m</code> and <code>n</code>,
7224−<code>math.random</code> returns a pseudo-random
7445+a uniform pseudo-random integer in the range <em>[1, m]</em>.
7446+When called with two integer numbers <code>m</code> and <code>n</code>,
7447+<code>math.random</code> returns a uniform pseudo-random
72257448 integer in the range <em>[m, n]</em>.
72267449
72277450
@@ -7316,6 +7539,7 @@ and then all operations are supplied as methods of the file descriptor. · 88 unmodified lines
73167539 The table <code>io</code> also provides
73177540 three predefined file descriptors with their usual meanings from C:
73187541 <a name="pdf-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a>, and <a name="pdf-io.stderr"><code>io.stderr</code></a>.
7542+The I/O library never closes these files.
73197543
73207544
73217545 <p>
@@ -7829,9 +8053,9 @@ or <b>nil</b> if the request cannot be honored. · 507 unmodified lines
78298053
78308054 <p>
78318055 If <code>locale</code> is the empty string,
7832−the current locate is set to an implementation-defined native locale.
7833−If <code>locate</code> is the string "<code>C</code>",
7834−the current locate is set to the standard C locale.
8056+the current locale is set to an implementation-defined native locale.
8057+If <code>locale</code> is the string "<code>C</code>",
8058+the current locale is set to the standard C locale.
78358059
78368060
78378061 <p>
@@ -7892,7 +8116,7 @@ and similar tasks, such as profiling. · 54 unmodified lines
78928116 Please resist the temptation to use them as a
78938117 usual programming tool:
78948118 they can be very slow.
7895−Moreover, several of its functions
8119+Moreover, several of these functions
78968120 violate some assumptions about Lua code
78978121 (e.g., that variables local to a function
78988122 cannot be accessed from outside or
@@ -7983,7 +8207,8 @@ valid lines. · 84 unmodified lines
79838207
79848208 <p>
79858209 For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
7986−a name of the current function, if a reasonable name can be found,
8210+a table with a name for the current function,
8211+if a reasonable name can be found,
79878212 and the expression <code>debug.getinfo(print)</code>
79888213 returns a table with all available information
79898214 about the <a href="#pdf-print"><code>print</code></a> function.
@@ -8070,9 +8295,9 @@ The string mask may have the following characters, · 80 unmodified lines
80708295 with the given meaning:
80718296
80728297 <ul>
8073−<li><b><code>"c"</code>:</b> The hook is called every time Lua calls a function;</li>
8074−<li><b><code>"r"</code>:</b> The hook is called every time Lua returns from a function;</li>
8075−<li><b><code>"l"</code>:</b> The hook is called every time Lua enters a new line of code.</li>
8298+<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li>
8299+<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li>
8300+<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li>
80768301 </ul><p>
80778302 With a <code>count</code> different from zero,
80788303 the hook is called after every <code>count</code> instructions.
@@ -8257,17 +8482,19 @@ then its value is used as the prompt. · 178 unmodified lines
82578482 Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a string,
82588483 its value is used as the secondary prompt
82598484 (issued during incomplete statements).
8260−Therefore, both prompts can be changed directly on the command line.
8261−For instance,
8485+Therefore, both prompts can be changed directly on the command line
8486+or in any Lua programs by assigning to <code>_PROMPT</code>.
8487+See the next example:
82628488
82638489 <pre>
82648490 $ lua -e"_PROMPT='myprompt&gt; '" -i
82658491 </pre><p>
8266−(the outer pair of quotes is for the shell,
8267−the inner pair is for Lua),
8268−or in any Lua programs by assigning to <code>_PROMPT</code>.
8269−Note the use of <code>-i</code> to enter interactive mode; otherwise,
8270−the program would just end silently right after the assignment to <code>_PROMPT</code>.
8492+(The outer pair of quotes is for the shell,
8493+the inner pair is for Lua.)
8494+Note the use of <code>-i</code> to enter interactive mode;
8495+otherwise,
8496+the program would just end silently
8497+right after the assignment to <code>_PROMPT</code>.
82718498
82728499
82738500 <p>
@@ -8297,7 +8524,7 @@ is a more portable solution.) · 23 unmodified lines
82978524 <h1>7 - <a name="7">Incompatibilities with the Previous Version</a></h1>
82988525
82998526 <p>
8300−Here we list the incompatibilities that you may found when moving a program
8527+Here we list the incompatibilities that you may find when moving a program
83018528 from Lua&nbsp;5.0 to Lua&nbsp;5.1.
83028529 You can avoid most of the incompatibilities compiling Lua with
83038530 appropriate options (see file <code>luaconf.h</code>).
@@ -8446,29 +8673,29 @@ Here is the complete syntax of Lua in extended BNF. · 142 unmodified lines
84468673
84478674 block ::= chunk
84488675
8449− stat ::= varlist1 `<b>=</b>&acute; explist1 |
8676+ stat ::= varlist `<b>=</b>&acute; explist |
84508677 functioncall |
84518678 <b>do</b> block <b>end</b> |
84528679 <b>while</b> exp <b>do</b> block <b>end</b> |
84538680 <b>repeat</b> block <b>until</b> exp |
84548681 <b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b> |
84558682 <b>for</b> Name `<b>=</b>&acute; exp `<b>,</b>&acute; exp [`<b>,</b>&acute; exp] <b>do</b> block <b>end</b> |
8456− <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b> |
8683+ <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b> |
84578684 <b>function</b> funcname funcbody |
84588685 <b>local</b> <b>function</b> Name funcbody |
8459− <b>local</b> namelist [`<b>=</b>&acute; explist1]
8686+ <b>local</b> namelist [`<b>=</b>&acute; explist]
84608687
8461− laststat ::= <b>return</b> [explist1] | <b>break</b>
8688+ laststat ::= <b>return</b> [explist] | <b>break</b>
84628689
84638690 funcname ::= Name {`<b>.</b>&acute; Name} [`<b>:</b>&acute; Name]
84648691
8465− varlist1 ::= var {`<b>,</b>&acute; var}
8692+ varlist ::= var {`<b>,</b>&acute; var}
84668693
84678694 var ::= Name | prefixexp `<b>[</b>&acute; exp `<b>]</b>&acute; | prefixexp `<b>.</b>&acute; Name
84688695
84698696 namelist ::= Name {`<b>,</b>&acute; Name}
84708697
8471− explist1 ::= {exp `<b>,</b>&acute;} exp
8698+ explist ::= {exp `<b>,</b>&acute;} exp
84728699
84738700 exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | String | `<b>...</b>&acute; | function |
84748701 prefixexp | tableconstructor | exp binop exp | unop exp
@@ -8477,13 +8704,13 @@ Here is the complete syntax of Lua in extended BNF. · 2 unmodified lines
84778704
84788705 functioncall ::= prefixexp args | prefixexp `<b>:</b>&acute; Name args
84798706
8480− args ::= `<b>(</b>&acute; [explist1] `<b>)</b>&acute; | tableconstructor | String
8707+ args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute; | tableconstructor | String
84818708
84828709 function ::= <b>function</b> funcbody
84838710
8484− funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
8711+ funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
84858712
8486− parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
8713+ parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
84878714
84888715 tableconstructor ::= `<b>{</b>&acute; [fieldlist] `<b>}</b>&acute;
84898716
@@ -8508,13 +8735,14 @@ Here is the complete syntax of Lua in extended BNF. · 18 unmodified lines
85088735
85098736
85108737
8738+
85118739 <HR>
85128740 <SMALL>
85138741 Last update:
8514−Mon Mar 26 12:59:26 BRT 2007
8742+Thu Jan 17 15:06:18 BRST 2008
85158743 </SMALL>
85168744 <!--
8517−Last change: ready for Lua 5.1.2
8745+Last change: revised for Lua 5.1.3
85188746 -->
85198747
85208748 </body></html>
doc/readme.html+2−2
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 Documentation
1313 </H1>
1414
15−This is the documentation included in the source distribution of Lua 5.1.2.
15+This is the documentation included in the source distribution of Lua 5.1.3.
1616
1717 <UL>
1818 <LI><A HREF="contents.html">Reference manual</A>
@@ -33,7 +33,7 @@ especially the · 14 unmodified lines
3333 <HR>
3434 <SMALL>
3535 Last update:
36−Fri Mar 23 14:19:36 BRT 2007
36+Wed Dec 19 13:59:14 BRST 2007
3737 </SMALL>
3838
3939 </BODY>
etc/lua.pc+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 # grep '^V=' ../Makefile
66 V= 5.1
77 # grep '^R=' ../Makefile
8−R= 5.1.2
8+R= 5.1.3
99
1010 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
1111 prefix= /usr/local
src/Makefile+1−2
@@ -148,8 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ · 147 unmodified lines
148148 lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
149149 lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
150150 ltm.h lzio.h lmem.h ldo.h
151−loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
152− lualib.h
151+loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
153152 lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
154153 ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
155154 lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
src/lapi.c+7−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $
2+** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
33 ** Lua API
44 ** See Copyright Notice in lua.h
55 */
@@ -123,6 +123,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { · 117 unmodified lines
123123 }
124124
125125
126+LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
127+ to->nCcalls = from->nCcalls;
128+}
129+
130+
126131 LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
127132 lua_CFunction old;
128133 lua_lock(L);
@@ -749,7 +754,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) { · 620 unmodified lines
749754 res = 0;
750755 break;
751756 }
752− luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
757+ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
753758 L->top--;
754759 lua_unlock(L);
755760 return res;
src/lapi.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
2+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Auxiliary functions from Lua API
44 ** See Copyright Notice in lua.h
55 */
src/lauxlib.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $
2+** $Id: lauxlib.c,v 1.159.1.2 2008/01/17 14:04:41 roberto Exp $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -244,7 +244,7 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname, · 238 unmodified lines
244244 if (libname) {
245245 int size = libsize(l);
246246 /* check whether lib already exists */
247− luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
247+ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
248248 lua_getfield(L, -1, libname); /* get _LOADED[libname] */
249249 if (!lua_istable(L, -1)) { /* not found? */
250250 lua_pop(L, 1); /* remove previous result */
src/lauxlib.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 roberto Exp $
2+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
src/lbaselib.c+41−32
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $
2+** $Id: lbaselib.c,v 1.191.1.3 2008/01/03 15:20:39 roberto Exp $
33 ** Basic library
44 ** See Copyright Notice in lua.h
55 */
@@ -477,15 +477,52 @@ static const luaL_Reg base_funcs[] = { · 471 unmodified lines
477477 ** =======================================================
478478 */
479479
480+#define CO_RUN 0 /* running */
481+#define CO_SUS 1 /* suspended */
482+#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
483+#define CO_DEAD 3
484+
485+static const char *const statnames[] =
486+ {"running", "suspended", "normal", "dead"};
487+
488+static int costatus (lua_State *L, lua_State *co) {
489+ if (L == co) return CO_RUN;
490+ switch (lua_status(co)) {
491+ case LUA_YIELD:
492+ return CO_SUS;
493+ case 0: {
494+ lua_Debug ar;
495+ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
496+ return CO_NOR; /* it is running */
497+ else if (lua_gettop(co) == 0)
498+ return CO_DEAD;
499+ else
500+ return CO_SUS; /* initial state */
501+ }
502+ default: /* some error occured */
503+ return CO_DEAD;
504+ }
505+}
506+
507+
508+static int luaB_costatus (lua_State *L) {
509+ lua_State *co = lua_tothread(L, 1);
510+ luaL_argcheck(L, co, 1, "coroutine expected");
511+ lua_pushstring(L, statnames[costatus(L, co)]);
512+ return 1;
513+}
514+
515+
480516 static int auxresume (lua_State *L, lua_State *co, int narg) {
481− int status;
517+ int status = costatus(L, co);
482518 if (!lua_checkstack(co, narg))
483519 luaL_error(L, "too many arguments to resume");
484− if (lua_status(co) == 0 && lua_gettop(co) == 0) {
485− lua_pushliteral(L, "cannot resume dead coroutine");
520+ if (status != CO_SUS) {
521+ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
486522 return -1; /* error flag */
487523 }
488524 lua_xmove(L, co, narg);
525+ lua_setlevel(L, co);
489526 status = lua_resume(co, narg);
490527 if (status == 0 || status == LUA_YIELD) {
491528 int nres = lua_gettop(co);
@@ -556,34 +593,6 @@ static int luaB_yield (lua_State *L) { · 64 unmodified lines
556593 }
557594
558595
559−static int luaB_costatus (lua_State *L) {
560− lua_State *co = lua_tothread(L, 1);
561− luaL_argcheck(L, co, 1, "coroutine expected");
562− if (L == co) lua_pushliteral(L, "running");
563− else {
564− switch (lua_status(co)) {
565− case LUA_YIELD:
566− lua_pushliteral(L, "suspended");
567− break;
568− case 0: {
569− lua_Debug ar;
570− if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
571− lua_pushliteral(L, "normal"); /* it is running */
572− else if (lua_gettop(co) == 0)
573− lua_pushliteral(L, "dead");
574− else
575− lua_pushliteral(L, "suspended"); /* initial state */
576− break;
577− }
578− default: /* some error occured */
579− lua_pushliteral(L, "dead");
580− break;
581− }
582− }
583− return 1;
584−}
585−
586−
587596 static int luaB_corunning (lua_State *L) {
588597 if (lua_pushthread(L))
589598 return 0; /* main thread is not a coroutine */
src/lcode.c+2−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $
2+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
33 ** Code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -699,7 +699,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { · 693 unmodified lines
699699 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
700700 switch (op) {
701701 case OPR_MINUS: {
702− if (e->k == VK)
702+ if (!isnumeral(e))
703703 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
704704 codearith(fs, OP_UNM, e, &e2);
705705 break;
src/lcode.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $
2+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
src/ldblib.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $
2+** $Id: ldblib.c,v 1.104.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Interface from Lua to its debug API
44 ** See Copyright Notice in lua.h
55 */
src/ldebug.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $
2+** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $
33 ** Debug Interface
44 ** See Copyright Notice in lua.h
55 */
@@ -563,8 +563,8 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { · 557 unmodified lines
563563
564564
565565 void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
566− if (ttisstring(p1)) p1 = p2;
567− lua_assert(!ttisstring(p1));
566+ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
567+ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
568568 luaG_typeerror(L, p1, "concatenate");
569569 }
570570
src/ldebug.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $
2+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Auxiliary functions from Debug Interface module
44 ** See Copyright Notice in lua.h
55 */
src/ldo.c+12−10
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $
2+** $Id: ldo.c,v 2.38.1.2 2008/01/03 15:20:39 roberto Exp $
33 ** Stack and Call structure of Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -83,7 +83,7 @@ static void resetstack (lua_State *L, int status) { · 77 unmodified lines
8383 L->base = L->ci->base;
8484 luaF_close(L, L->base); /* close eventual pending closures */
8585 luaD_seterrorobj(L, status, L->base);
86− L->nCcalls = 0;
86+ L->nCcalls = L->baseCcalls;
8787 L->allowhook = 1;
8888 restore_stack_limit(L);
8989 L->errfunc = 0;
@@ -417,22 +417,24 @@ static int resume_error (lua_State *L, const char *msg) { · 327 unmodified lines
417417 LUA_API int lua_resume (lua_State *L, int nargs) {
418418 int status;
419419 lua_lock(L);
420− if (L->status != LUA_YIELD) {
421− if (L->status != 0)
422− return resume_error(L, "cannot resume dead coroutine");
423− else if (L->ci != L->base_ci)
420+ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
424421 return resume_error(L, "cannot resume non-suspended coroutine");
425− }
422+ if (L->nCcalls >= LUAI_MAXCCALLS)
423+ return resume_error(L, "C stack overflow");
426424 luai_userstateresume(L, nargs);
427− lua_assert(L->errfunc == 0 && L->nCcalls == 0);
425+ lua_assert(L->errfunc == 0);
426+ L->baseCcalls = ++L->nCcalls;
428427 status = luaD_rawrunprotected(L, resume, L->top - nargs);
429428 if (status != 0) { /* error? */
430429 L->status = cast_byte(status); /* mark thread as `dead' */
431430 luaD_seterrorobj(L, status, L->top);
432431 L->ci->top = L->top;
433432 }
434− else
433+ else {
434+ lua_assert(L->nCcalls == L->baseCcalls);
435435 status = L->status;
436+ }
437+ --L->nCcalls;
436438 lua_unlock(L);
437439 return status;
438440 }
@@ -441,7 +443,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) { · 2 unmodified lines
441443 LUA_API int lua_yield (lua_State *L, int nresults) {
442444 luai_userstateyield(L, nresults);
443445 lua_lock(L);
444− if (L->nCcalls > 0)
446+ if (L->nCcalls > L->baseCcalls)
445447 luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
446448 L->base = L->top - nresults; /* protect stack slots below */
447449 L->status = LUA_YIELD;
src/ldo.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $
2+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Stack and Call structure of Lua
44 ** See Copyright Notice in lua.h
55 */
src/ldump.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $
2+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** save precompiled Lua chunks
44 ** See Copyright Notice in lua.h
55 */
src/lfunc.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $
2+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
33 ** Auxiliary functions to manipulate prototypes and closures
44 ** See Copyright Notice in lua.h
55 */
src/lfunc.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $
2+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Auxiliary functions to manipulate prototypes and closures
44 ** See Copyright Notice in lua.h
55 */
src/lgc.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
2+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
src/lgc.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $
2+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Garbage Collector
44 ** See Copyright Notice in lua.h
55 */
src/linit.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $
2+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Initialization of libraries for lua.c
44 ** See Copyright Notice in lua.h
55 */
src/liolib.c+7−5
@@ -1,5 +1,5 @@
11 /*
2−** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $
2+** $Id: liolib.c,v 2.73.1.2 2008/01/02 13:56:00 roberto Exp $
33 ** Standard I/O (and system) library
44 ** See Copyright Notice in lua.h
55 */
@@ -106,8 +106,11 @@ static int io_pclose (lua_State *L) { · 100 unmodified lines
106106
107107 static int io_fclose (lua_State *L) {
108108 FILE **p = topfile(L);
109− int ok = (fclose(*p) == 0);
110− *p = NULL;
109+ int ok = 0;
110+ if (*p != stdin && *p != stdout && *p != stderr) {
111+ ok = (fclose(*p) == 0);
112+ *p = NULL;
113+ }
111114 return pushresult(L, ok, NULL);
112115 }
113116
@@ -129,8 +132,7 @@ static int io_close (lua_State *L) { · 15 unmodified lines
129132
130133 static int io_gc (lua_State *L) {
131134 FILE *f = *topfile(L);
132− /* ignore closed files and standard files */
133− if (f != NULL && f != stdin && f != stdout && f != stderr)
135+ if (f != NULL) /* ignore closed files */
134136 aux_close(L);
135137 return 0;
136138 }
src/llex.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: llex.c,v 2.20 2006/03/09 18:14:31 roberto Exp $
2+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lexical Analyzer
44 ** See Copyright Notice in lua.h
55 */
src/llex.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: llex.h,v 1.58 2006/03/23 18:23:32 roberto Exp $
2+** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lexical Analyzer
44 ** See Copyright Notice in lua.h
55 */
src/llimits.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
2+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Limits, basic types, and some other `installation-dependent' definitions
44 ** See Copyright Notice in lua.h
55 */
src/lmathlib.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $
2+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Standard mathematical library
44 ** See Copyright Notice in lua.h
55 */
src/lmem.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $
2+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Interface to Memory Manager
44 ** See Copyright Notice in lua.h
55 */
src/lmem.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $
2+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Interface to Memory Manager
44 ** See Copyright Notice in lua.h
55 */
src/loadlib.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $
2+** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $
33 ** Dynamic library loader for Lua
44 ** See Copyright Notice in lua.h
55 **
src/lobject.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $
2+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Some generic functions over Lua objects
44 ** See Copyright Notice in lua.h
55 */
src/lobject.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
2+** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Type definitions for Lua objects
44 ** See Copyright Notice in lua.h
55 */
src/lopcodes.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $
2+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** See Copyright Notice in lua.h
44 */
55
src/lopcodes.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $
2+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Opcodes for Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
src/loslib.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $
2+** $Id: loslib.c,v 1.19.1.2 2007/12/28 14:58:43 roberto Exp $
33 ** Standard Operating System library
44 ** See Copyright Notice in lua.h
55 */
src/lparser.c+3−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $
2+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
33 ** Lua Parser
44 ** See Copyright Notice in lua.h
55 */
@@ -938,6 +938,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { · 932 unmodified lines
938938 primaryexp(ls, &nv.v);
939939 if (nv.v.k == VLOCAL)
940940 check_conflict(ls, lh, &nv.v);
941+ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
942+ "variables in assignment");
941943 assignment(ls, &nv, nvars+1);
942944 }
943945 else { /* assignment -> `=' explist1 */
src/lparser.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
2+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lua Parser
44 ** See Copyright Notice in lua.h
55 */
src/lstate.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $
2+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
33 ** Global State
44 ** See Copyright Notice in lua.h
55 */
@@ -93,7 +93,7 @@ static void preinit_state (lua_State *L, global_State *g) { · 87 unmodified lines
9393 resethookcount(L);
9494 L->openupval = NULL;
9595 L->size_ci = 0;
96− L->nCcalls = 0;
96+ L->nCcalls = L->baseCcalls = 0;
9797 L->status = 0;
9898 L->base_ci = L->ci = NULL;
9999 L->savedpc = NULL;
@@ -205,7 +205,7 @@ LUA_API void lua_close (lua_State *L) { · 105 unmodified lines
205205 do { /* repeat until no more errors */
206206 L->ci = L->base_ci;
207207 L->base = L->top = L->ci->base;
208− L->nCcalls = 0;
208+ L->nCcalls = L->baseCcalls = 0;
209209 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
210210 lua_assert(G(L)->tmudata == NULL);
211211 luai_userstateclose(L);
src/lstate.h+2−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
2+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
33 ** Global State
44 ** See Copyright Notice in lua.h
55 */
@@ -112,6 +112,7 @@ struct lua_State { · 106 unmodified lines
112112 int stacksize;
113113 int size_ci; /* size of array `base_ci' */
114114 unsigned short nCcalls; /* number of nested C calls */
115+ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
115116 lu_byte hookmask;
116117 lu_byte allowhook;
117118 int basehookcount;
src/lstring.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $
2+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** String table (keeps all strings handled by Lua)
44 ** See Copyright Notice in lua.h
55 */
src/lstring.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $
2+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** String table (keep all strings handled by Lua)
44 ** See Copyright Notice in lua.h
55 */
src/lstrlib.c+5−5
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $
2+** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
33 ** Standard library for string operations and pattern-matching
44 ** See Copyright Notice in lua.h
55 */
@@ -629,10 +629,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, · 623 unmodified lines
629629 lua_gettable(L, 3);
630630 break;
631631 }
632− default: {
633− luaL_argerror(L, 3, "string/function/table expected");
634− return;
635− }
636632 }
637633 if (!lua_toboolean(L, -1)) { /* nil or false? */
638634 lua_pop(L, 1);
@@ -648,11 +644,15 @@ static int str_gsub (lua_State *L) { · 9 unmodified lines
648644 size_t srcl;
649645 const char *src = luaL_checklstring(L, 1, &srcl);
650646 const char *p = luaL_checkstring(L, 2);
647+ int tr = lua_type(L, 3);
651648 int max_s = luaL_optint(L, 4, srcl+1);
652649 int anchor = (*p == '^') ? (p++, 1) : 0;
653650 int n = 0;
654651 MatchState ms;
655652 luaL_Buffer b;
653+ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
654+ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
655+ "string/function/table expected");
656656 luaL_buffinit(L, &b);
657657 ms.L = L;
658658 ms.src_init = src;
src/ltable.c+3−3
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
2+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
33 ** Lua tables (hash)
44 ** See Copyright Notice in lua.h
55 */
@@ -84,8 +84,8 @@ static const Node dummynode_ = { · 78 unmodified lines
8484 static Node *hashnum (const Table *t, lua_Number n) {
8585 unsigned int a[numints];
8686 int i;
87− n += 1; /* normalize number (avoid -0) */
88− lua_assert(sizeof(a) <= sizeof(n));
87+ if (luai_numeq(n, 0)) /* avoid problems with -0 */
88+ return gnode(t, 0);
8989 memcpy(a, &n, sizeof(a));
9090 for (i = 1; i < numints; i++) a[0] += a[i];
9191 return hashmod(t, a[0]);
src/ltable.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $
2+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lua tables (hash)
44 ** See Copyright Notice in lua.h
55 */
src/ltablib.c+3−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $
2+** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $
33 ** Library for Table Manipulation
44 ** See Copyright Notice in lua.h
55 */
@@ -118,7 +118,8 @@ static int tinsert (lua_State *L) { · 112 unmodified lines
118118 static int tremove (lua_State *L) {
119119 int e = aux_getn(L, 1);
120120 int pos = luaL_optint(L, 2, e);
121− if (e == 0) return 0; /* table is `empty' */
121+ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
122+ return 0; /* nothing to remove */
122123 luaL_setn(L, 1, e - 1); /* t.n = n-1 */
123124 lua_rawgeti(L, 1, pos); /* result = t[pos] */
124125 for ( ;pos<e; pos++) {
src/ltm.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $
2+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Tag methods
44 ** See Copyright Notice in lua.h
55 */
src/ltm.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $
2+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Tag methods
44 ** See Copyright Notice in lua.h
55 */
src/lua.c+4−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp $
2+** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $
33 ** Lua stand-alone interpreter
44 ** See Copyright Notice in lua.h
55 */
@@ -74,6 +74,8 @@ static int report (lua_State *L, int status) { · 68 unmodified lines
7474
7575
7676 static int traceback (lua_State *L) {
77+ if (!lua_isstring(L, 1)) /* 'message' not a string? */
78+ return 1; /* keep it intact */
7779 lua_getfield(L, LUA_GLOBALSINDEX, "debug");
7880 if (!lua_istable(L, -1)) {
7981 lua_pop(L, 1);
@@ -144,7 +146,7 @@ static int dostring (lua_State *L, const char *s, const char *name) { · 64 unmodified lines
144146 static int dolibrary (lua_State *L, const char *name) {
145147 lua_getglobal(L, "require");
146148 lua_pushstring(L, name);
147− return report(L, lua_pcall(L, 1, 0, 0));
149+ return report(L, docall(L, 1, 1));
148150 }
149151
150152
src/lua.h+7−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $
2+** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
33 ** Lua - An Extensible Extension Language
44 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
55 ** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@ · 11 unmodified lines
1717
1818
1919 #define LUA_VERSION "Lua 5.1"
20−#define LUA_RELEASE "Lua 5.1.2"
20+#define LUA_RELEASE "Lua 5.1.3"
2121 #define LUA_VERSION_NUM 501
22−#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio"
22+#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
2323 #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
2424
2525
@@ -294,6 +294,9 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); · 268 unmodified lines
294294 #define lua_Chunkwriter lua_Writer
295295
296296
297+/* hack */
298+LUA_API void lua_setlevel (lua_State *from, lua_State *to);
299+
297300
298301 /*
299302 ** {======================================================================
@@ -359,7 +362,7 @@ struct lua_Debug { · 59 unmodified lines
359362
360363
361364 /******************************************************************************
362−* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved.
365+* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
363366 *
364367 * Permission is hereby granted, free of charge, to any person obtaining
365368 * a copy of this software and associated documentation files (the
src/luaconf.h+3−2
@@ -1,5 +1,5 @@
11 /*
2−** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $
2+** $Id: luaconf.h,v 1.82.1.5 2008/01/17 14:04:20 roberto Exp $
33 ** Configuration file for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -442,7 +442,8 @@ · 436 unmodified lines
442442 ** functions. This limit is arbitrary; its only purpose is to stop C
443443 ** functions to consume unlimited stack space.
444444 */
445−#define LUAI_MAXCSTACK 2048
445+#define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
446+#define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
446447
447448
448449
src/lualib.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
2+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lua standard libraries
44 ** See Copyright Notice in lua.h
55 */
src/lundump.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
2+** $Id: lundump.c,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** load precompiled Lua chunks
44 ** See Copyright Notice in lua.h
55 */
src/lundump.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
2+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** load precompiled Lua chunks
44 ** See Copyright Notice in lua.h
55 */
src/lvm.c+4−6
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $
2+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
@@ -61,11 +61,9 @@ static void traceexec (lua_State *L, const Instruction *pc) { · 55 unmodified lines
6161 lu_byte mask = L->hookmask;
6262 const Instruction *oldpc = L->savedpc;
6363 L->savedpc = pc;
64− if (mask > LUA_MASKLINE) { /* instruction-hook set? */
65− if (L->hookcount == 0) {
66− resethookcount(L);
67− luaD_callhook(L, LUA_HOOKCOUNT, -1);
68− }
64+ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
65+ resethookcount(L);
66+ luaD_callhook(L, LUA_HOOKCOUNT, -1);
6967 }
7068 if (mask & LUA_MASKLINE) {
7169 Proto *p = ci_func(L->ci)->l.p;
src/lvm.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $
2+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Lua virtual machine
44 ** See Copyright Notice in lua.h
55 */
src/lzio.c+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $
2+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** a generic input stream interface
44 ** See Copyright Notice in lua.h
55 */
src/lzio.h+1−1
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
2+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
33 ** Buffered streams
44 ** See Copyright Notice in lua.h
55 */