git: 0ea45b9cd43c - Import lua 5.4.2
Kyle Evans
kevans at FreeBSD.org
Sat Dec 26 05:04:34 UTC 2020
The branch vendor/lua has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7
commit 0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-26 05:02:38 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2020-12-26 05:02:38 +0000
Import lua 5.4.2
---
Makefile | 30 +-
README | 2 +-
doc/contents.html | 81 +-
doc/lua.1 | 93 +-
doc/manual.html | 3260 ++++++++++++++++++++++++++++++++++-------------------
doc/readme.html | 115 +-
src/Makefile | 83 +-
src/lapi.c | 706 +++++++-----
src/lapi.h | 27 +-
src/lauxlib.c | 385 ++++---
src/lauxlib.h | 54 +-
src/lbaselib.c | 139 ++-
src/lbitlib.c | 233 ----
src/lcode.c | 1141 ++++++++++++++-----
src/lcode.h | 34 +-
src/lcorolib.c | 89 +-
src/lctype.c | 43 +-
src/lctype.h | 18 +-
src/ldblib.c | 94 +-
src/ldebug.c | 462 +++++---
src/ldebug.h | 21 +-
src/ldo.c | 559 ++++-----
src/ldo.h | 38 +-
src/ldump.c | 197 ++--
src/lfunc.c | 223 +++-
src/lfunc.h | 50 +-
src/lgc.c | 1387 ++++++++++++++++-------
src/lgc.h | 128 ++-
src/linit.c | 7 +-
src/liolib.c | 121 +-
src/ljumptab.h | 112 ++
src/llex.c | 74 +-
src/llex.h | 12 +-
src/llimits.h | 132 ++-
src/lmathlib.c | 433 ++++++-
src/lmem.c | 178 ++-
src/lmem.h | 72 +-
src/loadlib.c | 261 ++---
src/lobject.c | 340 +++---
src/lobject.h | 737 ++++++++----
src/lopcodes.c | 190 ++--
src/lopcodes.h | 401 ++++---
src/lopnames.h | 103 ++
src/loslib.c | 85 +-
src/lparser.c | 967 ++++++++++------
src/lparser.h | 80 +-
src/lprefix.h | 4 +-
src/lstate.c | 221 ++--
src/lstate.h | 202 +++-
src/lstring.c | 135 ++-
src/lstring.h | 22 +-
src/lstrlib.c | 502 ++++++---
src/ltable.c | 692 ++++++++----
src/ltable.h | 22 +-
src/ltablib.c | 52 +-
src/ltm.c | 173 ++-
src/ltm.h | 37 +-
src/lua.c | 439 ++++----
src/lua.h | 60 +-
src/luac.c | 470 ++++++--
src/luaconf.h | 253 ++---
src/lualib.h | 5 +-
src/lundump.c | 266 +++--
src/lundump.h | 8 +-
src/lutf8lib.c | 117 +-
src/lvm.c | 1759 +++++++++++++++++++----------
src/lvm.h | 91 +-
src/lzio.c | 2 +-
src/lzio.h | 2 +-
69 files changed, 12722 insertions(+), 6809 deletions(-)
diff --git a/Makefile b/Makefile
index a2820e04fe24..36447a0f61c7 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
-PLAT= none
+PLAT= guess
# Where to install. The installation starts in the src and doc directories,
# so take care if INSTALL_TOP is not an absolute path. See the local target.
@@ -36,7 +36,7 @@ RM= rm -f
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
# Convenience platforms targets.
-PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
+PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
@@ -45,17 +45,14 @@ TO_LIB= liblua.a
TO_MAN= lua.1 luac.1
# Lua version and release.
-V= 5.3
-R= $V.6
+V= 5.4
+R= $V.2
# Targets start here.
all: $(PLAT)
-$(PLATS) clean:
- cd src && $(MAKE) $@
-
-test: dummy
- src/lua -v
+$(PLATS) help test clean:
+ @cd src && $(MAKE) $@
install: dummy
cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
@@ -73,15 +70,10 @@ uninstall:
local:
$(MAKE) install INSTALL_TOP=../install
-none:
- @echo "Please do 'make PLATFORM' where PLATFORM is one of these:"
- @echo " $(PLATS)"
- @echo "See doc/readme.html for complete instructions."
-
-# make may get confused with test/ and install/
+# make may get confused with install/ if it does not support .PHONY.
dummy:
-# echo config parameters
+# Echo config parameters.
echo:
@cd src && $(MAKE) -s echo
@echo "PLAT= $(PLAT)"
@@ -101,14 +93,14 @@ echo:
@echo "INSTALL_EXEC= $(INSTALL_EXEC)"
@echo "INSTALL_DATA= $(INSTALL_DATA)"
-# echo pkg-config data
+# Echo pkg-config data.
pc:
@echo "version=$R"
@echo "prefix=$(INSTALL_TOP)"
@echo "libdir=$(INSTALL_LIB)"
@echo "includedir=$(INSTALL_INC)"
-# list targets that do not create files (but not all makes understand .PHONY)
-.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
+# Targets that do not create files (not all makes understand .PHONY).
+.PHONY: all $(PLATS) help test clean install uninstall local dummy echo pc
# (end of Makefile)
diff --git a/README b/README
index f8bdb6f41d00..bc8a9d737d26 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-This is Lua 5.3.6, released on 14 Sep 2020.
+This is Lua 5.4.2, released on 13 Nov 2020.
For installation instructions, license details, and
further information about Lua, see doc/readme.html.
diff --git a/doc/contents.html b/doc/contents.html
index 3a357b1ed653..8ea0616b25ce 100644
--- a/doc/contents.html
+++ b/doc/contents.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
-<TITLE>Lua 5.3 Reference Manual - contents</TITLE>
+<TITLE>Lua 5.4 Reference Manual - contents</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
<LINK REL="stylesheet" TYPE="text/css" HREF="index.css">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
@@ -11,7 +11,7 @@
<H1>
<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
-Lua 5.3 Reference Manual
+Lua 5.4 Reference Manual
</H1>
<P>
@@ -32,7 +32,7 @@ For a complete introduction to Lua programming, see the book
<P>
<SMALL>
-Copyright © 2015–2020 Lua.org, PUC-Rio.
+Copyright © 2020 Lua.org, PUC-Rio.
Freely available under the terms of the
<A HREF="http://www.lua.org/license.html">Lua license</A>.
</SMALL>
@@ -49,8 +49,10 @@ Freely available under the terms of the
<LI><A HREF="manual.html#2.4">2.4 – Metatables and Metamethods</A>
<LI><A HREF="manual.html#2.5">2.5 – Garbage Collection</A>
<UL>
-<LI><A HREF="manual.html#2.5.1">2.5.1 – Garbage-Collection Metamethods</A>
-<LI><A HREF="manual.html#2.5.2">2.5.2 – Weak Tables</A>
+<LI><A HREF="manual.html#2.5.1">2.5.1 – Incremental Garbage Collection</A>
+<LI><A HREF="manual.html#2.5.2">2.5.2 – Generational Garbage Collection</A>
+<LI><A HREF="manual.html#2.5.3">2.5.3 – Garbage-Collection Metamethods</A>
+<LI><A HREF="manual.html#2.5.4">2.5.4 – Weak Tables</A>
</UL>
<LI><A HREF="manual.html#2.6">2.6 – Coroutines</A>
</UL>
@@ -68,6 +70,7 @@ Freely available under the terms of the
<LI><A HREF="manual.html#3.3.5">3.3.5 – For Statement</A>
<LI><A HREF="manual.html#3.3.6">3.3.6 – Function Calls as Statements</A>
<LI><A HREF="manual.html#3.3.7">3.3.7 – Local Declarations</A>
+<LI><A HREF="manual.html#3.3.8">3.3.8 – To-be-closed Variables</A>
</UL>
<LI><A HREF="manual.html#3.4">3.4 – Expressions</A>
<UL>
@@ -89,14 +92,20 @@ Freely available under the terms of the
<LI><A HREF="manual.html#4">4 – The Application Program Interface</A>
<UL>
<LI><A HREF="manual.html#4.1">4.1 – The Stack</A>
-<LI><A HREF="manual.html#4.2">4.2 – Stack Size</A>
-<LI><A HREF="manual.html#4.3">4.3 – Valid and Acceptable Indices</A>
-<LI><A HREF="manual.html#4.4">4.4 – C Closures</A>
-<LI><A HREF="manual.html#4.5">4.5 – Registry</A>
-<LI><A HREF="manual.html#4.6">4.6 – Error Handling in C</A>
-<LI><A HREF="manual.html#4.7">4.7 – Handling Yields in C</A>
-<LI><A HREF="manual.html#4.8">4.8 – Functions and Types</A>
-<LI><A HREF="manual.html#4.9">4.9 – The Debug Interface</A>
+<UL>
+<LI><A HREF="manual.html#4.1.1">4.1.1 – Stack Size</A>
+<LI><A HREF="manual.html#4.1.2">4.1.2 – Valid and Acceptable Indices</A>
+<LI><A HREF="manual.html#4.1.3">4.1.3 – Pointers to strings</A>
+</UL>
+<LI><A HREF="manual.html#4.2">4.2 – C Closures</A>
+<LI><A HREF="manual.html#4.3">4.3 – Registry</A>
+<LI><A HREF="manual.html#4.4">4.4 – Error Handling in C</A>
+<UL>
+<LI><A HREF="manual.html#4.4.1">4.4.1 – Status Codes</A>
+</UL>
+<LI><A HREF="manual.html#4.5">4.5 – Handling Yields in C</A>
+<LI><A HREF="manual.html#4.6">4.6 – Functions and Types</A>
+<LI><A HREF="manual.html#4.7">4.7 – The Debug Interface</A>
</UL>
<P>
<LI><A HREF="manual.html#5">5 – The Auxiliary Library</A>
@@ -104,7 +113,7 @@ Freely available under the terms of the
<LI><A HREF="manual.html#5.1">5.1 – Functions and Types</A>
</UL>
<P>
-<LI><A HREF="manual.html#6">6 – Standard Libraries</A>
+<LI><A HREF="manual.html#6">6 – The Standard Libraries</A>
<UL>
<LI><A HREF="manual.html#6.1">6.1 – Basic Functions</A>
<LI><A HREF="manual.html#6.2">6.2 – Coroutine Manipulation</A>
@@ -126,9 +135,9 @@ Freely available under the terms of the
<P>
<LI><A HREF="manual.html#8">8 – Incompatibilities with the Previous Version</A>
<UL>
-<LI><A HREF="manual.html#8.1">8.1 – Changes in the Language</A>
-<LI><A HREF="manual.html#8.2">8.2 – Changes in the Libraries</A>
-<LI><A HREF="manual.html#8.3">8.3 – Changes in the API</A>
+<LI><A HREF="manual.html#8.1">8.1 – Incompatibilities in the Language</A>
+<LI><A HREF="manual.html#8.2">8.2 – Incompatibilities in the Libraries</A>
+<LI><A HREF="manual.html#8.3">8.3 – Incompatibilities in the API</A>
</UL>
<P>
<LI><A HREF="manual.html#9">9 – The Complete Syntax of Lua</A>
@@ -165,10 +174,12 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-tonumber">tonumber</A><BR>
<A HREF="manual.html#pdf-tostring">tostring</A><BR>
<A HREF="manual.html#pdf-type">type</A><BR>
+<A HREF="manual.html#pdf-warn">warn</A><BR>
<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
<P>
<A HREF="manual.html#6.2">coroutine</A><BR>
+<A HREF="manual.html#pdf-coroutine.close">coroutine.close</A><BR>
<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
<A HREF="manual.html#pdf-coroutine.isyieldable">coroutine.isyieldable</A><BR>
<A HREF="manual.html#pdf-coroutine.resume">coroutine.resume</A><BR>
@@ -326,10 +337,11 @@ Freely available under the terms of the
<A HREF="manual.html#2.4">__bor</A><BR>
<A HREF="manual.html#2.4">__bxor</A><BR>
<A HREF="manual.html#2.4">__call</A><BR>
+<A HREF="manual.html#3.3.8">__close</A><BR>
<A HREF="manual.html#2.4">__concat</A><BR>
<A HREF="manual.html#2.4">__div</A><BR>
<A HREF="manual.html#2.4">__eq</A><BR>
-<A HREF="manual.html#2.5.1">__gc</A><BR>
+<A HREF="manual.html#2.5.3">__gc</A><BR>
<A HREF="manual.html#2.4">__idiv</A><BR>
<A HREF="manual.html#2.4">__index</A><BR>
<A HREF="manual.html#2.4">__le</A><BR>
@@ -337,7 +349,7 @@ Freely available under the terms of the
<A HREF="manual.html#2.4">__lt</A><BR>
<A HREF="manual.html#pdf-getmetatable">__metatable</A><BR>
<A HREF="manual.html#2.4">__mod</A><BR>
-<A HREF="manual.html#2.5.2">__mode</A><BR>
+<A HREF="manual.html#2.5.4">__mode</A><BR>
<A HREF="manual.html#2.4">__mul</A><BR>
<A HREF="manual.html#luaL_newmetatable">__name</A><BR>
<A HREF="manual.html#2.4">__newindex</A><BR>
@@ -352,11 +364,11 @@ Freely available under the terms of the
<H3><A NAME="env">environment<BR>variables</A></H3>
<P>
<A HREF="manual.html#pdf-LUA_CPATH">LUA_CPATH</A><BR>
-<A HREF="manual.html#pdf-LUA_CPATH_5_3">LUA_CPATH_5_3</A><BR>
+<A HREF="manual.html#pdf-LUA_CPATH_5_4">LUA_CPATH_5_4</A><BR>
<A HREF="manual.html#pdf-LUA_INIT">LUA_INIT</A><BR>
-<A HREF="manual.html#pdf-LUA_INIT_5_3">LUA_INIT_5_3</A><BR>
+<A HREF="manual.html#pdf-LUA_INIT_5_4">LUA_INIT_5_4</A><BR>
<A HREF="manual.html#pdf-LUA_PATH">LUA_PATH</A><BR>
-<A HREF="manual.html#pdf-LUA_PATH_5_3">LUA_PATH_5_3</A><BR>
+<A HREF="manual.html#pdf-LUA_PATH_5_4">LUA_PATH_5_4</A><BR>
</TD>
<TD>
@@ -373,6 +385,7 @@ Freely available under the terms of the
<A HREF="manual.html#lua_Reader">lua_Reader</A><BR>
<A HREF="manual.html#lua_State">lua_State</A><BR>
<A HREF="manual.html#lua_Unsigned">lua_Unsigned</A><BR>
+<A HREF="manual.html#lua_WarnFunction">lua_WarnFunction</A><BR>
<A HREF="manual.html#lua_Writer">lua_Writer</A><BR>
<P>
@@ -399,13 +412,13 @@ Freely available under the terms of the
<A HREF="manual.html#lua_gethookmask">lua_gethookmask</A><BR>
<A HREF="manual.html#lua_geti">lua_geti</A><BR>
<A HREF="manual.html#lua_getinfo">lua_getinfo</A><BR>
+<A HREF="manual.html#lua_getiuservalue">lua_getiuservalue</A><BR>
<A HREF="manual.html#lua_getlocal">lua_getlocal</A><BR>
<A HREF="manual.html#lua_getmetatable">lua_getmetatable</A><BR>
<A HREF="manual.html#lua_getstack">lua_getstack</A><BR>
<A HREF="manual.html#lua_gettable">lua_gettable</A><BR>
<A HREF="manual.html#lua_gettop">lua_gettop</A><BR>
<A HREF="manual.html#lua_getupvalue">lua_getupvalue</A><BR>
-<A HREF="manual.html#lua_getuservalue">lua_getuservalue</A><BR>
<A HREF="manual.html#lua_insert">lua_insert</A><BR>
<A HREF="manual.html#lua_isboolean">lua_isboolean</A><BR>
<A HREF="manual.html#lua_iscfunction">lua_iscfunction</A><BR>
@@ -426,7 +439,7 @@ Freely available under the terms of the
<A HREF="manual.html#lua_newstate">lua_newstate</A><BR>
<A HREF="manual.html#lua_newtable">lua_newtable</A><BR>
<A HREF="manual.html#lua_newthread">lua_newthread</A><BR>
-<A HREF="manual.html#lua_newuserdata">lua_newuserdata</A><BR>
+<A HREF="manual.html#lua_newuserdatauv">lua_newuserdatauv</A><BR>
<A HREF="manual.html#lua_next">lua_next</A><BR>
<A HREF="manual.html#lua_numbertointeger">lua_numbertointeger</A><BR>
<A HREF="manual.html#lua_pcall">lua_pcall</A><BR>
@@ -458,6 +471,7 @@ Freely available under the terms of the
<A HREF="manual.html#lua_register">lua_register</A><BR>
<A HREF="manual.html#lua_remove">lua_remove</A><BR>
<A HREF="manual.html#lua_replace">lua_replace</A><BR>
+<A HREF="manual.html#lua_resetthread">lua_resetthread</A><BR>
<A HREF="manual.html#lua_resume">lua_resume</A><BR>
<A HREF="manual.html#lua_rotate">lua_rotate</A><BR>
<A HREF="manual.html#lua_setallocf">lua_setallocf</A><BR>
@@ -465,16 +479,18 @@ Freely available under the terms of the
<A HREF="manual.html#lua_setglobal">lua_setglobal</A><BR>
<A HREF="manual.html#lua_sethook">lua_sethook</A><BR>
<A HREF="manual.html#lua_seti">lua_seti</A><BR>
+<A HREF="manual.html#lua_setiuservalue">lua_setiuservalue</A><BR>
<A HREF="manual.html#lua_setlocal">lua_setlocal</A><BR>
<A HREF="manual.html#lua_setmetatable">lua_setmetatable</A><BR>
<A HREF="manual.html#lua_settable">lua_settable</A><BR>
<A HREF="manual.html#lua_settop">lua_settop</A><BR>
<A HREF="manual.html#lua_setupvalue">lua_setupvalue</A><BR>
-<A HREF="manual.html#lua_setuservalue">lua_setuservalue</A><BR>
+<A HREF="manual.html#lua_setwarnf">lua_setwarnf</A><BR>
<A HREF="manual.html#lua_status">lua_status</A><BR>
<A HREF="manual.html#lua_stringtonumber">lua_stringtonumber</A><BR>
<A HREF="manual.html#lua_toboolean">lua_toboolean</A><BR>
<A HREF="manual.html#lua_tocfunction">lua_tocfunction</A><BR>
+<A HREF="manual.html#lua_toclose">lua_toclose</A><BR>
<A HREF="manual.html#lua_tointeger">lua_tointeger</A><BR>
<A HREF="manual.html#lua_tointegerx">lua_tointegerx</A><BR>
<A HREF="manual.html#lua_tolstring">lua_tolstring</A><BR>
@@ -490,6 +506,7 @@ Freely available under the terms of the
<A HREF="manual.html#lua_upvalueindex">lua_upvalueindex</A><BR>
<A HREF="manual.html#lua_upvaluejoin">lua_upvaluejoin</A><BR>
<A HREF="manual.html#lua_version">lua_version</A><BR>
+<A HREF="manual.html#lua_warning">lua_warning</A><BR>
<A HREF="manual.html#lua_xmove">lua_xmove</A><BR>
<A HREF="manual.html#lua_yield">lua_yield</A><BR>
<A HREF="manual.html#lua_yieldk">lua_yieldk</A><BR>
@@ -504,14 +521,19 @@ Freely available under the terms of the
<P>
<A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR>
+<A HREF="manual.html#luaL_addgsub">luaL_addgsub</A><BR>
<A HREF="manual.html#luaL_addlstring">luaL_addlstring</A><BR>
<A HREF="manual.html#luaL_addsize">luaL_addsize</A><BR>
<A HREF="manual.html#luaL_addstring">luaL_addstring</A><BR>
<A HREF="manual.html#luaL_addvalue">luaL_addvalue</A><BR>
<A HREF="manual.html#luaL_argcheck">luaL_argcheck</A><BR>
<A HREF="manual.html#luaL_argerror">luaL_argerror</A><BR>
+<A HREF="manual.html#luaL_argexpected">luaL_argexpected</A><BR>
+<A HREF="manual.html#luaL_buffaddr">luaL_buffaddr</A><BR>
<A HREF="manual.html#luaL_buffinit">luaL_buffinit</A><BR>
<A HREF="manual.html#luaL_buffinitsize">luaL_buffinitsize</A><BR>
+<A HREF="manual.html#luaL_bufflen">luaL_bufflen</A><BR>
+<A HREF="manual.html#luaL_buffsub">luaL_buffsub</A><BR>
<A HREF="manual.html#luaL_callmeta">luaL_callmeta</A><BR>
<A HREF="manual.html#luaL_checkany">luaL_checkany</A><BR>
<A HREF="manual.html#luaL_checkinteger">luaL_checkinteger</A><BR>
@@ -550,6 +572,7 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_optstring">luaL_optstring</A><BR>
<A HREF="manual.html#luaL_prepbuffer">luaL_prepbuffer</A><BR>
<A HREF="manual.html#luaL_prepbuffsize">luaL_prepbuffsize</A><BR>
+<A HREF="manual.html#luaL_pushfail">luaL_pushfail</A><BR>
<A HREF="manual.html#luaL_pushresult">luaL_pushresult</A><BR>
<A HREF="manual.html#luaL_pushresultsize">luaL_pushresultsize</A><BR>
<A HREF="manual.html#luaL_ref">luaL_ref</A><BR>
@@ -559,6 +582,7 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_testudata">luaL_testudata</A><BR>
<A HREF="manual.html#luaL_tolstring">luaL_tolstring</A><BR>
<A HREF="manual.html#luaL_traceback">luaL_traceback</A><BR>
+<A HREF="manual.html#luaL_typeerror">luaL_typeerror</A><BR>
<A HREF="manual.html#luaL_typename">luaL_typename</A><BR>
<A HREF="manual.html#luaL_unref">luaL_unref</A><BR>
<A HREF="manual.html#luaL_where">luaL_where</A><BR>
@@ -580,7 +604,6 @@ Freely available under the terms of the
<P>
<A HREF="manual.html#pdf-LUA_ERRERR">LUA_ERRERR</A><BR>
<A HREF="manual.html#pdf-LUA_ERRFILE">LUA_ERRFILE</A><BR>
-<A HREF="manual.html#pdf-LUA_ERRGCMM">LUA_ERRGCMM</A><BR>
<A HREF="manual.html#pdf-LUA_ERRMEM">LUA_ERRMEM</A><BR>
<A HREF="manual.html#pdf-LUA_ERRRUN">LUA_ERRRUN</A><BR>
<A HREF="manual.html#pdf-LUA_ERRSYNTAX">LUA_ERRSYNTAX</A><BR>
@@ -589,6 +612,7 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-LUA_HOOKLINE">LUA_HOOKLINE</A><BR>
<A HREF="manual.html#pdf-LUA_HOOKRET">LUA_HOOKRET</A><BR>
<A HREF="manual.html#pdf-LUA_HOOKTAILCALL">LUA_HOOKTAILCALL</A><BR>
+<A HREF="manual.html#pdf-LUAL_BUFFERSIZE">LUAL_BUFFERSIZE</A><BR>
<A HREF="manual.html#pdf-LUA_MASKCALL">LUA_MASKCALL</A><BR>
<A HREF="manual.html#pdf-LUA_MASKCOUNT">LUA_MASKCOUNT</A><BR>
<A HREF="manual.html#pdf-LUA_MASKLINE">LUA_MASKLINE</A><BR>
@@ -632,7 +656,6 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-LUA_TUSERDATA">LUA_TUSERDATA</A><BR>
<A HREF="manual.html#pdf-LUA_USE_APICHECK">LUA_USE_APICHECK</A><BR>
<A HREF="manual.html#pdf-LUA_YIELD">LUA_YIELD</A><BR>
-<A HREF="manual.html#pdf-LUAL_BUFFERSIZE">LUAL_BUFFERSIZE</A><BR>
</TD>
</TR>
@@ -640,10 +663,10 @@ Freely available under the terms of the
<P CLASS="footer">
Last update:
-Tue Aug 25 13:45:14 UTC 2020
+Tue Nov 10 20:58:52 UTC 2020
</P>
<!--
-Last change: revised for Lua 5.3.6
+Last change: revised for Lua 5.4.2
-->
</BODY>
diff --git a/doc/lua.1 b/doc/lua.1
index d728d0b80c17..a46a1a67dd04 100644
--- a/doc/lua.1
+++ b/doc/lua.1
@@ -1,5 +1,5 @@
-.\" $Id: lua.man,v 1.14 2016/10/17 15:43:50 lhf Exp $
-.TH LUA 1 "$Date: 2016/10/17 15:43:50 $"
+.\" $Id: lua.man,v 1.14 2020/05/21 19:31:21 lhf Exp $
+.TH LUA 1 "$Date: 2020/05/21 19:31:21 $"
.SH NAME
lua \- Lua interpreter
.SH SYNOPSIS
@@ -25,52 +25,57 @@ the Lua compiler.)
.B lua
can be used as a batch interpreter and also interactively.
.LP
-The given
-.I options
-are handled in order and then
+After handling the
+.IR options ,
the Lua program in file
.I script
is loaded and executed.
-The given
+The
.I args
are available to
.I script
as strings in a global table named
-.BR arg .
-If no options or arguments are given,
-then
-.B "\-v \-i"
-is assumed when the standard input is a terminal;
-otherwise,
-.B "\-"
-is assumed.
+.B arg
+and also as arguments to its main function.
+When called without arguments,
+.B lua
+behaves as
+.B "lua \-v \-i"
+if the standard input is a terminal,
+and as
+.B "lua \-"
+otherwise.
.LP
In interactive mode,
.B lua
prompts the user,
reads lines from the standard input,
and executes them as they are read.
-If the line contains an expression or list of expressions,
-then the line is evaluated and the results are printed.
+If the line contains an expression,
+then the line is evaluated and the result is printed.
If a line does not contain a complete statement,
then a secondary prompt is displayed and
lines are read until a complete statement is formed or
a syntax error is found.
.LP
-At the very start,
-before even handling the command line,
+Before handling command line options and scripts,
.B lua
checks the contents of the environment variables
-.B LUA_INIT_5_3
-or
+.B LUA_INIT_5_4
+and
.BR LUA_INIT ,
in that order.
-If the contents is of the form
+If the contents are of the form
.RI '@ filename ',
then
.I filename
is executed.
-Otherwise, the string is assumed to be a Lua statement and is executed.
+Otherwise, the contents are assumed to be a Lua statement and is executed.
+When
+.B LUA_INIT_5_4
+is defined,
+.B LUA_INIT
+is ignored.
.SH OPTIONS
.TP
.BI \-e " stat"
@@ -82,10 +87,10 @@ enter interactive mode after executing
.IR script .
.TP
.BI \-l " name"
-execute the equivalent of
-.IB name =require(' name ')
-before executing
-.IR script .
+require library
+.I name
+into global
+.IR name .
.TP
.B \-v
show version information.
@@ -93,18 +98,50 @@ show version information.
.B \-E
ignore environment variables.
.TP
+.B \-W
+turn warnings on.
+.TP
.B \-\-
stop handling options.
.TP
.B \-
stop handling options and execute the standard input as a file.
+.SH ENVIRONMENT VARIABLES
+The following environment variables affect the execution of
+.BR lua .
+When defined,
+the version-specific variants take priority
+and the version-neutral variants are ignored.
+.TP
+.B LUA_INIT, LUA_INIT_5_4
+Code to be executed before command line options and scripts.
+.TP
+.B LUA_PATH, LUA_PATH_5_4
+Initial value of package.cpath,
+the path used by require to search for Lua loaders.
+.TP
+.B LUA_CPATH, LUA_CPATH_5_4
+Initial value of package.cpath,
+the path used by require to search for C loaders.
+.SH EXIT STATUS
+If a script calls os.exit,
+then
+.B lua
+exits with the given exit status.
+Otherwise,
+.B lua
+exits
+with EXIT_SUCCESS (0 on POSIX systems) if there were no errors
+and
+with EXIT_FAILURE (1 on POSIX systems) if there were errors.
+Errors raised in interactive mode do not cause exits.
+.SH DIAGNOSTICS
+Error messages should be self explanatory.
.SH "SEE ALSO"
.BR luac (1)
.br
The documentation at lua.org,
especially section 7 of the reference manual.
-.SH DIAGNOSTICS
-Error messages should be self explanatory.
.SH AUTHORS
R. Ierusalimschy,
L. H. de Figueiredo,
diff --git a/doc/manual.html b/doc/manual.html
index 57c778744b7a..6de396c41d1c 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
-<TITLE>Lua 5.3 Reference Manual</TITLE>
+<TITLE>Lua 5.4 Reference Manual</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
<LINK REL="stylesheet" TYPE="text/css" HREF="manual.css">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
@@ -11,7 +11,7 @@
<H1>
<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
-Lua 5.3 Reference Manual
+Lua 5.4 Reference Manual
</H1>
<P>
@@ -19,7 +19,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
<P>
<SMALL>
-Copyright © 2015–2020 Lua.org, PUC-Rio.
+Copyright © 2020 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html">Lua license</a>.
</SMALL>
@@ -35,7 +35,7 @@ Freely available under the terms of the
<!-- ====================================================================== -->
<p>
-<!-- $Id: manual.of,v 1.167.1.2 2018/06/26 15:49:07 roberto Exp $ -->
+<!-- $Id: manual.of $ -->
@@ -56,7 +56,7 @@ Lua is dynamically typed,
runs by interpreting bytecode with a register-based
virtual machine,
and has automatic memory management with
-incremental garbage collection,
+a generational garbage collection,
making it ideal for configuration, scripting,
and rapid prototyping.
@@ -106,15 +106,19 @@ see Roberto's book, <em>Programming in Lua</em>.
<h1>2 – <a name="2">Basic Concepts</a></h1>
+
+
<p>
This section describes the basic concepts of the language.
+
+
<h2>2.1 – <a name="2.1">Values and Types</a></h2>
<p>
-Lua is a <em>dynamically typed language</em>.
+Lua is a dynamically typed language.
This means that
variables do not have types; only values do.
There are no type definitions in the language.
@@ -122,7 +126,7 @@ All values carry their own type.
<p>
-All values in Lua are <em>first-class values</em>.
+All values in Lua are first-class values.
This means that all values can be stored in variables,
passed as arguments to other functions, and returned as results.
@@ -134,31 +138,17 @@ There are eight basic types in Lua:
<em>thread</em>, and <em>table</em>.
The type <em>nil</em> has one single value, <b>nil</b>,
whose main property is to be different from any other value;
-it usually represents the absence of a useful value.
+it often represents the absence of a useful value.
The type <em>boolean</em> has two values, <b>false</b> and <b>true</b>.
Both <b>nil</b> and <b>false</b> make a condition false;
-any other value makes it true.
-The type <em>number</em> represents both
-integer numbers and real (floating-point) numbers.
-The type <em>string</em> represents immutable sequences of bytes.
-
-Lua is 8-bit clean:
-strings can contain any 8-bit value,
-including embedded zeros ('<code>\0</code>').
-Lua is also encoding-agnostic;
-it makes no assumptions about the contents of a string.
+they are collectively called <em>false values</em>.
+Any other value makes a condition true.
<p>
-The type <em>number</em> uses two internal representations,
-or two subtypes,
-one called <em>integer</em> and the other called <em>float</em>.
-Lua has explicit rules about when each representation is used,
-but it also converts between them automatically as needed (see <a href="#3.4.3">§3.4.3</a>).
-Therefore,
-the programmer may choose to mostly ignore the difference
-between integers and floats
-or to assume complete control over the representation of each number.
+The type <em>number</em> represents both
+integer numbers and real (floating-point) numbers,
+using two subtypes: <em>integer</em> and <em>float</em>.
Standard Lua uses 64-bit integers and double-precision (64-bit) floats,
but you can also compile Lua so that it
uses 32-bit integers and/or single-precision (32-bit) floats.
@@ -168,6 +158,36 @@ for small machines and embedded systems.
(See macro <code>LUA_32BITS</code> in file <code>luaconf.h</code>.)
+<p>
+Unless stated otherwise,
+any overflow when manipulating integer values <em>wrap around</em>,
+according to the usual rules of two-complement arithmetic.
+(In other words,
+the actual result is the unique representable integer
+that is equal modulo <em>2<sup>n</sup></em> to the mathematical result,
+where <em>n</em> is the number of bits of the integer type.)
+
+
+<p>
+Lua has explicit rules about when each subtype is used,
+but it also converts between them automatically as needed (see <a href="#3.4.3">§3.4.3</a>).
+Therefore,
+the programmer may choose to mostly ignore the difference
+between integers and floats
+or to assume complete control over the representation of each number.
+
+
+<p>
+The type <em>string</em> represents immutable sequences of bytes.
+
+Lua is 8-bit clean:
+strings can contain any 8-bit value,
+including embedded zeros ('<code>\0</code>').
+Lua is also encoding-agnostic;
+it makes no assumptions about the contents of a string.
+The length of any string in Lua must fit in a Lua integer.
+
+
<p>
Lua can call (and manipulate) functions written in Lua and
functions written in C (see <a href="#3.4.10">§3.4.10</a>).
@@ -190,7 +210,8 @@ the programmer can define operations for full userdata values
(see <a href="#2.4">§2.4</a>).
Userdata values cannot be created or modified in Lua,
only through the C API.
-This guarantees the integrity of data owned by the host program.
+This guarantees the integrity of data owned by
+the host program and C libraries.
<p>
@@ -205,11 +226,12 @@ even those that do not support threads natively.
The type <em>table</em> implements associative arrays,
that is, arrays that can have as indices not only numbers,
but any Lua value except <b>nil</b> and NaN.
-(<em>Not a Number</em> is a special value used to represent
-undefined or unrepresentable numerical results, such as <code>0/0</code>.)
+(<em>Not a Number</em> is a special floating-point value
+used by the IEEE 754 standard to represent
+undefined numerical results, such as <code>0/0</code>.)
Tables can be <em>heterogeneous</em>;
that is, they can contain values of all types (except <b>nil</b>).
-Any key with value <b>nil</b> is not considered part of the table.
+Any key associated to the value <b>nil</b> is not considered part of the table.
Conversely, any key that is not part of a table has
an associated value <b>nil</b>.
@@ -245,14 +267,10 @@ In particular, floats with integral values
are equal to their respective integers
(e.g., <code>1.0 == 1</code>).
To avoid ambiguities,
-any float with integral value used as a key
-is converted to its respective integer.
+any float used as a key that is equal to an integer
+is converted to that integer.
For instance, if you write <code>a[2.0] = true</code>,
-the actual key inserted into the table will be the
-integer <code>2</code>.
-(On the other hand,
-2 and "<code>2</code>" are different Lua values and therefore
-denote different table entries.)
+the actual key inserted into the table will be the integer <code>2</code>.
<p>
@@ -266,7 +284,7 @@ these operations do not imply any kind of copy.
<p>
The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
-of a given value (see <a href="#6.1">§6.1</a>).
+of a given value (see <a href="#pdf-type"><code>type</code></a>).
@@ -275,7 +293,7 @@ of a given value (see <a href="#6.1">§6.1</a>).
<h2>2.2 – <a name="2.2">Environments and the Global Environment</a></h2>
<p>
-As will be discussed in <a href="#3.2">§3.2</a> and <a href="#3.3.3">§3.3.3</a>,
+As we will discuss further in <a href="#3.2">§3.2</a> and <a href="#3.3.3">§3.3.3</a>,
any reference to a free name
(that is, a name not bound to any declaration) <code>var</code>
is syntactically translated to <code>_ENV.var</code>.
@@ -301,24 +319,25 @@ Any table used as the value of <code>_ENV</code> is called an <em>environment</e
<p>
Lua keeps a distinguished environment called the <em>global environment</em>.
-This value is kept at a special index in the C registry (see <a href="#4.5">§4.5</a>).
+This value is kept at a special index in the C registry (see <a href="#4.3">§4.3</a>).
In Lua, the global variable <a href="#pdf-_G"><code>_G</code></a> is initialized with this same value.
-(<a href="#pdf-_G"><code>_G</code></a> is never used internally.)
+(<a href="#pdf-_G"><code>_G</code></a> is never used internally,
+so changing its value will affect only your own code.)
<p>
When Lua loads a chunk,
-the default value for its <code>_ENV</code> upvalue
+the default value for its <code>_ENV</code> variable
is the global environment (see <a href="#pdf-load"><code>load</code></a>).
Therefore, by default,
free names in Lua code refer to entries in the global environment
-(and, therefore, they are also called <em>global variables</em>).
+and, therefore, they are also called <em>global variables</em>.
Moreover, all standard libraries are loaded in the global environment
and some functions there operate on that environment.
You can use <a href="#pdf-load"><code>load</code></a> (or <a href="#pdf-loadfile"><code>loadfile</code></a>)
to load a chunk with a different environment.
(In C, you have to load the chunk and then change the value
-of its first upvalue.)
+of its first upvalue; see <a href="#lua_setupvalue"><code>lua_setupvalue</code></a>.)
@@ -326,39 +345,57 @@ of its first upvalue.)
<h2>2.3 – <a name="2.3">Error Handling</a></h2>
+<p>
+Several operations in Lua can <em>raise</em> an error.
+An error interrupts the normal flow of the program,
+which can continue by <em>catching</em> the error.
+
+
+<p>
+Lua code can explicitly raise an error by calling the
+<a href="#pdf-error"><code>error</code></a> function.
+(This function never returns.)
+
+
+<p>
+To catch errors in Lua,
+you can do a <em>protected call</em>,
+using <a href="#pdf-pcall"><code>pcall</code></a> (or <a href="#pdf-xpcall"><code>xpcall</code></a>).
+The function <a href="#pdf-pcall"><code>pcall</code></a> calls a given function in <em>protected mode</em>.
+Any error while running the function stops its execution,
+and control returns immediately to <code>pcall</code>,
+which returns a status code.
+
+
<p>
Because Lua is an embedded extension language,
-all Lua actions start from C code in the host program
-calling a function from the Lua library.
+Lua code starts running by a call
+from C code in the host program.
(When you use Lua standalone,
the <code>lua</code> application is the host program.)
-Whenever an error occurs during
+Usually, this call is protected;
+so, when an otherwise unprotected error occurs during
the compilation or execution of a Lua chunk,
control returns to the host,
-which can take appropriate measures
-(such as printing an error message).
-
-
-<p>
-Lua code can explicitly generate an error by calling the
-<a href="#pdf-error"><code>error</code></a> function.
-If you need to catch errors in Lua,
-you can use <a href="#pdf-pcall"><code>pcall</code></a> or <a href="#pdf-xpcall"><code>xpcall</code></a>
-to call a given function in <em>protected mode</em>.
+which can take appropriate measures,
+such as printing an error message.
<p>
Whenever there is an error,
-an <em>error object</em> (also called an <em>error message</em>)
+an <em>error object</em>
is propagated with information about the error.
Lua itself only generates errors whose error object is a string,
but programs may generate errors with
any value as the error object.
It is up to the Lua program or its host to handle such error objects.
+For historical reasons,
+an error object is often called an <em>error message</em>,
+even though it does not have to be a string.
<p>
-When you use <a href="#pdf-xpcall"><code>xpcall</code></a> or <a href="#lua_pcall"><code>lua_pcall</code></a>,
+When you use <a href="#pdf-xpcall"><code>xpcall</code></a> (or <a href="#lua_pcall"><code>lua_pcall</code></a>, in C)
you may give a <em>message handler</em>
to be called in case of errors.
This function is called with the original error object
@@ -371,9 +408,17 @@ so, an error inside the message handler
will call the message handler again.
If this loop goes on for too long,
Lua breaks it and returns an appropriate message.
-(The message handler is called only for regular runtime errors.
+The message handler is called only for regular runtime errors.
It is not called for memory-allocation errors
-nor for errors while running finalizers.)
+nor for errors while running finalizers or other message handlers.
+
+
+<p>
+Lua also offers a system of <em>warnings</em> (see <a href="#pdf-warn"><code>warn</code></a>).
+Unlike errors, warnings do not interfere
+in any way with program execution.
+They typically only generate a message to the user,
+although this behavior can be adapted from C (see <a href="#lua_setwarnf"><code>lua_setwarnf</code></a>).
@@ -385,9 +430,9 @@ nor for errors while running finalizers.)
Every value in Lua can have a <em>metatable</em>.
This <em>metatable</em> is an ordinary Lua table
that defines the behavior of the original value
-under certain special operations.
+under certain events.
You can change several aspects of the behavior
-of operations over a value by setting specific fields in its metatable.
+of a value by setting specific fields in its metatable.
For instance, when a non-numeric value is the operand of an addition,
Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
If it finds one,
@@ -397,35 +442,32 @@ Lua calls this function to perform the addition.
<p>
The key for each event in a metatable is a string
with the event name prefixed by two underscores;
-the corresponding values are called <em>metamethods</em>.
-In the previous example, the key is "<code>__add</code>"
+the corresponding value is called a <em>metavalue</em>.
+For most events, the metavalue must be a function,
+which is then called a <em>metamethod</em>.
*** 31822 LINES SKIPPED ***
More information about the dev-commits-src-all
mailing list