Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstarkos <none@none>2008-12-30 04:15:38 +0300
committerstarkos <none@none>2008-12-30 04:15:38 +0300
commit99bd98b803d5ab21d12677cb76484f6ff5f36546 (patch)
tree3533374661089fe14f76dd46680f83ef08ebc9eb
parent6ca3b3004e4e6b62840280ace5135809533bac7e (diff)
Upgraded to Lua 5.1.4
-rw-r--r--premake4.lua12
-rw-r--r--src/host/lua-5.1.2/PREMAKE_CHANGES.txt2
-rw-r--r--src/host/lua-5.1.2/etc/luavs.bat15
-rw-r--r--src/host/lua-5.1.4/COPYRIGHT (renamed from src/host/lua-5.1.2/COPYRIGHT)2
-rw-r--r--src/host/lua-5.1.4/HISTORY (renamed from src/host/lua-5.1.2/HISTORY)0
-rw-r--r--src/host/lua-5.1.4/INSTALL (renamed from src/host/lua-5.1.2/INSTALL)0
-rw-r--r--src/host/lua-5.1.4/Makefile (renamed from src/host/lua-5.1.2/Makefile)40
-rw-r--r--src/host/lua-5.1.4/README (renamed from src/host/lua-5.1.2/README)0
-rw-r--r--src/host/lua-5.1.4/doc/amazon.gif (renamed from src/host/lua-5.1.2/doc/amazon.gif)bin797 -> 797 bytes
-rw-r--r--src/host/lua-5.1.4/doc/contents.html (renamed from src/host/lua-5.1.2/doc/contents.html)73
-rw-r--r--src/host/lua-5.1.4/doc/cover.png (renamed from src/host/lua-5.1.2/doc/cover.png)bin3305 -> 3305 bytes
-rw-r--r--src/host/lua-5.1.4/doc/logo.gif (renamed from src/host/lua-5.1.2/doc/logo.gif)bin4232 -> 4232 bytes
-rw-r--r--src/host/lua-5.1.4/doc/lua.1 (renamed from src/host/lua-5.1.2/doc/lua.1)0
-rw-r--r--src/host/lua-5.1.4/doc/lua.css (renamed from src/host/lua-5.1.2/doc/lua.css)0
-rw-r--r--src/host/lua-5.1.4/doc/lua.html (renamed from src/host/lua-5.1.2/doc/lua.html)0
-rw-r--r--src/host/lua-5.1.4/doc/luac.1 (renamed from src/host/lua-5.1.2/doc/luac.1)0
-rw-r--r--src/host/lua-5.1.4/doc/luac.html (renamed from src/host/lua-5.1.2/doc/luac.html)0
-rw-r--r--src/host/lua-5.1.4/doc/manual.css (renamed from src/host/lua-5.1.2/doc/manual.css)6
-rw-r--r--src/host/lua-5.1.4/doc/manual.html (renamed from src/host/lua-5.1.2/doc/manual.html)1082
-rw-r--r--src/host/lua-5.1.4/doc/readme.html (renamed from src/host/lua-5.1.2/doc/readme.html)4
-rw-r--r--src/host/lua-5.1.4/etc/Makefile (renamed from src/host/lua-5.1.2/etc/Makefile)0
-rw-r--r--src/host/lua-5.1.4/etc/README (renamed from src/host/lua-5.1.2/etc/README)0
-rw-r--r--src/host/lua-5.1.4/etc/all.c (renamed from src/host/lua-5.1.2/etc/all.c)0
-rw-r--r--src/host/lua-5.1.4/etc/lua.hpp (renamed from src/host/lua-5.1.2/etc/lua.hpp)0
-rw-r--r--src/host/lua-5.1.4/etc/lua.ico (renamed from src/host/lua-5.1.2/etc/lua.ico)bin1078 -> 1078 bytes
-rw-r--r--src/host/lua-5.1.4/etc/lua.pc (renamed from src/host/lua-5.1.2/etc/lua.pc)2
-rw-r--r--src/host/lua-5.1.4/etc/luavs.bat28
-rw-r--r--src/host/lua-5.1.4/etc/min.c (renamed from src/host/lua-5.1.2/etc/min.c)2
-rw-r--r--src/host/lua-5.1.4/etc/noparser.c (renamed from src/host/lua-5.1.2/etc/noparser.c)0
-rw-r--r--src/host/lua-5.1.4/etc/strict.lua (renamed from src/host/lua-5.1.2/etc/strict.lua)4
-rw-r--r--src/host/lua-5.1.4/src/Makefile (renamed from src/host/lua-5.1.2/src/Makefile)9
-rw-r--r--src/host/lua-5.1.4/src/lapi.c (renamed from src/host/lua-5.1.2/src/lapi.c)25
-rw-r--r--src/host/lua-5.1.4/src/lapi.h (renamed from src/host/lua-5.1.2/src/lapi.h)2
-rw-r--r--src/host/lua-5.1.4/src/lauxlib.c (renamed from src/host/lua-5.1.2/src/lauxlib.c)13
-rw-r--r--src/host/lua-5.1.4/src/lauxlib.h (renamed from src/host/lua-5.1.2/src/lauxlib.h)2
-rw-r--r--src/host/lua-5.1.4/src/lbaselib.c (renamed from src/host/lua-5.1.2/src/lbaselib.c)88
-rw-r--r--src/host/lua-5.1.4/src/lcode.c (renamed from src/host/lua-5.1.2/src/lcode.c)4
-rw-r--r--src/host/lua-5.1.4/src/lcode.h (renamed from src/host/lua-5.1.2/src/lcode.h)2
-rw-r--r--src/host/lua-5.1.4/src/ldblib.c (renamed from src/host/lua-5.1.2/src/ldblib.c)30
-rw-r--r--src/host/lua-5.1.4/src/ldebug.c (renamed from src/host/lua-5.1.2/src/ldebug.c)38
-rw-r--r--src/host/lua-5.1.4/src/ldebug.h (renamed from src/host/lua-5.1.2/src/ldebug.h)2
-rw-r--r--src/host/lua-5.1.4/src/ldo.c (renamed from src/host/lua-5.1.2/src/ldo.c)24
-rw-r--r--src/host/lua-5.1.4/src/ldo.h (renamed from src/host/lua-5.1.2/src/ldo.h)2
-rw-r--r--src/host/lua-5.1.4/src/ldump.c (renamed from src/host/lua-5.1.2/src/ldump.c)2
-rw-r--r--src/host/lua-5.1.4/src/lfunc.c (renamed from src/host/lua-5.1.2/src/lfunc.c)2
-rw-r--r--src/host/lua-5.1.4/src/lfunc.h (renamed from src/host/lua-5.1.2/src/lfunc.h)2
-rw-r--r--src/host/lua-5.1.4/src/lgc.c (renamed from src/host/lua-5.1.2/src/lgc.c)2
-rw-r--r--src/host/lua-5.1.4/src/lgc.h (renamed from src/host/lua-5.1.2/src/lgc.h)2
-rw-r--r--src/host/lua-5.1.4/src/linit.c (renamed from src/host/lua-5.1.2/src/linit.c)2
-rw-r--r--src/host/lua-5.1.4/src/liolib.c (renamed from src/host/lua-5.1.2/src/liolib.c)69
-rw-r--r--src/host/lua-5.1.4/src/llex.c (renamed from src/host/lua-5.1.2/src/llex.c)2
-rw-r--r--src/host/lua-5.1.4/src/llex.h (renamed from src/host/lua-5.1.2/src/llex.h)2
-rw-r--r--src/host/lua-5.1.4/src/llimits.h (renamed from src/host/lua-5.1.2/src/llimits.h)2
-rw-r--r--src/host/lua-5.1.4/src/lmathlib.c (renamed from src/host/lua-5.1.2/src/lmathlib.c)2
-rw-r--r--src/host/lua-5.1.4/src/lmem.c (renamed from src/host/lua-5.1.2/src/lmem.c)2
-rw-r--r--src/host/lua-5.1.4/src/lmem.h (renamed from src/host/lua-5.1.2/src/lmem.h)2
-rw-r--r--src/host/lua-5.1.4/src/loadlib.c (renamed from src/host/lua-5.1.2/src/loadlib.c)8
-rw-r--r--src/host/lua-5.1.4/src/lobject.c (renamed from src/host/lua-5.1.2/src/lobject.c)2
-rw-r--r--src/host/lua-5.1.4/src/lobject.h (renamed from src/host/lua-5.1.2/src/lobject.h)4
-rw-r--r--src/host/lua-5.1.4/src/lopcodes.c (renamed from src/host/lua-5.1.2/src/lopcodes.c)2
-rw-r--r--src/host/lua-5.1.4/src/lopcodes.h (renamed from src/host/lua-5.1.2/src/lopcodes.h)2
-rw-r--r--src/host/lua-5.1.4/src/loslib.c (renamed from src/host/lua-5.1.2/src/loslib.c)3
-rw-r--r--src/host/lua-5.1.4/src/lparser.c (renamed from src/host/lua-5.1.2/src/lparser.c)4
-rw-r--r--src/host/lua-5.1.4/src/lparser.h (renamed from src/host/lua-5.1.2/src/lparser.h)2
-rw-r--r--src/host/lua-5.1.4/src/lstate.c (renamed from src/host/lua-5.1.2/src/lstate.c)6
-rw-r--r--src/host/lua-5.1.4/src/lstate.h (renamed from src/host/lua-5.1.2/src/lstate.h)3
-rw-r--r--src/host/lua-5.1.4/src/lstring.c (renamed from src/host/lua-5.1.2/src/lstring.c)2
-rw-r--r--src/host/lua-5.1.4/src/lstring.h (renamed from src/host/lua-5.1.2/src/lstring.h)2
-rw-r--r--src/host/lua-5.1.4/src/lstrlib.c (renamed from src/host/lua-5.1.2/src/lstrlib.c)13
-rw-r--r--src/host/lua-5.1.4/src/ltable.c (renamed from src/host/lua-5.1.2/src/ltable.c)6
-rw-r--r--src/host/lua-5.1.4/src/ltable.h (renamed from src/host/lua-5.1.2/src/ltable.h)2
-rw-r--r--src/host/lua-5.1.4/src/ltablib.c (renamed from src/host/lua-5.1.2/src/ltablib.c)25
-rw-r--r--src/host/lua-5.1.4/src/ltm.c (renamed from src/host/lua-5.1.2/src/ltm.c)2
-rw-r--r--src/host/lua-5.1.4/src/ltm.h (renamed from src/host/lua-5.1.2/src/ltm.h)2
-rw-r--r--src/host/lua-5.1.4/src/lua.c (renamed from src/host/lua-5.1.2/src/lua.c)6
-rw-r--r--src/host/lua-5.1.4/src/lua.h (renamed from src/host/lua-5.1.2/src/lua.h)11
-rw-r--r--src/host/lua-5.1.4/src/luac.c (renamed from src/host/lua-5.1.2/src/luac.c)0
-rw-r--r--src/host/lua-5.1.4/src/luaconf.h (renamed from src/host/lua-5.1.2/src/luaconf.h)14
-rw-r--r--src/host/lua-5.1.4/src/lualib.h (renamed from src/host/lua-5.1.2/src/lualib.h)2
-rw-r--r--src/host/lua-5.1.4/src/lundump.c (renamed from src/host/lua-5.1.2/src/lundump.c)12
-rw-r--r--src/host/lua-5.1.4/src/lundump.h (renamed from src/host/lua-5.1.2/src/lundump.h)2
-rw-r--r--src/host/lua-5.1.4/src/lvm.c (renamed from src/host/lua-5.1.2/src/lvm.c)10
-rw-r--r--src/host/lua-5.1.4/src/lvm.h (renamed from src/host/lua-5.1.2/src/lvm.h)2
-rw-r--r--src/host/lua-5.1.4/src/lzio.c (renamed from src/host/lua-5.1.2/src/lzio.c)2
-rw-r--r--src/host/lua-5.1.4/src/lzio.h (renamed from src/host/lua-5.1.2/src/lzio.h)2
-rw-r--r--src/host/lua-5.1.4/src/print.c (renamed from src/host/lua-5.1.2/src/print.c)0
-rw-r--r--src/host/lua-5.1.4/test/README (renamed from src/host/lua-5.1.2/test/README)0
-rw-r--r--src/host/lua-5.1.4/test/bisect.lua (renamed from src/host/lua-5.1.2/test/bisect.lua)0
-rw-r--r--src/host/lua-5.1.4/test/cf.lua (renamed from src/host/lua-5.1.2/test/cf.lua)0
-rw-r--r--src/host/lua-5.1.4/test/echo.lua (renamed from src/host/lua-5.1.2/test/echo.lua)0
-rw-r--r--src/host/lua-5.1.4/test/env.lua (renamed from src/host/lua-5.1.2/test/env.lua)0
-rw-r--r--src/host/lua-5.1.4/test/factorial.lua (renamed from src/host/lua-5.1.2/test/factorial.lua)0
-rw-r--r--src/host/lua-5.1.4/test/fib.lua (renamed from src/host/lua-5.1.2/test/fib.lua)0
-rw-r--r--src/host/lua-5.1.4/test/fibfor.lua (renamed from src/host/lua-5.1.2/test/fibfor.lua)0
-rw-r--r--src/host/lua-5.1.4/test/globals.lua (renamed from src/host/lua-5.1.2/test/globals.lua)0
-rw-r--r--src/host/lua-5.1.4/test/hello.lua (renamed from src/host/lua-5.1.2/test/hello.lua)0
-rw-r--r--src/host/lua-5.1.4/test/life.lua (renamed from src/host/lua-5.1.2/test/life.lua)0
-rw-r--r--src/host/lua-5.1.4/test/luac.lua (renamed from src/host/lua-5.1.2/test/luac.lua)0
-rw-r--r--src/host/lua-5.1.4/test/printf.lua (renamed from src/host/lua-5.1.2/test/printf.lua)0
-rw-r--r--src/host/lua-5.1.4/test/readonly.lua (renamed from src/host/lua-5.1.2/test/readonly.lua)0
-rw-r--r--src/host/lua-5.1.4/test/sieve.lua (renamed from src/host/lua-5.1.2/test/sieve.lua)0
-rw-r--r--src/host/lua-5.1.4/test/sort.lua (renamed from src/host/lua-5.1.2/test/sort.lua)0
-rw-r--r--src/host/lua-5.1.4/test/table.lua (renamed from src/host/lua-5.1.2/test/table.lua)0
-rw-r--r--src/host/lua-5.1.4/test/trace-calls.lua (renamed from src/host/lua-5.1.2/test/trace-calls.lua)0
-rw-r--r--src/host/lua-5.1.4/test/trace-globals.lua (renamed from src/host/lua-5.1.2/test/trace-globals.lua)0
-rw-r--r--src/host/lua-5.1.4/test/xd.lua (renamed from src/host/lua-5.1.2/test/xd.lua)0
106 files changed, 1087 insertions, 672 deletions
diff --git a/premake4.lua b/premake4.lua
index 92302be..90a5264 100644
--- a/premake4.lua
+++ b/premake4.lua
@@ -39,7 +39,7 @@ end
language "C"
kind "ConsoleApp"
flags { "No64BitChecks", "ExtraWarnings", "FatalWarnings" }
- includedirs { "src/host/lua-5.1.2/src" }
+ includedirs { "src/host/lua-5.1.4/src" }
location ( _OPTIONS["to"] )
files
@@ -51,11 +51,11 @@ end
excludes
{
"src/premake.lua",
- "src/host/lua-5.1.2/src/lua.c",
- "src/host/lua-5.1.2/src/luac.c",
- "src/host/lua-5.1.2/src/print.c",
- "src/host/lua-5.1.2/**.lua",
- "src/host/lua-5.1.2/etc/*.c"
+ "src/host/lua-5.1.4/src/lua.c",
+ "src/host/lua-5.1.4/src/luac.c",
+ "src/host/lua-5.1.4/src/print.c",
+ "src/host/lua-5.1.4/**.lua",
+ "src/host/lua-5.1.4/etc/*.c"
}
configuration "Debug"
diff --git a/src/host/lua-5.1.2/PREMAKE_CHANGES.txt b/src/host/lua-5.1.2/PREMAKE_CHANGES.txt
deleted file mode 100644
index ca2f322..0000000
--- a/src/host/lua-5.1.2/PREMAKE_CHANGES.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-I added #pragmas to the end of luaconf.h in order to suppress
-some (harmless) VS.NET warning messages.
diff --git a/src/host/lua-5.1.2/etc/luavs.bat b/src/host/lua-5.1.2/etc/luavs.bat
deleted file mode 100644
index 6b1120b..0000000
--- a/src/host/lua-5.1.2/etc/luavs.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-rem script to build Lua under "Visual Studio .NET Command Prompt".
-rem do not run it from this directory, run it from the toplevel: etc\luavs.bat
-rem it creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src.
-
-cd src
-cl /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DLUA_BUILD_AS_DLL l*.c
-del lua.obj luac.obj
-link /DLL /out:lua51.dll l*.obj
-cl /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DLUA_BUILD_AS_DLL lua.c
-link /out:lua.exe lua.obj lua51.lib
-cl /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE l*.c print.c
-del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj loslib.obj ltablib.obj lstrlib.obj loadlib.obj
-link /out:luac.exe *.obj
-del *.obj
-cd ..
diff --git a/src/host/lua-5.1.2/COPYRIGHT b/src/host/lua-5.1.4/COPYRIGHT
index a54a16e..3a53e74 100644
--- a/src/host/lua-5.1.2/COPYRIGHT
+++ b/src/host/lua-5.1.4/COPYRIGHT
@@ -9,7 +9,7 @@ For details and rationale, see http://www.lua.org/license.html .
===============================================================================
-Copyright (C) 1994-2007 Lua.org, PUC-Rio.
+Copyright (C) 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/host/lua-5.1.2/HISTORY b/src/host/lua-5.1.4/HISTORY
index ce0c95b..ce0c95b 100644
--- a/src/host/lua-5.1.2/HISTORY
+++ b/src/host/lua-5.1.4/HISTORY
diff --git a/src/host/lua-5.1.2/INSTALL b/src/host/lua-5.1.4/INSTALL
index 17eb8ae..17eb8ae 100644
--- a/src/host/lua-5.1.2/INSTALL
+++ b/src/host/lua-5.1.4/INSTALL
diff --git a/src/host/lua-5.1.2/Makefile b/src/host/lua-5.1.4/Makefile
index c5ec666..6e78f66 100644
--- a/src/host/lua-5.1.2/Makefile
+++ b/src/host/lua-5.1.4/Makefile
@@ -7,32 +7,32 @@
# Your platform. See PLATS for possible values.
PLAT= none
-# Where to install. The installation starts in the src directory, so take care
-# if INSTALL_TOP is not an absolute path. (Man pages are installed from the
-# doc directory.) You may want to make these paths consistent with LUA_ROOT,
-# LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
-#
+# Where to install. The installation starts in the src and doc directories,
+# so take care if INSTALL_TOP is not an absolute path.
INSTALL_TOP= /usr/local
INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
INSTALL_MAN= $(INSTALL_TOP)/man/man1
+#
+# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
+# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
-# How to install. You may prefer "install" instead of "cp" if you have it.
-# To remove debug information from binaries, use "install -s" in INSTALL_EXEC.
+# How to install. If your install program does not support "-p", then you
+# may have to run ranlib on the installed liblua.a (do "make ranlib").
+INSTALL= install -p
+INSTALL_EXEC= $(INSTALL) -m 0755
+INSTALL_DATA= $(INSTALL) -m 0644
#
-INSTALL_EXEC= $(CP)
-INSTALL_DATA= $(CP)
-#INSTALL_EXEC= $(INSTALL) -m 0755
-#INSTALL_DATA= $(INSTALL) -m 0644
+# If you don't have install you can use cp instead.
+# INSTALL= cp -p
+# INSTALL_EXEC= $(INSTALL)
+# INSTALL_DATA= $(INSTALL)
# Utilities.
-CP= cp
-FIND= find
-INSTALL= install
-MKDIR= mkdir
+MKDIR= mkdir -p
RANLIB= ranlib
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
@@ -48,7 +48,7 @@ TO_MAN= lua.1 luac.1
# Lua version and release.
V= 5.1
-R= 5.1.2
+R= 5.1.4
all: $(PLAT)
@@ -59,15 +59,17 @@ test: dummy
src/lua test/hello.lua
install: dummy
- cd src && $(MKDIR) -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+ cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
-# $(RANLIB) $(INSTALL_LIB)/$(TO_LIB)
+
+ranlib:
+ cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
local:
- $(MAKE) install INSTALL_TOP=.. INSTALL_EXEC="cp -p" INSTALL_DATA="cp -p"
+ $(MAKE) install INSTALL_TOP=..
none:
@echo "Please do"
diff --git a/src/host/lua-5.1.2/README b/src/host/lua-5.1.4/README
index 11b4dff..11b4dff 100644
--- a/src/host/lua-5.1.2/README
+++ b/src/host/lua-5.1.4/README
diff --git a/src/host/lua-5.1.2/doc/amazon.gif b/src/host/lua-5.1.4/doc/amazon.gif
index f2586d5..f2586d5 100644
--- a/src/host/lua-5.1.2/doc/amazon.gif
+++ b/src/host/lua-5.1.4/doc/amazon.gif
Binary files differ
diff --git a/src/host/lua-5.1.2/doc/contents.html b/src/host/lua-5.1.4/doc/contents.html
index 01b069f..8e58e18 100644
--- a/src/host/lua-5.1.2/doc/contents.html
+++ b/src/host/lua-5.1.4/doc/contents.html
@@ -1,7 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
-<TITLE>Lua 5.1 reference manual - contents</TITLE>
+<TITLE>Lua 5.1 Reference Manual - contents</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
+<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
<STYLE TYPE="text/css">
ul {
list-style-type: none ;
@@ -33,21 +35,28 @@ This is an online version of
</BLOCKQUOTE>
<P>
-Buy a paper copy and
+Buy a copy of this book and
<A HREF="http://www.lua.org/donations.html">help to support</A>
the Lua project.
<P>
+The reference manual is the official definition of the Lua language.
+For a complete introduction to Lua programming, see the book
+<A HREF="http://www.lua.org/docs.html#books">Programming in Lua</A>.
+<P>
+
<A HREF="manual.html">start</A>
&middot;
<A HREF="#contents">contents</A>
&middot;
<A HREF="#index">index</A>
&middot;
-<A HREF="http://www.lua.org/manual/5.1/errata.html">errata</A>
+<A HREF="http://www.lua.org/manual/5.1/pt/">português</A>
+&middot;
+<A HREF="http://www.lua.org/manual/5.1/es/">español</A>
<HR>
<SMALL>
-Copyright &copy; 2006-2007 Lua.org, PUC-Rio.
+Copyright &copy; 2006-2008 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html#5">Lua license</a>.
</SMALL>
@@ -55,7 +64,8 @@ Freely available under the terms of the
<H2><A NAME="contents">Contents</A></H2>
<UL style="padding: 0">
-<LI><A HREF="manual.html#1">1 - Introduction</A>
+<LI><A HREF="manual.html">1 - Introduction</A>
+<P>
<LI><A HREF="manual.html#2">2 - The Language</A>
<UL>
<LI><A HREF="manual.html#2.1">2.1 - Lexical Conventions</A>
@@ -97,6 +107,7 @@ Freely available under the terms of the
</UL>
<LI><A HREF="manual.html#2.11">2.11 - Coroutines</A>
</UL>
+<P>
<LI><A HREF="manual.html#3">3 - The Application Program Interface</A>
<UL>
<LI><A HREF="manual.html#3.1">3.1 - The Stack</A>
@@ -108,10 +119,12 @@ Freely available under the terms of the
<LI><A HREF="manual.html#3.7">3.7 - Functions and Types</A>
<LI><A HREF="manual.html#3.8">3.8 - The Debug Interface</A>
</UL>
+<P>
<LI><A HREF="manual.html#4">4 - The Auxiliary Library</A>
<UL>
<LI><A HREF="manual.html#4.1">4.1 - Functions and Types</A>
</UL>
+<P>
<LI><A HREF="manual.html#5">5 - Standard Libraries</A>
<UL>
<LI><A HREF="manual.html#5.1">5.1 - Basic Functions</A>
@@ -127,13 +140,16 @@ Freely available under the terms of the
<LI><A HREF="manual.html#5.8">5.8 - Operating System Facilities</A>
<LI><A HREF="manual.html#5.9">5.9 - The Debug Library</A>
</UL>
+<P>
<LI><A HREF="manual.html#6">6 - Lua Stand-alone</A>
+<P>
<LI><A HREF="manual.html#7">7 - Incompatibilities with the Previous Version</A>
<UL>
<LI><A HREF="manual.html#7.1">7.1 - Changes in the Language</A>
<LI><A HREF="manual.html#7.2">7.2 - Changes in the Libraries</A>
<LI><A HREF="manual.html#7.3">7.3 - Changes in the API</A>
</UL>
+<P>
<LI><A HREF="manual.html#8">8 - The Complete Syntax of Lua</A>
</UL>
@@ -171,16 +187,16 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-type">type</A><BR>
<A HREF="manual.html#pdf-unpack">unpack</A><BR>
<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
+<P>
-</TD>
-<TD>
-<H3>&nbsp;</H3>
<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
<A HREF="manual.html#pdf-coroutine.resume">coroutine.resume</A><BR>
<A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR>
<A HREF="manual.html#pdf-coroutine.status">coroutine.status</A><BR>
<A HREF="manual.html#pdf-coroutine.wrap">coroutine.wrap</A><BR>
<A HREF="manual.html#pdf-coroutine.yield">coroutine.yield</A><BR>
+<P>
+
<A HREF="manual.html#pdf-debug.debug">debug.debug</A><BR>
<A HREF="manual.html#pdf-debug.getfenv">debug.getfenv</A><BR>
<A HREF="manual.html#pdf-debug.gethook">debug.gethook</A><BR>
@@ -195,6 +211,10 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-debug.setmetatable">debug.setmetatable</A><BR>
<A HREF="manual.html#pdf-debug.setupvalue">debug.setupvalue</A><BR>
<A HREF="manual.html#pdf-debug.traceback">debug.traceback</A><BR>
+
+</TD>
+<TD>
+<H3>&nbsp;</H3>
<A HREF="manual.html#pdf-file:close">file:close</A><BR>
<A HREF="manual.html#pdf-file:flush">file:flush</A><BR>
<A HREF="manual.html#pdf-file:lines">file:lines</A><BR>
@@ -202,6 +222,8 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-file:seek">file:seek</A><BR>
<A HREF="manual.html#pdf-file:setvbuf">file:setvbuf</A><BR>
<A HREF="manual.html#pdf-file:write">file:write</A><BR>
+<P>
+
<A HREF="manual.html#pdf-io.close">io.close</A><BR>
<A HREF="manual.html#pdf-io.flush">io.flush</A><BR>
<A HREF="manual.html#pdf-io.input">io.input</A><BR>
@@ -210,17 +232,22 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-io.output">io.output</A><BR>
<A HREF="manual.html#pdf-io.popen">io.popen</A><BR>
<A HREF="manual.html#pdf-io.read">io.read</A><BR>
+<A HREF="manual.html#pdf-io.stderr">io.stderr</A><BR>
+<A HREF="manual.html#pdf-io.stdin">io.stdin</A><BR>
+<A HREF="manual.html#pdf-io.stdout">io.stdout</A><BR>
<A HREF="manual.html#pdf-io.tmpfile">io.tmpfile</A><BR>
<A HREF="manual.html#pdf-io.type">io.type</A><BR>
<A HREF="manual.html#pdf-io.write">io.write</A><BR>
+<P>
+
<A HREF="manual.html#pdf-math.abs">math.abs</A><BR>
<A HREF="manual.html#pdf-math.acos">math.acos</A><BR>
<A HREF="manual.html#pdf-math.asin">math.asin</A><BR>
-<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
+<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
<A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>
-<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
+<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
<A HREF="manual.html#pdf-math.deg">math.deg</A><BR>
<A HREF="manual.html#pdf-math.exp">math.exp</A><BR>
<A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
@@ -228,8 +255,8 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
<A HREF="manual.html#pdf-math.huge">math.huge</A><BR>
<A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>
-<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
<A HREF="manual.html#pdf-math.log">math.log</A><BR>
+<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
<A HREF="manual.html#pdf-math.max">math.max</A><BR>
<A HREF="manual.html#pdf-math.min">math.min</A><BR>
<A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
@@ -238,11 +265,13 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
<A HREF="manual.html#pdf-math.random">math.random</A><BR>
<A HREF="manual.html#pdf-math.randomseed">math.randomseed</A><BR>
-<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
+<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
<A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
-<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
+<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
+<P>
+
<A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
<A HREF="manual.html#pdf-os.date">os.date</A><BR>
<A HREF="manual.html#pdf-os.difftime">os.difftime</A><BR>
@@ -254,12 +283,17 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-os.setlocale">os.setlocale</A><BR>
<A HREF="manual.html#pdf-os.time">os.time</A><BR>
<A HREF="manual.html#pdf-os.tmpname">os.tmpname</A><BR>
+<P>
+
<A HREF="manual.html#pdf-package.cpath">package.cpath</A><BR>
<A HREF="manual.html#pdf-package.loaded">package.loaded</A><BR>
+<A HREF="manual.html#pdf-package.loaders">package.loaders</A><BR>
<A HREF="manual.html#pdf-package.loadlib">package.loadlib</A><BR>
<A HREF="manual.html#pdf-package.path">package.path</A><BR>
<A HREF="manual.html#pdf-package.preload">package.preload</A><BR>
<A HREF="manual.html#pdf-package.seeall">package.seeall</A><BR>
+<P>
+
<A HREF="manual.html#pdf-string.byte">string.byte</A><BR>
<A HREF="manual.html#pdf-string.char">string.char</A><BR>
<A HREF="manual.html#pdf-string.dump">string.dump</A><BR>
@@ -274,6 +308,8 @@ Freely available under the terms of the
<A HREF="manual.html#pdf-string.reverse">string.reverse</A><BR>
<A HREF="manual.html#pdf-string.sub">string.sub</A><BR>
<A HREF="manual.html#pdf-string.upper">string.upper</A><BR>
+<P>
+
<A HREF="manual.html#pdf-table.concat">table.concat</A><BR>
<A HREF="manual.html#pdf-table.insert">table.insert</A><BR>
<A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR>
@@ -292,6 +328,8 @@ 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_Writer">lua_Writer</A><BR>
+<P>
+
<A HREF="manual.html#lua_atpanic">lua_atpanic</A><BR>
<A HREF="manual.html#lua_call">lua_call</A><BR>
<A HREF="manual.html#lua_checkstack">lua_checkstack</A><BR>
@@ -323,6 +361,8 @@ Freely available under the terms of the
<A HREF="manual.html#lua_isfunction">lua_isfunction</A><BR>
<A HREF="manual.html#lua_islightuserdata">lua_islightuserdata</A><BR>
<A HREF="manual.html#lua_isnil">lua_isnil</A><BR>
+<A HREF="manual.html#lua_isnone">lua_isnone</A><BR>
+<A HREF="manual.html#lua_isnoneornil">lua_isnoneornil</A><BR>
<A HREF="manual.html#lua_isnumber">lua_isnumber</A><BR>
<A HREF="manual.html#lua_isstring">lua_isstring</A><BR>
<A HREF="manual.html#lua_istable">lua_istable</A><BR>
@@ -344,6 +384,7 @@ Freely available under the terms of the
<A HREF="manual.html#lua_pushfstring">lua_pushfstring</A><BR>
<A HREF="manual.html#lua_pushinteger">lua_pushinteger</A><BR>
<A HREF="manual.html#lua_pushlightuserdata">lua_pushlightuserdata</A><BR>
+<A HREF="manual.html#lua_pushliteral">lua_pushliteral</A><BR>
<A HREF="manual.html#lua_pushlstring">lua_pushlstring</A><BR>
<A HREF="manual.html#lua_pushnil">lua_pushnil</A><BR>
<A HREF="manual.html#lua_pushnumber">lua_pushnumber</A><BR>
@@ -391,6 +432,8 @@ Freely available under the terms of the
<H3>auxiliary library</H3>
<A HREF="manual.html#luaL_Buffer">luaL_Buffer</A><BR>
<A HREF="manual.html#luaL_Reg">luaL_Reg</A><BR>
+<P>
+
<A HREF="manual.html#luaL_addchar">luaL_addchar</A><BR>
<A HREF="manual.html#luaL_addlstring">luaL_addlstring</A><BR>
<A HREF="manual.html#luaL_addsize">luaL_addsize</A><BR>
@@ -446,10 +489,10 @@ Freely available under the terms of the
<HR>
<SMALL>
Last update:
-Fri Mar 23 08:33:19 BRT 2007
+Sat Jan 19 13:24:29 BRST 2008
</SMALL>
<!--
-Last change: minor edit
+Last change: revised for Lua 5.1.3
-->
</BODY>
diff --git a/src/host/lua-5.1.2/doc/cover.png b/src/host/lua-5.1.4/doc/cover.png
index 2dbb198..2dbb198 100644
--- a/src/host/lua-5.1.2/doc/cover.png
+++ b/src/host/lua-5.1.4/doc/cover.png
Binary files differ
diff --git a/src/host/lua-5.1.2/doc/logo.gif b/src/host/lua-5.1.4/doc/logo.gif
index 2f5e4ac..2f5e4ac 100644
--- a/src/host/lua-5.1.2/doc/logo.gif
+++ b/src/host/lua-5.1.4/doc/logo.gif
Binary files differ
diff --git a/src/host/lua-5.1.2/doc/lua.1 b/src/host/lua-5.1.4/doc/lua.1
index 24809cc..24809cc 100644
--- a/src/host/lua-5.1.2/doc/lua.1
+++ b/src/host/lua-5.1.4/doc/lua.1
diff --git a/src/host/lua-5.1.2/doc/lua.css b/src/host/lua-5.1.4/doc/lua.css
index 039cf11..039cf11 100644
--- a/src/host/lua-5.1.2/doc/lua.css
+++ b/src/host/lua-5.1.4/doc/lua.css
diff --git a/src/host/lua-5.1.2/doc/lua.html b/src/host/lua-5.1.4/doc/lua.html
index 1d435ab..1d435ab 100644
--- a/src/host/lua-5.1.2/doc/lua.html
+++ b/src/host/lua-5.1.4/doc/lua.html
diff --git a/src/host/lua-5.1.2/doc/luac.1 b/src/host/lua-5.1.4/doc/luac.1
index d814678..d814678 100644
--- a/src/host/lua-5.1.2/doc/luac.1
+++ b/src/host/lua-5.1.4/doc/luac.1
diff --git a/src/host/lua-5.1.2/doc/luac.html b/src/host/lua-5.1.4/doc/luac.html
index 179ffe8..179ffe8 100644
--- a/src/host/lua-5.1.2/doc/luac.html
+++ b/src/host/lua-5.1.4/doc/luac.html
diff --git a/src/host/lua-5.1.2/doc/manual.css b/src/host/lua-5.1.4/doc/manual.css
index 93f1ab2..eed5afd 100644
--- a/src/host/lua-5.1.2/doc/manual.css
+++ b/src/host/lua-5.1.4/doc/manual.css
@@ -5,3 +5,9 @@ h3 code {
pre {
font-size: 105% ;
}
+
+span.apii {
+ float: right ;
+ font-family: inherit ;
+}
+
diff --git a/src/host/lua-5.1.2/doc/manual.html b/src/host/lua-5.1.4/doc/manual.html
index 6b137ff..f46f17c 100644
--- a/src/host/lua-5.1.2/doc/manual.html
+++ b/src/host/lua-5.1.4/doc/manual.html
@@ -1,10 +1,11 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Lua 5.1 Reference Manual</title>
-<link rel="stylesheet" href="lua.css">
-<link rel="stylesheet" href="manual.css">
+<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">
</head>
<body>
@@ -18,7 +19,7 @@ Lua 5.1 Reference Manual
by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
<p>
<small>
-Copyright &copy; 2006-2007 Lua.org, PUC-Rio.
+Copyright &copy; 2006-2008 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html#5">Lua license</a>.
</small>
@@ -32,6 +33,7 @@ Freely available under the terms of the
<!-- ====================================================================== -->
<p>
+<!-- $Id: manual.of,v 1.48 2008/08/18 15:24:20 roberto Exp $ -->
@@ -101,7 +103,8 @@ in which
Non-terminals are shown like non-terminal,
keywords are shown like <b>kword</b>,
and other terminal symbols are shown like `<b>=</b>&acute;.
-The complete syntax of Lua can be found at the end of this manual.
+The complete syntax of Lua can be found in <a href="#8">&sect;8</a>
+at the end of this manual.
@@ -137,7 +140,7 @@ Lua is a case-sensitive language:
<code>and</code> is a reserved word, but <code>And</code> and <code>AND</code>
are two different, valid names.
As a convention, names starting with an underscore followed by
-uppercase letters (such as <code>_VERSION</code>)
+uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>)
are reserved for internal global variables used by Lua.
@@ -167,26 +170,16 @@ and can contain the following C-like escape sequences:
and '<code>\'</code>' (apostrophe [single quote]).
Moreover, a backslash followed by a real newline
results in a newline in the string.
-A character in a string may also be specified by its numerical value
+A character in a string can also be specified by its numerical value
using the escape sequence <code>\<em>ddd</em></code>,
where <em>ddd</em> is a sequence of up to three decimal digits.
(Note that if a numerical escape is to be followed by a digit,
it must be expressed using exactly three digits.)
-Strings in Lua may contain any 8-bit value, including embedded zeros,
+Strings in Lua can contain any 8-bit value, including embedded zeros,
which can be specified as '<code>\0</code>'.
<p>
-To put a double (single) quote, a newline, a backslash,
-or an embedded zero
-inside a literal string enclosed by double (single) quotes
-you must use an escape sequence.
-Any other character may be directly inserted into the literal.
-(Some control characters may cause problems for the file system,
-but Lua has no problem with them.)
-
-
-<p>
Literal strings can also be defined using a long format
enclosed by <em>long brackets</em>.
We define an <em>opening long bracket of level <em>n</em></em> as an opening
@@ -199,10 +192,10 @@ A <em>closing long bracket</em> is defined similarly;
for instance, a closing long bracket of level&nbsp;4 is written as <code>]====]</code>.
A long string starts with an opening long bracket of any level and
ends at the first closing long bracket of the same level.
-Literals in this bracketed form may run for several lines,
+Literals in this bracketed form can run for several lines,
do not interpret any escape sequences,
and ignore long brackets of any other level.
-They may contain anything except a closing bracket of the proper level.
+They can contain anything except a closing bracket of the proper level.
<p>
@@ -212,7 +205,7 @@ the newline is not included in the string.
As an example, in a system using ASCII
(in which '<code>a</code>' is coded as&nbsp;97,
newline is coded as&nbsp;10, and '<code>1</code>' is coded as&nbsp;49),
-the five literals below denote the same string:
+the five literal strings below denote the same string:
<pre>
a = 'alo\n123"'
@@ -226,7 +219,7 @@ the five literals below denote the same string:
</pre>
<p>
-A <em>numerical constant</em> may be written with an optional decimal part
+A <em>numerical constant</em> can be written with an optional decimal part
and an optional decimal exponent.
Lua also accepts integer hexadecimal constants,
by prefixing them with <code>0x</code>.
@@ -285,7 +278,7 @@ see file <code>luaconf.h</code>.)
<em>String</em> represents arrays of characters.
Lua is 8-bit clean:
-strings may contain any 8-bit character,
+strings can contain any 8-bit character,
including embedded zeros ('<code>\0</code>') (see <a href="#2.1">&sect;2.1</a>).
@@ -324,7 +317,7 @@ but with any value (except <b>nil</b>).
Tables can be <em>heterogeneous</em>;
that is, they can contain values of all types (except <b>nil</b>).
Tables are the sole data structuring mechanism in Lua;
-they may be used to represent ordinary arrays,
+they can be used to represent ordinary arrays,
symbol tables, sets, records, graphs, trees, etc.
To represent records, Lua uses the field name as an index.
The language supports this representation by
@@ -338,8 +331,8 @@ Like indices,
the value of a table field can be of any type (except <b>nil</b>).
In particular,
because functions are first-class values,
-table fields may contain functions.
-Thus tables may also carry <em>methods</em> (see <a href="#2.5.9">&sect;2.5.9</a>).
+table fields can contain functions.
+Thus tables can also carry <em>methods</em> (see <a href="#2.5.9">&sect;2.5.9</a>).
<p>
@@ -474,7 +467,7 @@ We use them here only for explanatory purposes.)
Lua supports an almost conventional set of statements,
similar to those in Pascal or C.
This set includes
-assignment, control structures, function calls,
+assignments, control structures, function calls,
and variable declarations.
@@ -502,15 +495,15 @@ receive arguments, and return values.
<p>
-A chunk may be stored in a file or in a string inside the host program.
-When a chunk is executed, first it is pre-compiled into instructions for
-a virtual machine,
-and then the compiled code is executed
-by an interpreter for the virtual machine.
+A chunk can be stored in a file or in a string inside the host program.
+To execute a chunk,
+Lua first pre-compiles the chunk into instructions for a virtual machine,
+and then it executes the compiled code
+with an interpreter for the virtual machine.
<p>
-Chunks may also be pre-compiled into binary form;
+Chunks can also be pre-compiled into binary form;
see program <code>luac</code> for details.
Programs in source and compiled forms are interchangeable;
Lua automatically detects the file type and acts accordingly.
@@ -529,7 +522,7 @@ syntactically, a block is the same as a chunk:
</pre>
<p>
-A block may be explicitly delimited to produce a single statement:
+A block can be explicitly delimited to produce a single statement:
<pre>
stat ::= <b>do</b> block <b>end</b>
@@ -547,16 +540,16 @@ of another block (see <a href="#2.4.4">&sect;2.4.4</a>).
<h3>2.4.3 - <a name="2.4.3">Assignment</a></h3>
<p>
-Lua allows multiple assignment.
+Lua allows multiple assignments.
Therefore, the syntax for assignment
defines a list of variables on the left side
and a list of expressions on the right side.
The elements in both lists are separated by commas:
<pre>
- stat ::= varlist1 `<b>=</b>&acute; explist1
- varlist1 ::= var {`<b>,</b>&acute; var}
- explist1 ::= exp {`<b>,</b>&acute; exp}
+ stat ::= varlist `<b>=</b>&acute; explist
+ varlist ::= var {`<b>,</b>&acute; var}
+ explist ::= exp {`<b>,</b>&acute; exp}
</pre><p>
Expressions are discussed in <a href="#2.5">&sect;2.5</a>.
@@ -570,7 +563,7 @@ the excess values are thrown away.
If there are fewer values than needed,
the list is extended with as many <b>nil</b>'s as needed.
If the list of expressions ends with a function call,
-then all values returned by this call enter in the list of values,
+then all values returned by that call enter the list of values,
before the adjustment
(except when the call is enclosed in parentheses; see <a href="#2.5">&sect;2.5</a>).
@@ -592,7 +585,13 @@ Similarly, the line
<pre>
x, y = y, x
</pre><p>
-exchanges the values of <code>x</code> and <code>y</code>.
+exchanges the values of <code>x</code> and <code>y</code>,
+and
+
+<pre>
+ x, y, z = y, z, x
+</pre><p>
+cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>.
<p>
@@ -641,7 +640,7 @@ Lua also has a <b>for</b> statement, in two flavors (see <a href="#2.4.5">&sect;
<p>
The condition expression of a
-control structure may return any value.
+control structure can return any value.
Both <b>false</b> and <b>nil</b> are considered false.
All values different from <b>nil</b> and <b>false</b> are considered true
(in particular, the number 0 and the empty string are also true).
@@ -659,11 +658,11 @@ declared inside the loop block.
The <b>return</b> statement is used to return values
from a function or a chunk (which is just a function).
-Functions and chunks may return more than one value,
-so the syntax for the <b>return</b> statement is
+Functions and chunks can return more than one value,
+and so the syntax for the <b>return</b> statement is
<pre>
- stat ::= <b>return</b> [explist1]
+ stat ::= <b>return</b> [explist]
</pre>
<p>
@@ -742,7 +741,7 @@ They must all result in numbers.
<li>
<code><em>var</em></code>, <code><em>limit</em></code>, and <code><em>step</em></code> are invisible variables.
-The names are here for explanatory purposes only.
+The names shown here are for explanatory purposes only.
</li>
<li>
@@ -771,7 +770,7 @@ stopping when this new value is <b>nil</b>.
The generic <b>for</b> loop has the following syntax:
<pre>
- stat ::= <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b>
+ stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
namelist ::= Name {`<b>,</b>&acute; Name}
</pre><p>
A <b>for</b> statement like
@@ -839,11 +838,11 @@ Function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>.
<h3>2.4.7 - <a name="2.4.7">Local Declarations</a></h3><p>
-Local variables may be declared anywhere inside a block.
-The declaration may include an initial assignment:
+Local variables can be declared anywhere inside a block.
+The declaration can include an initial assignment:
<pre>
- stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist1]
+ stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist]
</pre><p>
If present, an initial assignment has the same semantics
of a multiple assignment (see <a href="#2.4.3">&sect;2.4.3</a>).
@@ -905,12 +904,12 @@ and the unary <em>length operator</em> (see <a href="#2.5.5">&sect;2.5.5</a>).
<p>
-Both function calls and vararg expressions may result in multiple values.
-If the expression is used as a statement (see <a href="#2.4.6">&sect;2.4.6</a>)
-(only possible for function calls),
+Both function calls and vararg expressions can result in multiple values.
+If an expression is used as a statement
+(only possible for function calls (see <a href="#2.4.6">&sect;2.4.6</a>)),
then its return list is adjusted to zero elements,
thus discarding all returned values.
-If the expression is used as the last (or the only) element
+If an expression is used as the last (or the only) element
of a list of expressions,
then no adjustment is made
(unless the call is enclosed in parentheses).
@@ -928,7 +927,7 @@ Here are some examples:
g(x, f()) -- g gets x plus all results from f()
a,b,c = f(), x -- f() is adjusted to 1 result (c gets nil)
a,b = ... -- a gets the first vararg parameter, b gets
- -- the second (both a and b may get nil if there
+ -- the second (both a and b can get nil if there
-- is no corresponding vararg parameter)
a,b,c = x, f() -- f() is adjusted to 2 results
@@ -942,7 +941,7 @@ Here are some examples:
</pre>
<p>
-An expression enclosed in parentheses always results in only one value.
+Any expression enclosed in parentheses always results in only one value.
Thus,
<code>(f(x,y,z))</code> is always a single value,
even if <code>f</code> returns several values.
@@ -1020,6 +1019,8 @@ Otherwise, if both arguments are strings,
then their values are compared according to the current locale.
Otherwise, Lua tries to call the "lt" or the "le"
metamethod (see <a href="#2.8">&sect;2.8</a>).
+A comparison <code>a &gt; b</code> is translated to <code>b &lt; a</code>
+and <code>a &gt;= b</code> is translated to <code>b &lt;= a</code>.
@@ -1057,7 +1058,7 @@ Here are some examples:
10 and 20 --&gt; 20
</pre><p>
(In this manual,
---> indicates the result of the preceding expression.)
+<code>--&gt;</code> indicates the result of the preceding expression.)
@@ -1087,13 +1088,13 @@ character is one byte).
The length of a table <code>t</code> is defined to be any
integer index <code>n</code>
such that <code>t[n]</code> is not <b>nil</b> and <code>t[n+1]</code> is <b>nil</b>;
-moreover, if <code>t[1]</code> is <b>nil</b>, <code>n</code> may be zero.
+moreover, if <code>t[1]</code> is <b>nil</b>, <code>n</code> can be zero.
For a regular array, with non-nil values from 1 to a given <code>n</code>,
its length is exactly that <code>n</code>,
the index of its last value.
If the array has "holes"
(that is, <b>nil</b> values between other non-nil values),
-then <code>#t</code> may be any of the indices that
+then <code>#t</code> can be any of the indices that
directly precedes a <b>nil</b> value
(that is, it may consider any such <b>nil</b> value as the end of
the array).
@@ -1129,7 +1130,7 @@ All other binary operators are left associative.
<h3>2.5.7 - <a name="2.5.7">Table Constructors</a></h3><p>
Table constructors are expressions that create tables.
Every time a constructor is evaluated, a new table is created.
-Constructors can be used to create empty tables,
+A constructor can be used to create an empty table
or to create a table and initialize some of its fields.
The general syntax for constructors is
@@ -1176,12 +1177,12 @@ and the expression is a function call or a vararg expression,
then all values returned by this expression enter the list consecutively
(see <a href="#2.5.8">&sect;2.5.8</a>).
To avoid this,
-enclose the function call (or the vararg expression)
+enclose the function call or the vararg expression
in parentheses (see <a href="#2.5">&sect;2.5</a>).
<p>
-The field list may have an optional trailing separator,
+The field list can have an optional trailing separator,
as a convenience for machine-generated code.
@@ -1221,7 +1222,7 @@ except that <code>v</code> is evaluated only once.
Arguments have the following syntax:
<pre>
- args ::= `<b>(</b>&acute; [explist1] `<b>)</b>&acute;
+ args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute;
args ::= tableconstructor
args ::= String
</pre><p>
@@ -1286,7 +1287,7 @@ The syntax for function definition is
<pre>
function ::= <b>function</b> funcbody
- funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
+ funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
</pre>
<p>
@@ -1346,8 +1347,8 @@ the function is <em>instantiated</em> (or <em>closed</em>).
This function instance (or <em>closure</em>)
is the final value of the expression.
Different instances of the same function
-may refer to different external local variables
-and may have different environment tables.
+can refer to different external local variables
+and can have different environment tables.
<p>
@@ -1355,7 +1356,7 @@ Parameters act as local variables that are
initialized with the argument values:
<pre>
- parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
+ parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
</pre><p>
When a function is called,
the list of arguments is adjusted to
@@ -1374,7 +1375,7 @@ or in the middle of a list of expressions,
then its return list is adjusted to one element.
If the expression is used as the last element of a list of expressions,
then no adjustment is made
-(unless the call is enclosed in parentheses).
+(unless that last expression is enclosed in parentheses).
<p>
@@ -1517,7 +1518,7 @@ you can use the <a href="#pdf-pcall"><code>pcall</code></a> function.
<h2>2.8 - <a name="2.8">Metatables</a></h2>
<p>
-Every value in Lua may have a <em>metatable</em>.
+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.
@@ -1546,22 +1547,22 @@ You can replace the metatable of tables
through the <a href="#pdf-setmetatable"><code>setmetatable</code></a>
function.
You cannot change the metatable of other types from Lua
-(except using the debug library);
+(except by using the debug library);
you must use the C&nbsp;API for that.
<p>
-Tables and userdata have individual metatables
-(although multiple tables and userdata can share their metatables);
-values of all other types share one single metatable per type.
-So, there is one single metatable for all numbers,
-and for all strings, etc.
+Tables and full userdata have individual metatables
+(although multiple tables and userdata can share their metatables).
+Values of all other types share one single metatable per type;
+that is, there is one single metatable for all numbers,
+one for all strings, etc.
<p>
-A metatable may control how an object behaves in arithmetic operations,
+A metatable controls how an object behaves in arithmetic operations,
order comparisons, concatenation, length operation, and indexing.
-A metatable can also define a function to be called when a userdata
+A metatable also can define a function to be called when a userdata
is garbage collected.
For each of these operations Lua associates a specific key
called an <em>event</em>.
@@ -1638,7 +1639,7 @@ the behavior of the <code>op1 + op2</code> is
local h = getbinhandler(op1, op2, "__add")
if h then
-- call the handler with both operands
- return h(op1, op2)
+ return (h(op1, op2))
else -- no handler available: default behavior
error(&middot;&middot;&middot;)
end
@@ -1695,7 +1696,7 @@ the unary <code>-</code> operation.
local h = metatable(op).__unm
if h then
-- call the handler with the operand
- return h(op)
+ return (h(op))
else -- no handler available: default behavior
error(&middot;&middot;&middot;)
end
@@ -1716,7 +1717,7 @@ the <code>..</code> (concatenation) operation.
else
local h = getbinhandler(op1, op2, "__concat")
if h then
- return h(op1, op2)
+ return (h(op1, op2))
else
error(&middot;&middot;&middot;)
end
@@ -1739,7 +1740,7 @@ the <code>#</code> operation.
local h = metatable(op).__len
if h then
-- call the handler with the operand
- return h(op)
+ return (h(op))
else -- no handler available: default behavior
error(&middot;&middot;&middot;)
end
@@ -1779,7 +1780,7 @@ The "eq" event is defined as follows:
-- try metamethod
local h = getcomphandler(op1, op2, "__eq")
if h then
- return h(op1, op2)
+ return (h(op1, op2))
else
return false
end
@@ -1801,9 +1802,9 @@ the <code>&lt;</code> operation.
else
local h = getcomphandler(op1, op2, "__lt")
if h then
- return h(op1, op2)
+ return (h(op1, op2))
else
- error(&middot;&middot;&middot;);
+ error(&middot;&middot;&middot;)
end
end
end
@@ -1824,13 +1825,13 @@ the <code>&lt;=</code> operation.
else
local h = getcomphandler(op1, op2, "__le")
if h then
- return h(op1, op2)
+ return (h(op1, op2))
else
h = getcomphandler(op1, op2, "__lt")
if h then
return not h(op2, op1)
else
- error(&middot;&middot;&middot;);
+ error(&middot;&middot;&middot;)
end
end
end
@@ -1857,12 +1858,12 @@ The indexing access <code>table[key]</code>.
else
h = metatable(table).__index
if h == nil then
- error(&middot;&middot;&middot;);
+ error(&middot;&middot;&middot;)
end
end
if type(h) == "function" then
- return h(table, key) -- call the handler
- else return h[key] -- or repeat operation on it
+ return (h(table, key)) -- call the handler
+ else return h[key] -- or repeat operation on it
end
end
</pre><p>
@@ -1883,11 +1884,11 @@ The indexing assignment <code>table[key] = value</code>.
else
h = metatable(table).__newindex
if h == nil then
- error(&middot;&middot;&middot;);
+ error(&middot;&middot;&middot;)
end
end
if type(h) == "function" then
- return h(table, key,value) -- call the handler
+ h(table, key,value) -- call the handler
else h[key] = value -- or repeat operation on it
end
end
@@ -1931,6 +1932,17 @@ multiple objects can share the same environment.
<p>
+Threads are created sharing the environment of the creating thread.
+Userdata and C&nbsp;functions are created sharing the environment
+of the creating C&nbsp;function.
+Non-nested Lua functions
+(created by <a href="#pdf-loadfile"><code>loadfile</code></a>, <a href="#pdf-loadstring"><code>loadstring</code></a> or <a href="#pdf-load"><code>load</code></a>)
+are created sharing the environment of the creating thread.
+Nested Lua functions are created sharing the environment of
+the creating Lua function.
+
+
+<p>
Environments associated with userdata have no meaning for Lua.
It is only a convenience feature for programmers to associate a table to
a userdata.
@@ -1939,23 +1951,22 @@ a userdata.
<p>
Environments associated with threads are called
<em>global environments</em>.
-They are used as the default environment for their threads and
-non-nested functions created by the thread
-(through <a href="#pdf-loadfile"><code>loadfile</code></a>, <a href="#pdf-loadstring"><code>loadstring</code></a> or <a href="#pdf-load"><code>load</code></a>)
+They are used as the default environment for threads and
+non-nested Lua functions created by the thread
and can be directly accessed by C&nbsp;code (see <a href="#3.3">&sect;3.3</a>).
<p>
-Environments associated with C&nbsp;functions can be directly
+The environment associated with a C&nbsp;function can be directly
accessed by C&nbsp;code (see <a href="#3.3">&sect;3.3</a>).
-They are used as the default environment for other C&nbsp;functions
-created by the function.
+It is used as the default environment for other C&nbsp;functions
+and userdata created by the function.
<p>
Environments associated with Lua functions are used to resolve
all accesses to global variables within the function (see <a href="#2.3">&sect;2.3</a>).
-They are used as the default environment for other Lua functions
+They are used as the default environment for nested Lua functions
created by the function.
@@ -1982,9 +1993,9 @@ nor about freeing it when the objects are no longer needed.
Lua manages memory automatically by running
a <em>garbage collector</em> from time to time
to collect all <em>dead objects</em>
-(that is, these objects that are no longer accessible from Lua).
-All objects in Lua are subject to automatic management:
-tables, userdata, functions, threads, and strings.
+(that is, objects that are no longer accessible from Lua).
+All memory used by Lua is subject to automatic management:
+tables, userdata, functions, threads, strings, etc.
<p>
@@ -1992,15 +2003,17 @@ Lua implements an incremental mark-and-sweep collector.
It uses two numbers to control its garbage-collection cycles:
the <em>garbage-collector pause</em> and
the <em>garbage-collector step multiplier</em>.
+Both use percentage points as units
+(so that a value of 100 means an internal value of 1).
<p>
The garbage-collector pause
controls how long the collector waits before starting a new cycle.
Larger values make the collector less aggressive.
-Values smaller than 1 mean the collector will not wait to
+Values smaller than 100 mean the collector will not wait to
start a new cycle.
-A value of 2 means that the collector waits for the total memory in use
+A value of 200 means that the collector waits for the total memory in use
to double before starting a new cycle.
@@ -2010,17 +2023,15 @@ controls the relative speed of the collector relative to
memory allocation.
Larger values make the collector more aggressive but also increase
the size of each incremental step.
-Values smaller than 1 make the collector too slow and
-may result in the collector never finishing a cycle.
-The default, 2, means that the collector runs at "twice"
+Values smaller than 100 make the collector too slow and
+can result in the collector never finishing a cycle.
+The default, 200, means that the collector runs at "twice"
the speed of memory allocation.
<p>
You can change these numbers by calling <a href="#lua_gc"><code>lua_gc</code></a> in C
or <a href="#pdf-collectgarbage"><code>collectgarbage</code></a> in Lua.
-Both get percentage points as arguments
-(so an argument of 100 means a real value of 1).
With these functions you can also control
the collector directly (e.g., stop and restart it).
@@ -2062,6 +2073,7 @@ order of their creation,
among those collected in that cycle.
That is, the first finalizer to be called is the one associated
with the userdata created last in the program.
+The userdata itself is freed only in the next garbage-collection cycle.
@@ -2096,7 +2108,7 @@ the values in the table are weak.
<p>
After you use a table as a metatable,
-you should not change the value of its field <code>__mode</code>.
+you should not change the value of its <code>__mode</code> field.
Otherwise, the weak behavior of the tables controlled by this
metatable is undefined.
@@ -2129,7 +2141,7 @@ it does not start the coroutine execution.
<p>
When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
passing as its first argument
-the thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
+a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
the coroutine starts its execution,
at the first line of its main function.
Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are passed on
@@ -2379,7 +2391,7 @@ The first value associated with a function is at position
<code>lua_upvalueindex(1)</code>, and so on.
Any access to <code>lua_upvalueindex(<em>n</em>)</code>,
where <em>n</em> is greater than the number of upvalues of the
-current function,
+current function (but not greater than 256),
produces an acceptable (but invalid) index.
@@ -2427,17 +2439,14 @@ any error jumps to the most recent active recover point.
<p>
-Almost any function in the API may raise an error,
+Most functions in the API can throw an error,
for instance due to a memory allocation error.
-The following functions run in protected mode
-(that is, they create a protected environment to run),
-so they never raise an error:
-<a href="#lua_newstate"><code>lua_newstate</code></a>, <a href="#lua_close"><code>lua_close</code></a>, <a href="#lua_load"><code>lua_load</code></a>,
-<a href="#lua_pcall"><code>lua_pcall</code></a>, and <a href="#lua_cpcall"><code>lua_cpcall</code></a>.
+The documentation for each function indicates whether
+it can throw errors.
<p>
-Inside a C&nbsp;function you can raise an error by calling <a href="#lua_error"><code>lua_error</code></a>.
+Inside a C&nbsp;function you can throw an error by calling <a href="#lua_error"><code>lua_error</code></a>.
@@ -2448,6 +2457,30 @@ Inside a C&nbsp;function you can raise an error by calling <a href="#lua_error">
<p>
Here we list all functions and types from the C&nbsp;API in
alphabetical order.
+Each function has an indicator like this:
+<span class="apii">[-o, +p, <em>x</em>]</span>
+
+
+<p>
+The first field, <code>o</code>,
+is how many elements the function pops from the stack.
+The second field, <code>p</code>,
+is how many elements the function pushes onto the stack.
+(Any function always pushes its results after popping its arguments.)
+A field in the form <code>x|y</code> means the function can push (or pop)
+<code>x</code> or <code>y</code> elements,
+depending on the situation;
+an interrogation mark '<code>?</code>' means that
+we cannot know how many elements the function pops/pushes
+by looking only at its arguments
+(e.g., they may depend on what is on the stack).
+The third field, <code>x</code>,
+tells whether the function may throw errors:
+'<code>-</code>' means the function never throws any error;
+'<code>m</code>' means the function may throw an error
+only due to not enough memory;
+'<code>e</code>' means the function may throw other kinds of errors;
+'<code>v</code>' means the function may throw an error on purpose.
@@ -2506,7 +2539,8 @@ ANSI&nbsp;C ensures both behaviors.
-<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3>
+<hr><h3><a name="lua_atpanic"><code>lua_atpanic</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);</pre>
<p>
@@ -2518,7 +2552,7 @@ If an error happens outside any protected environment,
Lua calls a <em>panic function</em>
and then calls <code>exit(EXIT_FAILURE)</code>,
thus exiting the host application.
-Your panic function may avoid this exit by
+Your panic function can avoid this exit by
never returning (e.g., doing a long jump).
@@ -2529,7 +2563,8 @@ The panic function can access the error message at the top of the stack.
-<hr><h3><a name="lua_call"><code>lua_call</code></a></h3>
+<hr><h3><a name="lua_call"><code>lua_call</code></a></h3><p>
+<span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span>
<pre>void lua_call (lua_State *L, int nargs, int nresults);</pre>
<p>
@@ -2562,7 +2597,7 @@ Any error inside the called function is propagated upwards
<p>
-The following example shows how the host program may do the
+The following example shows how the host program can do the
equivalent to this Lua code:
<pre>
@@ -2639,7 +2674,8 @@ of numerical arguments and returns their average and sum:
-<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3>
+<hr><h3><a name="lua_checkstack"><code>lua_checkstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>int lua_checkstack (lua_State *L, int extra);</pre>
<p>
@@ -2653,7 +2689,8 @@ it is left unchanged.
-<hr><h3><a name="lua_close"><code>lua_close</code></a></h3>
+<hr><h3><a name="lua_close"><code>lua_close</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void lua_close (lua_State *L);</pre>
<p>
@@ -2671,23 +2708,25 @@ to avoid growing too large.
-<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3>
+<hr><h3><a name="lua_concat"><code>lua_concat</code></a></h3><p>
+<span class="apii">[-n, +1, <em>e</em>]</span>
<pre>void lua_concat (lua_State *L, int n);</pre>
<p>
Concatenates the <code>n</code> values at the top of the stack,
pops them, and leaves the result at the top.
-If <code>n</code>&nbsp;is&nbsp;1, the result is the single string on the stack
+If <code>n</code>&nbsp;is&nbsp;1, the result is the single value on the stack
(that is, the function does nothing);
if <code>n</code> is 0, the result is the empty string.
-Concatenation is done following the usual semantics of Lua
+Concatenation is performed following the usual semantics of Lua
(see <a href="#2.5.4">&sect;2.5.4</a>).
-<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3>
+<hr><h3><a name="lua_cpcall"><code>lua_cpcall</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
<pre>int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);</pre>
<p>
@@ -2704,7 +2743,8 @@ All values returned by <code>func</code> are discarded.
-<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3>
+<hr><h3><a name="lua_createtable"><code>lua_createtable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void lua_createtable (lua_State *L, int narr, int nrec);</pre>
<p>
@@ -2719,7 +2759,8 @@ Otherwise you can use the function <a href="#lua_newtable"><code>lua_newtable</c
-<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3>
+<hr><h3><a name="lua_dump"><code>lua_dump</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>int lua_dump (lua_State *L, lua_Writer writer, void *data);</pre>
<p>
@@ -2747,7 +2788,8 @@ This function does not pop the Lua function from the stack.
-<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3>
+<hr><h3><a name="lua_equal"><code>lua_equal</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>int lua_equal (lua_State *L, int index1, int index2);</pre>
<p>
@@ -2762,7 +2804,8 @@ Also returns&nbsp;0 if any of the indices is non valid.
-<hr><h3><a name="lua_error"><code>lua_error</code></a></h3>
+<hr><h3><a name="lua_error"><code>lua_error</code></a></h3><p>
+<span class="apii">[-1, +0, <em>v</em>]</span>
<pre>int lua_error (lua_State *L);</pre>
<p>
@@ -2777,7 +2820,8 @@ and therefore never returns.
-<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3>
+<hr><h3><a name="lua_gc"><code>lua_gc</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>int lua_gc (lua_State *L, int what, int data);</pre>
<p>
@@ -2822,13 +2866,13 @@ garbage-collection cycle.
</li>
<li><b><code>LUA_GCSETPAUSE</code>:</b>
-sets <code>data</code>/100 as the new value
+sets <code>data</code> as the new value
for the <em>pause</em> of the collector (see <a href="#2.10">&sect;2.10</a>).
The function returns the previous value of the pause.
</li>
<li><b><code>LUA_GCSETSTEPMUL</code>:</b>
-sets <code>data</code>/100 as the new value for the <em>step multiplier</em> of
+sets <code>data</code> as the new value for the <em>step multiplier</em> of
the collector (see <a href="#2.10">&sect;2.10</a>).
The function returns the previous value of the step multiplier.
</li>
@@ -2838,7 +2882,8 @@ The function returns the previous value of the step multiplier.
-<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3>
+<hr><h3><a name="lua_getallocf"><code>lua_getallocf</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_Alloc lua_getallocf (lua_State *L, void **ud);</pre>
<p>
@@ -2850,7 +2895,8 @@ opaque pointer passed to <a href="#lua_newstate"><code>lua_newstate</code></a>.
-<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3>
+<hr><h3><a name="lua_getfenv"><code>lua_getfenv</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_getfenv (lua_State *L, int index);</pre>
<p>
@@ -2861,12 +2907,13 @@ the value at the given index.
-<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3>
+<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
+<span class="apii">[-0, +1, <em>e</em>]</span>
<pre>void lua_getfield (lua_State *L, int index, const char *k);</pre>
<p>
Pushes onto the stack the value <code>t[k]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>.
+where <code>t</code> is the value at the given valid index.
As in Lua, this function may trigger a metamethod
for the "index" event (see <a href="#2.8">&sect;2.8</a>).
@@ -2874,7 +2921,8 @@ for the "index" event (see <a href="#2.8">&sect;2.8</a>).
-<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3>
+<hr><h3><a name="lua_getglobal"><code>lua_getglobal</code></a></h3><p>
+<span class="apii">[-0, +1, <em>e</em>]</span>
<pre>void lua_getglobal (lua_State *L, const char *name);</pre>
<p>
@@ -2888,7 +2936,8 @@ It is defined as a macro:
-<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3>
+<hr><h3><a name="lua_getmetatable"><code>lua_getmetatable</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
<pre>int lua_getmetatable (lua_State *L, int index);</pre>
<p>
@@ -2902,12 +2951,13 @@ the function returns&nbsp;0 and pushes nothing on the stack.
-<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3>
+<hr><h3><a name="lua_gettable"><code>lua_gettable</code></a></h3><p>
+<span class="apii">[-1, +1, <em>e</em>]</span>
<pre>void lua_gettable (lua_State *L, int index);</pre>
<p>
Pushes onto the stack the value <code>t[k]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
+where <code>t</code> is the value at the given valid index
and <code>k</code> is the value at the top of the stack.
@@ -2921,7 +2971,8 @@ for the "index" event (see <a href="#2.8">&sect;2.8</a>).
-<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3>
+<hr><h3><a name="lua_gettop"><code>lua_gettop</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_gettop (lua_State *L);</pre>
<p>
@@ -2934,7 +2985,8 @@ this result is equal to the number of elements in the stack
-<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3>
+<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
+<span class="apii">[-1, +1, <em>-</em>]</span>
<pre>void lua_insert (lua_State *L, int index);</pre>
<p>
@@ -2963,7 +3015,8 @@ which is usually the largest signed integral type the machine handles
-<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3>
+<hr><h3><a name="lua_isboolean"><code>lua_isboolean</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isboolean (lua_State *L, int index);</pre>
<p>
@@ -2974,7 +3027,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3>
+<hr><h3><a name="lua_iscfunction"><code>lua_iscfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_iscfunction (lua_State *L, int index);</pre>
<p>
@@ -2985,7 +3039,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3>
+<hr><h3><a name="lua_isfunction"><code>lua_isfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isfunction (lua_State *L, int index);</pre>
<p>
@@ -2996,7 +3051,8 @@ Returns 1 if the value at the given acceptable index is a function
-<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3>
+<hr><h3><a name="lua_islightuserdata"><code>lua_islightuserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_islightuserdata (lua_State *L, int index);</pre>
<p>
@@ -3007,7 +3063,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3>
+<hr><h3><a name="lua_isnil"><code>lua_isnil</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isnil (lua_State *L, int index);</pre>
<p>
@@ -3018,11 +3075,12 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3>
+<hr><h3><a name="lua_isnone"><code>lua_isnone</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isnone (lua_State *L, int index);</pre>
<p>
-Returns 1 if the the given acceptable index is not valid
+Returns 1 if the given acceptable index is not valid
(that is, it refers to an element outside the current stack),
and 0&nbsp;otherwise.
@@ -3030,11 +3088,12 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3>
+<hr><h3><a name="lua_isnoneornil"><code>lua_isnoneornil</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isnoneornil (lua_State *L, int index);</pre>
<p>
-Returns 1 if the the given acceptable index is not valid
+Returns 1 if the given acceptable index is not valid
(that is, it refers to an element outside the current stack)
or if the value at this index is <b>nil</b>,
and 0&nbsp;otherwise.
@@ -3043,7 +3102,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3>
+<hr><h3><a name="lua_isnumber"><code>lua_isnumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isnumber (lua_State *L, int index);</pre>
<p>
@@ -3055,7 +3115,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3>
+<hr><h3><a name="lua_isstring"><code>lua_isstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isstring (lua_State *L, int index);</pre>
<p>
@@ -3067,7 +3128,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3>
+<hr><h3><a name="lua_istable"><code>lua_istable</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_istable (lua_State *L, int index);</pre>
<p>
@@ -3078,7 +3140,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3>
+<hr><h3><a name="lua_isthread"><code>lua_isthread</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isthread (lua_State *L, int index);</pre>
<p>
@@ -3089,7 +3152,8 @@ and 0&nbsp;otherwise.
-<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3>
+<hr><h3><a name="lua_isuserdata"><code>lua_isuserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_isuserdata (lua_State *L, int index);</pre>
<p>
@@ -3100,7 +3164,8 @@ Returns 1 if the value at the given acceptable index is a userdata
-<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3>
+<hr><h3><a name="lua_lessthan"><code>lua_lessthan</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>int lua_lessthan (lua_State *L, int index1, int index2);</pre>
<p>
@@ -3115,7 +3180,8 @@ Also returns&nbsp;0 if any of the indices is non valid.
-<hr><h3><a name="lua_load"><code>lua_load</code></a></h3>
+<hr><h3><a name="lua_load"><code>lua_load</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>int lua_load (lua_State *L,
lua_Reader reader,
void *data,
@@ -3165,7 +3231,8 @@ which is used for error messages and in debug information (see <a href="#3.8">&s
-<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3>
+<hr><h3><a name="lua_newstate"><code>lua_newstate</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_State *lua_newstate (lua_Alloc f, void *ud);</pre>
<p>
@@ -3181,7 +3248,8 @@ simply passes to the allocator in every call.
-<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3>
+<hr><h3><a name="lua_newtable"><code>lua_newtable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void lua_newtable (lua_State *L);</pre>
<p>
@@ -3192,7 +3260,8 @@ It is equivalent to <code>lua_createtable(L, 0, 0)</code>.
-<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3>
+<hr><h3><a name="lua_newthread"><code>lua_newthread</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>lua_State *lua_newthread (lua_State *L);</pre>
<p>
@@ -3212,7 +3281,8 @@ like any Lua object.
-<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3>
+<hr><h3><a name="lua_newuserdata"><code>lua_newuserdata</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void *lua_newuserdata (lua_State *L, size_t size);</pre>
<p>
@@ -3240,7 +3310,8 @@ Lua frees its corresponding memory.
-<hr><h3><a name="lua_next"><code>lua_next</code></a></h3>
+<hr><h3><a name="lua_next"><code>lua_next</code></a></h3><p>
+<span class="apii">[-1, +(2|0), <em>e</em>]</span>
<pre>int lua_next (lua_State *L, int index);</pre>
<p>
@@ -3295,7 +3366,8 @@ Lua to operate with another type for numbers (e.g., float or long).
-<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3>
+<hr><h3><a name="lua_objlen"><code>lua_objlen</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>size_t lua_objlen (lua_State *L, int index);</pre>
<p>
@@ -3310,7 +3382,8 @@ for other values, it is&nbsp;0.
-<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3>
+<hr><h3><a name="lua_pcall"><code>lua_pcall</code></a></h3><p>
+<span class="apii">[-(nargs + 1), +(nresults|1), <em>-</em>]</span>
<pre>int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);</pre>
<p>
@@ -3375,7 +3448,8 @@ error while running the error handler function.
-<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3>
+<hr><h3><a name="lua_pop"><code>lua_pop</code></a></h3><p>
+<span class="apii">[-n, +0, <em>-</em>]</span>
<pre>void lua_pop (lua_State *L, int n);</pre>
<p>
@@ -3385,7 +3459,8 @@ Pops <code>n</code> elements from the stack.
-<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3>
+<hr><h3><a name="lua_pushboolean"><code>lua_pushboolean</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushboolean (lua_State *L, int b);</pre>
<p>
@@ -3395,7 +3470,8 @@ Pushes a boolean value with value <code>b</code> onto the stack.
-<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3>
+<hr><h3><a name="lua_pushcclosure"><code>lua_pushcclosure</code></a></h3><p>
+<span class="apii">[-n, +1, <em>m</em>]</span>
<pre>void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);</pre>
<p>
@@ -3417,10 +3493,15 @@ associated with the function.
<a href="#lua_pushcclosure"><code>lua_pushcclosure</code></a> also pops these values from the stack.
+<p>
+The maximum value for <code>n</code> is 255.
+
+
-<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3>
+<hr><h3><a name="lua_pushcfunction"><code>lua_pushcfunction</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void lua_pushcfunction (lua_State *L, lua_CFunction f);</pre>
<p>
@@ -3446,7 +3527,8 @@ and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code><
-<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3>
+<hr><h3><a name="lua_pushfstring"><code>lua_pushfstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>const char *lua_pushfstring (lua_State *L, const char *fmt, ...);</pre>
<p>
@@ -3480,7 +3562,8 @@ The conversion specifiers can only be
-<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3>
+<hr><h3><a name="lua_pushinteger"><code>lua_pushinteger</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushinteger (lua_State *L, lua_Integer n);</pre>
<p>
@@ -3490,7 +3573,8 @@ Pushes a number with value <code>n</code> onto the stack.
-<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3>
+<hr><h3><a name="lua_pushlightuserdata"><code>lua_pushlightuserdata</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushlightuserdata (lua_State *L, void *p);</pre>
<p>
@@ -3510,7 +3594,21 @@ light userdata with the same C&nbsp;address.
-<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3>
+<hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
+<pre>void lua_pushliteral (lua_State *L, const char *s);</pre>
+
+<p>
+This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,
+but can be used only when <code>s</code> is a literal string.
+In these cases, it automatically provides the string length.
+
+
+
+
+
+<hr><h3><a name="lua_pushlstring"><code>lua_pushlstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void lua_pushlstring (lua_State *L, const char *s, size_t len);</pre>
<p>
@@ -3525,7 +3623,8 @@ The string can contain embedded zeros.
-<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3>
+<hr><h3><a name="lua_pushnil"><code>lua_pushnil</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushnil (lua_State *L);</pre>
<p>
@@ -3535,7 +3634,8 @@ Pushes a nil value onto the stack.
-<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3>
+<hr><h3><a name="lua_pushnumber"><code>lua_pushnumber</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushnumber (lua_State *L, lua_Number n);</pre>
<p>
@@ -3545,7 +3645,8 @@ Pushes a number with value <code>n</code> onto the stack.
-<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3>
+<hr><h3><a name="lua_pushstring"><code>lua_pushstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void lua_pushstring (lua_State *L, const char *s);</pre>
<p>
@@ -3561,7 +3662,8 @@ it is assumed to end at the first zero.
-<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3>
+<hr><h3><a name="lua_pushthread"><code>lua_pushthread</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>int lua_pushthread (lua_State *L);</pre>
<p>
@@ -3572,7 +3674,8 @@ Returns 1 if this thread is the main thread of its state.
-<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3>
+<hr><h3><a name="lua_pushvalue"><code>lua_pushvalue</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_pushvalue (lua_State *L, int index);</pre>
<p>
@@ -3583,7 +3686,8 @@ onto the stack.
-<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3>
+<hr><h3><a name="lua_pushvfstring"><code>lua_pushvfstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>const char *lua_pushvfstring (lua_State *L,
const char *fmt,
va_list argp);</pre>
@@ -3596,7 +3700,8 @@ instead of a variable number of arguments.
-<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3>
+<hr><h3><a name="lua_rawequal"><code>lua_rawequal</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_rawequal (lua_State *L, int index1, int index2);</pre>
<p>
@@ -3610,7 +3715,8 @@ Also returns&nbsp;0 if any of the indices are non valid.
-<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3>
+<hr><h3><a name="lua_rawget"><code>lua_rawget</code></a></h3><p>
+<span class="apii">[-1, +1, <em>-</em>]</span>
<pre>void lua_rawget (lua_State *L, int index);</pre>
<p>
@@ -3621,12 +3727,13 @@ Similar to <a href="#lua_gettable"><code>lua_gettable</code></a>, but does a raw
-<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3>
+<hr><h3><a name="lua_rawgeti"><code>lua_rawgeti</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void lua_rawgeti (lua_State *L, int index, int n);</pre>
<p>
Pushes onto the stack the value <code>t[n]</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>.
+where <code>t</code> is the value at the given valid index.
The access is raw;
that is, it does not invoke metamethods.
@@ -3634,7 +3741,8 @@ that is, it does not invoke metamethods.
-<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3>
+<hr><h3><a name="lua_rawset"><code>lua_rawset</code></a></h3><p>
+<span class="apii">[-2, +0, <em>m</em>]</span>
<pre>void lua_rawset (lua_State *L, int index);</pre>
<p>
@@ -3645,13 +3753,14 @@ Similar to <a href="#lua_settable"><code>lua_settable</code></a>, but does a raw
-<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3>
+<hr><h3><a name="lua_rawseti"><code>lua_rawseti</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
<pre>void lua_rawseti (lua_State *L, int index, int n);</pre>
<p>
Does the equivalent of <code>t[n] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
-and <code>v</code> is the value at the top of the stack,
+where <code>t</code> is the value at the given valid index
+and <code>v</code> is the value at the top of the stack.
<p>
@@ -3677,14 +3786,16 @@ The reader must return a pointer to a block of memory
with a new piece of the chunk
and set <code>size</code> to the block size.
The block must exist until the reader function is called again.
-To signal the end of the chunk, the reader must return <code>NULL</code>.
+To signal the end of the chunk,
+the reader must return <code>NULL</code> or set <code>size</code> to zero.
The reader function may return pieces of any size greater than zero.
-<hr><h3><a name="lua_register"><code>lua_register</code></a></h3>
+<hr><h3><a name="lua_register"><code>lua_register</code></a></h3><p>
+<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>void lua_register (lua_State *L,
const char *name,
lua_CFunction f);</pre>
@@ -3701,7 +3812,8 @@ It is defined as a macro:
-<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3>
+<hr><h3><a name="lua_remove"><code>lua_remove</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
<pre>void lua_remove (lua_State *L, int index);</pre>
<p>
@@ -3714,7 +3826,8 @@ because a pseudo-index is not an actual stack position.
-<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3>
+<hr><h3><a name="lua_replace"><code>lua_replace</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
<pre>void lua_replace (lua_State *L, int index);</pre>
<p>
@@ -3726,7 +3839,8 @@ without shifting any element
-<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3>
+<hr><h3><a name="lua_resume"><code>lua_resume</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
<pre>int lua_resume (lua_State *L, int narg);</pre>
<p>
@@ -3759,7 +3873,8 @@ and then call <a href="#lua_resume"><code>lua_resume</code></a>.
-<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3>
+<hr><h3><a name="lua_setallocf"><code>lua_setallocf</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);</pre>
<p>
@@ -3770,7 +3885,8 @@ with user data <code>ud</code>.
-<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3>
+<hr><h3><a name="lua_setfenv"><code>lua_setfenv</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
<pre>int lua_setfenv (lua_State *L, int index);</pre>
<p>
@@ -3785,13 +3901,14 @@ Otherwise it returns 1.
-<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3>
+<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
+<span class="apii">[-1, +0, <em>e</em>]</span>
<pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
<p>
Does the equivalent to <code>t[k] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>
-and <code>v</code> is the value at the top of the stack,
+where <code>t</code> is the value at the given valid index
+and <code>v</code> is the value at the top of the stack.
<p>
@@ -3803,7 +3920,8 @@ for the "newindex" event (see <a href="#2.8">&sect;2.8</a>).
-<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3>
+<hr><h3><a name="lua_setglobal"><code>lua_setglobal</code></a></h3><p>
+<span class="apii">[-1, +0, <em>e</em>]</span>
<pre>void lua_setglobal (lua_State *L, const char *name);</pre>
<p>
@@ -3818,7 +3936,8 @@ It is defined as a macro:
-<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3>
+<hr><h3><a name="lua_setmetatable"><code>lua_setmetatable</code></a></h3><p>
+<span class="apii">[-1, +0, <em>-</em>]</span>
<pre>int lua_setmetatable (lua_State *L, int index);</pre>
<p>
@@ -3830,12 +3949,13 @@ acceptable index.
-<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3>
+<hr><h3><a name="lua_settable"><code>lua_settable</code></a></h3><p>
+<span class="apii">[-2, +0, <em>e</em>]</span>
<pre>void lua_settable (lua_State *L, int index);</pre>
<p>
Does the equivalent to <code>t[k] = v</code>,
-where <code>t</code> is the value at the given valid index <code>index</code>,
+where <code>t</code> is the value at the given valid index,
<code>v</code> is the value at the top of the stack,
and <code>k</code> is the value just below the top.
@@ -3849,7 +3969,8 @@ for the "newindex" event (see <a href="#2.8">&sect;2.8</a>).
-<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3>
+<hr><h3><a name="lua_settop"><code>lua_settop</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
<pre>void lua_settop (lua_State *L, int index);</pre>
<p>
@@ -3882,7 +4003,8 @@ which creates a Lua state from scratch.
-<hr><h3><a name="lua_status"><code>lua_status</code></a></h3>
+<hr><h3><a name="lua_status"><code>lua_status</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_status (lua_State *L);</pre>
<p>
@@ -3898,7 +4020,8 @@ or <a name="pdf-LUA_YIELD"><code>LUA_YIELD</code></a> if the thread is suspended
-<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3>
+<hr><h3><a name="lua_toboolean"><code>lua_toboolean</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_toboolean (lua_State *L, int index);</pre>
<p>
@@ -3916,7 +4039,8 @@ use <a href="#lua_isboolean"><code>lua_isboolean</code></a> to test the value's
-<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3>
+<hr><h3><a name="lua_tocfunction"><code>lua_tocfunction</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_CFunction lua_tocfunction (lua_State *L, int index);</pre>
<p>
@@ -3928,8 +4052,9 @@ otherwise, returns <code>NULL</code>.
-<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3>
-<pre>lua_Integer lua_tointeger (lua_State *L, int idx);</pre>
+<hr><h3><a name="lua_tointeger"><code>lua_tointeger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>lua_Integer lua_tointeger (lua_State *L, int index);</pre>
<p>
Converts the Lua value at the given acceptable index
@@ -3947,7 +4072,8 @@ it is truncated in some non-specified way.
-<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3>
+<hr><h3><a name="lua_tolstring"><code>lua_tolstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>const char *lua_tolstring (lua_State *L, int index, size_t *len);</pre>
<p>
@@ -3968,7 +4094,7 @@ when <a href="#lua_tolstring"><code>lua_tolstring</code></a> is applied to keys
to a string inside the Lua state.
This string always has a zero ('<code>\0</code>')
after its last character (as in&nbsp;C),
-but may contain other zeros in its body.
+but can contain other zeros in its body.
Because Lua has garbage collection,
there is no guarantee that the pointer returned by <a href="#lua_tolstring"><code>lua_tolstring</code></a>
will be valid after the corresponding value is removed from the stack.
@@ -3977,7 +4103,8 @@ will be valid after the corresponding value is removed from the stack.
-<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3>
+<hr><h3><a name="lua_tonumber"><code>lua_tonumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_Number lua_tonumber (lua_State *L, int index);</pre>
<p>
@@ -3991,13 +4118,14 @@ otherwise, <a href="#lua_tonumber"><code>lua_tonumber</code></a> returns&nbsp;0.
-<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3>
+<hr><h3><a name="lua_topointer"><code>lua_topointer</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>const void *lua_topointer (lua_State *L, int index);</pre>
<p>
Converts the value at the given acceptable index to a generic
C&nbsp;pointer (<code>void*</code>).
-The value may be a userdata, a table, a thread, or a function;
+The value can be a userdata, a table, a thread, or a function;
otherwise, <a href="#lua_topointer"><code>lua_topointer</code></a> returns <code>NULL</code>.
Different objects will give different pointers.
There is no way to convert the pointer back to its original value.
@@ -4010,7 +4138,8 @@ Typically this function is used only for debug information.
-<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3>
+<hr><h3><a name="lua_tostring"><code>lua_tostring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>const char *lua_tostring (lua_State *L, int index);</pre>
<p>
@@ -4020,7 +4149,8 @@ Equivalent to <a href="#lua_tolstring"><code>lua_tolstring</code></a> with <code
-<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3>
+<hr><h3><a name="lua_tothread"><code>lua_tothread</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_State *lua_tothread (lua_State *L, int index);</pre>
<p>
@@ -4033,7 +4163,8 @@ otherwise, the function returns <code>NULL</code>.
-<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3>
+<hr><h3><a name="lua_touserdata"><code>lua_touserdata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void *lua_touserdata (lua_State *L, int index);</pre>
<p>
@@ -4047,7 +4178,8 @@ Otherwise, returns <code>NULL</code>.
-<hr><h3><a name="lua_type"><code>lua_type</code></a></h3>
+<hr><h3><a name="lua_type"><code>lua_type</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_type (lua_State *L, int index);</pre>
<p>
@@ -4071,7 +4203,8 @@ and
-<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3>
+<hr><h3><a name="lua_typename"><code>lua_typename</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>const char *lua_typename (lua_State *L, int tp);</pre>
<p>
@@ -4089,7 +4222,7 @@ which must be one the values returned by <a href="#lua_type"><code>lua_type</cod
void* ud);</pre>
<p>
-The writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
+The type of the writer function used by <a href="#lua_dump"><code>lua_dump</code></a>.
Every time it produces another piece of chunk,
<a href="#lua_dump"><code>lua_dump</code></a> calls the writer,
passing along the buffer to be written (<code>p</code>),
@@ -4107,7 +4240,8 @@ calling the writer again.
-<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3>
+<hr><h3><a name="lua_xmove"><code>lua_xmove</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
<pre>void lua_xmove (lua_State *from, lua_State *to, int n);</pre>
<p>
@@ -4122,7 +4256,8 @@ and pushes them onto the stack <code>to</code>.
-<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3>
+<hr><h3><a name="lua_yield"><code>lua_yield</code></a></h3><p>
+<span class="apii">[-?, +?, <em>-</em>]</span>
<pre>int lua_yield (lua_State *L, int nresults);</pre>
<p>
@@ -4228,8 +4363,8 @@ When no line information is available,
a reasonable name for the given function.
Because functions in Lua are first-class values,
they do not have a fixed name:
-some functions may be the value of multiple global variables,
-while others may be stored only in a table field.
+some functions can be the value of multiple global variables,
+while others can be stored only in a table field.
The <code>lua_getinfo</code> function checks how the function was
called to find a suitable name.
If it cannot find a name,
@@ -4254,7 +4389,8 @@ the number of upvalues of the function.
-<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3>
+<hr><h3><a name="lua_gethook"><code>lua_gethook</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_Hook lua_gethook (lua_State *L);</pre>
<p>
@@ -4264,7 +4400,8 @@ Returns the current hook function.
-<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3>
+<hr><h3><a name="lua_gethookcount"><code>lua_gethookcount</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_gethookcount (lua_State *L);</pre>
<p>
@@ -4274,7 +4411,8 @@ Returns the current hook count.
-<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3>
+<hr><h3><a name="lua_gethookmask"><code>lua_gethookmask</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_gethookmask (lua_State *L);</pre>
<p>
@@ -4284,7 +4422,8 @@ Returns the current hook mask.
-<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3>
+<hr><h3><a name="lua_getinfo"><code>lua_getinfo</code></a></h3><p>
+<span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>
<pre>int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);</pre>
<p>
@@ -4357,7 +4496,8 @@ This function returns 0 on error
-<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3>
+<hr><h3><a name="lua_getlocal"><code>lua_getlocal</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
<pre>const char *lua_getlocal (lua_State *L, lua_Debug *ar, int n);</pre>
<p>
@@ -4387,7 +4527,8 @@ the number of active local variables.
-<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3>
+<hr><h3><a name="lua_getstack"><code>lua_getstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_getstack (lua_State *L, int level, lua_Debug *ar);</pre>
<p>
@@ -4408,7 +4549,8 @@ it returns 0.
-<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3>
+<hr><h3><a name="lua_getupvalue"><code>lua_getupvalue</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>-</em>]</span>
<pre>const char *lua_getupvalue (lua_State *L, int funcindex, int n);</pre>
<p>
@@ -4452,7 +4594,7 @@ and <a name="pdf-LUA_HOOKCOUNT"><code>LUA_HOOKCOUNT</code></a>.
Moreover, for line events, the field <code>currentline</code> is also set.
To get the value of any other field in <code>ar</code>,
the hook must call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
-For return events, <code>event</code> may be <code>LUA_HOOKRET</code>,
+For return events, <code>event</code> can be <code>LUA_HOOKRET</code>,
the normal value, or <code>LUA_HOOKTAILRET</code>.
In the latter case, Lua is simulating a return from
a function that did a tail call;
@@ -4468,7 +4610,8 @@ this execution occurs without any calls to hooks.
-<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3>
+<hr><h3><a name="lua_sethook"><code>lua_sethook</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);</pre>
<p>
@@ -4519,7 +4662,8 @@ A hook is disabled by setting <code>mask</code> to zero.
-<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3>
+<hr><h3><a name="lua_setlocal"><code>lua_setlocal</code></a></h3><p>
+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
<pre>const char *lua_setlocal (lua_State *L, lua_Debug *ar, int n);</pre>
<p>
@@ -4540,7 +4684,8 @@ the number of active local variables.
-<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3>
+<hr><h3><a name="lua_setupvalue"><code>lua_setupvalue</code></a></h3><p>
+<span class="apii">[-(0|1), +0, <em>-</em>]</span>
<pre>const char *lua_setupvalue (lua_State *L, int funcindex, int n);</pre>
<p>
@@ -4590,7 +4735,7 @@ and so they provide nothing that cannot be done with this API.
Several functions in the auxiliary library are used to
check C&nbsp;function arguments.
Their names are always <code>luaL_check*</code> or <code>luaL_opt*</code>.
-All of these functions raise an error if the check is not satisfied.
+All of these functions throw an error if the check is not satisfied.
Because the error message is formatted for arguments
(e.g., "<code>bad argument #1</code>"),
you should not use these functions for other stack values.
@@ -4605,7 +4750,8 @@ in alphabetical order.
-<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3>
+<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
<p>
@@ -4616,7 +4762,8 @@ Adds the character <code>c</code> to the buffer <code>B</code>
-<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3>
+<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
<p>
@@ -4629,7 +4776,8 @@ The string may contain embedded zeros.
-<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3>
+<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
<p>
@@ -4641,7 +4789,8 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>).
-<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3>
+<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
<p>
@@ -4654,7 +4803,8 @@ The string may not contain embedded zeros.
-<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3>
+<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
<pre>void luaL_addvalue (luaL_Buffer *B);</pre>
<p>
@@ -4673,7 +4823,8 @@ which is the value to be added to the buffer.
-<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3>
+<hr><h3><a name="luaL_argcheck"><code>luaL_argcheck</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>void luaL_argcheck (lua_State *L,
int cond,
int narg,
@@ -4691,7 +4842,8 @@ where <code>func</code> is retrieved from the call stack:
-<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3>
+<hr><h3><a name="luaL_argerror"><code>luaL_argerror</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_argerror (lua_State *L, int narg, const char *extramsg);</pre>
<p>
@@ -4760,7 +4912,8 @@ plus the final string on its top.
-<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3>
+<hr><h3><a name="luaL_buffinit"><code>luaL_buffinit</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void luaL_buffinit (lua_State *L, luaL_Buffer *B);</pre>
<p>
@@ -4773,7 +4926,8 @@ the buffer must be declared as a variable
-<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3>
+<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>e</em>]</span>
<pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
<p>
@@ -4793,7 +4947,8 @@ this function returns 0 (without pushing any value on the stack).
-<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3>
+<hr><h3><a name="luaL_checkany"><code>luaL_checkany</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>void luaL_checkany (lua_State *L, int narg);</pre>
<p>
@@ -4804,7 +4959,8 @@ of any type (including <b>nil</b>) at position <code>narg</code>.
-<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3>
+<hr><h3><a name="luaL_checkint"><code>luaL_checkint</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_checkint (lua_State *L, int narg);</pre>
<p>
@@ -4815,7 +4971,8 @@ and returns this number cast to an <code>int</code>.
-<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3>
+<hr><h3><a name="luaL_checkinteger"><code>luaL_checkinteger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>lua_Integer luaL_checkinteger (lua_State *L, int narg);</pre>
<p>
@@ -4826,7 +4983,8 @@ and returns this number cast to a <a href="#lua_Integer"><code>lua_Integer</code
-<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3>
+<hr><h3><a name="luaL_checklong"><code>luaL_checklong</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>long luaL_checklong (lua_State *L, int narg);</pre>
<p>
@@ -4837,7 +4995,8 @@ and returns this number cast to a <code>long</code>.
-<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3>
+<hr><h3><a name="luaL_checklstring"><code>luaL_checklstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>const char *luaL_checklstring (lua_State *L, int narg, size_t *l);</pre>
<p>
@@ -4847,10 +5006,16 @@ if <code>l</code> is not <code>NULL</code> fills <code>*l</code>
with the string's length.
+<p>
+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
+so all conversions and caveats of that function apply here.
+
-<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3>
+
+<hr><h3><a name="luaL_checknumber"><code>luaL_checknumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>lua_Number luaL_checknumber (lua_State *L, int narg);</pre>
<p>
@@ -4861,7 +5026,8 @@ and returns this number.
-<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3>
+<hr><h3><a name="luaL_checkoption"><code>luaL_checkoption</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_checkoption (lua_State *L,
int narg,
const char *def,
@@ -4891,7 +5057,8 @@ to use strings instead of numbers to select options.)
-<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3>
+<hr><h3><a name="luaL_checkstack"><code>luaL_checkstack</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>void luaL_checkstack (lua_State *L, int sz, const char *msg);</pre>
<p>
@@ -4903,7 +5070,8 @@ raising an error if the stack cannot grow to that size.
-<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3>
+<hr><h3><a name="luaL_checkstring"><code>luaL_checkstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>const char *luaL_checkstring (lua_State *L, int narg);</pre>
<p>
@@ -4911,20 +5079,28 @@ Checks whether the function argument <code>narg</code> is a string
and returns this string.
+<p>
+This function uses <a href="#lua_tolstring"><code>lua_tolstring</code></a> to get its result,
+so all conversions and caveats of that function apply here.
-<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3>
+
+
+<hr><h3><a name="luaL_checktype"><code>luaL_checktype</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>void luaL_checktype (lua_State *L, int narg, int t);</pre>
<p>
Checks whether the function argument <code>narg</code> has type <code>t</code>.
+See <a href="#lua_type"><code>lua_type</code></a> for the encoding of types for <code>t</code>.
-<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3>
+<hr><h3><a name="luaL_checkudata"><code>luaL_checkudata</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>void *luaL_checkudata (lua_State *L, int narg, const char *tname);</pre>
<p>
@@ -4935,7 +5111,8 @@ of the type <code>tname</code> (see <a href="#luaL_newmetatable"><code>luaL_newm
-<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3>
+<hr><h3><a name="luaL_dofile"><code>luaL_dofile</code></a></h3><p>
+<span class="apii">[-0, +?, <em>m</em>]</span>
<pre>int luaL_dofile (lua_State *L, const char *filename);</pre>
<p>
@@ -4952,7 +5129,8 @@ or 1 in case of errors.
-<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3>
+<hr><h3><a name="luaL_dostring"><code>luaL_dostring</code></a></h3><p>
+<span class="apii">[-0, +?, <em>m</em>]</span>
<pre>int luaL_dostring (lua_State *L, const char *str);</pre>
<p>
@@ -4969,7 +5147,8 @@ or 1 in case of errors.
-<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3>
+<hr><h3><a name="luaL_error"><code>luaL_error</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_error (lua_State *L, const char *fmt, ...);</pre>
<p>
@@ -4991,7 +5170,8 @@ as <code>return luaL_error(<em>args</em>)</code>.
-<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3>
+<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
+<span class="apii">[-0, +(0|1), <em>m</em>]</span>
<pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
<p>
@@ -5005,7 +5185,8 @@ returns 0 and pushes nothing.
-<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3>
+<hr><h3><a name="luaL_getmetatable"><code>luaL_getmetatable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>-</em>]</span>
<pre>void luaL_getmetatable (lua_State *L, const char *tname);</pre>
<p>
@@ -5016,7 +5197,8 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code>
-<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3>
+<hr><h3><a name="luaL_gsub"><code>luaL_gsub</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>const char *luaL_gsub (lua_State *L,
const char *s,
const char *p,
@@ -5032,7 +5214,8 @@ Pushes the resulting string on the stack and returns it.
-<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3>
+<hr><h3><a name="luaL_loadbuffer"><code>luaL_loadbuffer</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>int luaL_loadbuffer (lua_State *L,
const char *buff,
size_t sz,
@@ -5053,7 +5236,8 @@ used for debug information and error messages.
-<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3>
+<hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>int luaL_loadfile (lua_State *L, const char *filename);</pre>
<p>
@@ -5079,7 +5263,8 @@ it does not run it.
-<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3>
+<hr><h3><a name="luaL_loadstring"><code>luaL_loadstring</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>int luaL_loadstring (lua_State *L, const char *s);</pre>
<p>
@@ -5100,7 +5285,8 @@ it does not run it.
-<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3>
+<hr><h3><a name="luaL_newmetatable"><code>luaL_newmetatable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>int luaL_newmetatable (lua_State *L, const char *tname);</pre>
<p>
@@ -5120,7 +5306,8 @@ with <code>tname</code> in the registry.
-<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3>
+<hr><h3><a name="luaL_newstate"><code>luaL_newstate</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>lua_State *luaL_newstate (void);</pre>
<p>
@@ -5140,7 +5327,8 @@ or <code>NULL</code> if there is a memory allocation error.
-<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3>
+<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
+<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void luaL_openlibs (lua_State *L);</pre>
<p>
@@ -5150,7 +5338,8 @@ Opens all standard Lua libraries into the given state.
-<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3>
+<hr><h3><a name="luaL_optint"><code>luaL_optint</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_optint (lua_State *L, int narg, int d);</pre>
<p>
@@ -5164,7 +5353,8 @@ Otherwise, raises an error.
-<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3>
+<hr><h3><a name="luaL_optinteger"><code>luaL_optinteger</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>lua_Integer luaL_optinteger (lua_State *L,
int narg,
lua_Integer d);</pre>
@@ -5180,7 +5370,8 @@ Otherwise, raises an error.
-<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3>
+<hr><h3><a name="luaL_optlong"><code>luaL_optlong</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>long luaL_optlong (lua_State *L, int narg, long d);</pre>
<p>
@@ -5194,7 +5385,8 @@ Otherwise, raises an error.
-<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3>
+<hr><h3><a name="luaL_optlstring"><code>luaL_optlstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>const char *luaL_optlstring (lua_State *L,
int narg,
const char *d,
@@ -5216,7 +5408,8 @@ fills the position <code>*l</code> with the results's length.
-<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3>
+<hr><h3><a name="luaL_optnumber"><code>luaL_optnumber</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);</pre>
<p>
@@ -5230,7 +5423,8 @@ Otherwise, raises an error.
-<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3>
+<hr><h3><a name="luaL_optstring"><code>luaL_optstring</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>const char *luaL_optstring (lua_State *L,
int narg,
const char *d);</pre>
@@ -5246,7 +5440,8 @@ Otherwise, raises an error.
-<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3>
+<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
<p>
@@ -5261,7 +5456,8 @@ it to the buffer.
-<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3>
+<hr><h3><a name="luaL_pushresult"><code>luaL_pushresult</code></a></h3><p>
+<span class="apii">[-?, +1, <em>m</em>]</span>
<pre>void luaL_pushresult (luaL_Buffer *B);</pre>
<p>
@@ -5272,7 +5468,8 @@ the top of the stack.
-<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3>
+<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
+<span class="apii">[-1, +0, <em>m</em>]</span>
<pre>int luaL_ref (lua_State *L, int t);</pre>
<p>
@@ -5318,7 +5515,8 @@ in which both <code>name</code> and <code>func</code> are <code>NULL</code>.
-<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3>
+<hr><h3><a name="luaL_register"><code>luaL_register</code></a></h3><p>
+<span class="apii">[-(0|1), +1, <em>m</em>]</span>
<pre>void luaL_register (lua_State *L,
const char *libname,
const luaL_Reg *l);</pre>
@@ -5352,17 +5550,19 @@ on the top of the stack.
-<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3>
-<pre>const char *luaL_typename (lua_State *L, int idx);</pre>
+<hr><h3><a name="luaL_typename"><code>luaL_typename</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>const char *luaL_typename (lua_State *L, int index);</pre>
<p>
-Returns the name of the type of the value at index <code>idx</code>.
+Returns the name of the type of the value at the given index.
-<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3>
+<hr><h3><a name="luaL_typerror"><code>luaL_typerror</code></a></h3><p>
+<span class="apii">[-0, +0, <em>v</em>]</span>
<pre>int luaL_typerror (lua_State *L, int narg, const char *tname);</pre>
<p>
@@ -5379,7 +5579,8 @@ and <code><em>rt</em></code> is the type name of the actual argument.
-<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3>
+<hr><h3><a name="luaL_unref"><code>luaL_unref</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
<pre>void luaL_unref (lua_State *L, int t, int ref);</pre>
<p>
@@ -5398,7 +5599,8 @@ If <code>ref</code> is <a href="#pdf-LUA_NOREF"><code>LUA_NOREF</code></a> or <a
-<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3>
+<hr><h3><a name="luaL_where"><code>luaL_where</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
<pre>void luaL_where (lua_State *L, int lvl);</pre>
<p>
@@ -5433,7 +5635,7 @@ Some of these functions provide essential services to the language
others provide access to "outside" services (e.g., I/O);
and others could be implemented in Lua itself,
but are quite useful or have critical performance requirements that
-deserve an implementation in C (e.g., <code>sort</code>).
+deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).
<p>
@@ -5443,7 +5645,7 @@ Currently, Lua has the following standard libraries:
<ul>
-<li>basic library;</li>
+<li>basic library,</li> which includes the coroutine sub-library;
<li>package library;</li>
@@ -5476,7 +5678,8 @@ it can open them individually by calling
<a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library),
<a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library),
<a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library),
-<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O and the Operating System libraries),
+<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
+<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>
and should not be called directly:
@@ -5541,13 +5744,15 @@ Returns <b>true</b> if the step finished a collection cycle.
</li>
<li><b>"setpause":</b>
-sets <code>arg</code>/100 as the new value for the <em>pause</em> of
+sets <code>arg</code> as the new value for the <em>pause</em> of
the collector (see <a href="#2.10">&sect;2.10</a>).
+Returns the previous value for <em>pause</em>.
</li>
<li><b>"setstepmul":</b>
-sets <code>arg</code>/100 as the new value for the <em>step multiplier</em> of
+sets <code>arg</code> as the new value for the <em>step multiplier</em> of
the collector (see <a href="#2.10">&sect;2.10</a>).
+Returns the previous value for <em>step</em>.
</li>
</ul>
@@ -5652,7 +5857,7 @@ up to the first integer key absent from the table.
Loads a chunk using function <code>func</code> to get its pieces.
Each call to <code>func</code> must return a string that concatenates
with previous results.
-A return of <b>nil</b> (or no value) signals the end of the chunk.
+A return of an empty string, <b>nil</b>, or no value signals the end of the chunk.
<p>
@@ -5665,6 +5870,8 @@ The environment of the returned function is the global environment.
<p>
<code>chunkname</code> is used as the chunk name for error messages
and debug information.
+When absent,
+it defaults to "<code>=(load)</code>".
@@ -5698,6 +5905,11 @@ To load and run a given string, use the idiom
assert(loadstring(s))()
</pre>
+<p>
+When absent,
+<code>chunkname</code> defaults to the given string.
+
+
<p>
@@ -5891,7 +6103,7 @@ The base may be any integer between 2 and 36, inclusive.
In bases above&nbsp;10, the letter '<code>A</code>' (in either upper or lower case)
represents&nbsp;10, '<code>B</code>' represents&nbsp;11, and so forth,
with '<code>Z</code>' representing 35.
-In base 10 (the default), the number may have a decimal part,
+In base 10 (the default), the number can have a decimal part,
as well as an optional exponent part (see <a href="#2.1">&sect;2.1</a>).
In other bases, only unsigned integers are accepted.
@@ -6138,7 +6350,7 @@ field <code>b</code> of global <code>a</code>.
<p>
-This function may receive optional <em>options</em> after
+This function can receive optional <em>options</em> after
the module name,
where each option is a function to be applied over the module.
@@ -6160,7 +6372,15 @@ Otherwise, it tries to find a <em>loader</em> for the module.
<p>
To find a loader,
-first <code>require</code> queries <code>package.preload[modname]</code>.
+<code>require</code> is guided by the <a href="#pdf-package.loaders"><code>package.loaders</code></a> array.
+By changing this array,
+we can change how <code>require</code> looks for a module.
+The following explanation is based on the default configuration
+for <a href="#pdf-package.loaders"><code>package.loaders</code></a>.
+
+
+<p>
+First <code>require</code> queries <code>package.preload[modname]</code>.
If it has a value,
this value (which should be a function) is the loader.
Otherwise <code>require</code> searches for a Lua loader using the
@@ -6168,38 +6388,7 @@ path stored in <a href="#pdf-package.path"><code>package.path</code></a>.
If that also fails, it searches for a C&nbsp;loader using the
path stored in <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
If that also fails,
-it tries an <em>all-in-one</em> loader (see below).
-
-
-<p>
-When loading a C&nbsp;library,
-<code>require</code> first uses a dynamic link facility to link the
-application with the library.
-Then it tries to find a C&nbsp;function inside this library to
-be used as the loader.
-The name of this C&nbsp;function is the string "<code>luaopen_</code>"
-concatenated with a copy of the module name where each dot
-is replaced by an underscore.
-Moreover, if the module name has a hyphen,
-its prefix up to (and including) the first hyphen is removed.
-For instance, if the module name is <code>a.v1-b.c</code>,
-the function name will be <code>luaopen_b_c</code>.
-
-
-<p>
-If <code>require</code> finds neither a Lua library nor a
-C&nbsp;library for a module,
-it calls the <em>all-in-one loader</em>.
-This loader searches the C&nbsp;path for a library for
-the root name of the given module.
-For instance, when requiring <code>a.b.c</code>,
-it will search for a C&nbsp;library for <code>a</code>.
-If found, it looks into it for an open function for
-the submodule;
-in our example, that would be <code>luaopen_a_b_c</code>.
-With this facility, a package can pack several C&nbsp;submodules
-into one single library,
-with each submodule keeping its original open function.
+it tries an <em>all-in-one</em> loader (see <a href="#pdf-package.loaders"><code>package.loaders</code></a>).
<p>
@@ -6234,7 +6423,7 @@ The path used by <a href="#pdf-require"><code>require</code></a> to search for a
Lua initializes the C&nbsp;path <a href="#pdf-package.cpath"><code>package.cpath</code></a> in the same way
it initializes the Lua path <a href="#pdf-package.path"><code>package.path</code></a>,
using the environment variable <a name="pdf-LUA_CPATH"><code>LUA_CPATH</code></a>
-(plus another default path defined in <code>luaconf.h</code>).
+or a default path defined in <code>luaconf.h</code>.
@@ -6255,6 +6444,94 @@ When you require a module <code>modname</code> and
<p>
+<hr><h3><a name="pdf-package.loaders"><code>package.loaders</code></a></h3>
+
+
+<p>
+A table used by <a href="#pdf-require"><code>require</code></a> to control how to load modules.
+
+
+<p>
+Each entry in this table is a <em>searcher function</em>.
+When looking for a module,
+<a href="#pdf-require"><code>require</code></a> calls each of these searchers in ascending order,
+with the module name (the argument given to <a href="#pdf-require"><code>require</code></a>) as its
+sole parameter.
+The function can return another function (the module <em>loader</em>)
+or a string explaining why it did not find that module
+(or <b>nil</b> if it has nothing to say).
+Lua initializes this table with four functions.
+
+
+<p>
+The first searcher simply looks for a loader in the
+<a href="#pdf-package.preload"><code>package.preload</code></a> table.
+
+
+<p>
+The second searcher looks for a loader as a Lua library,
+using the path stored at <a href="#pdf-package.path"><code>package.path</code></a>.
+A path is a sequence of <em>templates</em> separated by semicolons.
+For each template,
+the searcher will change each interrogation
+mark in the template by <code>filename</code>,
+which is the module name with each dot replaced by a
+"directory separator" (such as "<code>/</code>" in Unix);
+then it will try to open the resulting file name.
+So, for instance, if the Lua path is the string
+
+<pre>
+ "./?.lua;./?.lc;/usr/local/?/init.lua"
+</pre><p>
+the search for a Lua file for module <code>foo</code>
+will try to open the files
+<code>./foo.lua</code>, <code>./foo.lc</code>, and
+<code>/usr/local/foo/init.lua</code>, in that order.
+
+
+<p>
+The third searcher looks for a loader as a C&nbsp;library,
+using the path given by the variable <a href="#pdf-package.cpath"><code>package.cpath</code></a>.
+For instance,
+if the C&nbsp;path is the string
+
+<pre>
+ "./?.so;./?.dll;/usr/local/?/init.so"
+</pre><p>
+the searcher for module <code>foo</code>
+will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>,
+and <code>/usr/local/foo/init.so</code>, in that order.
+Once it finds a C&nbsp;library,
+this searcher first uses a dynamic link facility to link the
+application with the library.
+Then it tries to find a C&nbsp;function inside the library to
+be used as the loader.
+The name of this C&nbsp;function is the string "<code>luaopen_</code>"
+concatenated with a copy of the module name where each dot
+is replaced by an underscore.
+Moreover, if the module name has a hyphen,
+its prefix up to (and including) the first hyphen is removed.
+For instance, if the module name is <code>a.v1-b.c</code>,
+the function name will be <code>luaopen_b_c</code>.
+
+
+<p>
+The fourth searcher tries an <em>all-in-one loader</em>.
+It searches the C&nbsp;path for a library for
+the root name of the given module.
+For instance, when requiring <code>a.b.c</code>,
+it will search for a C&nbsp;library for <code>a</code>.
+If found, it looks into it for an open function for
+the submodule;
+in our example, that would be <code>luaopen_a_b_c</code>.
+With this facility, a package can pack several C&nbsp;submodules
+into one single library,
+with each submodule keeping its original open function.
+
+
+
+
+<p>
<hr><h3><a name="pdf-package.loadlib"><code>package.loadlib (libname, funcname)</code></a></h3>
@@ -6303,24 +6580,6 @@ Any "<code>;;</code>" in the value of the environment variable
is replaced by the default path.
-<p>
-A path is a sequence of <em>templates</em> separated by semicolons.
-For each template, <a href="#pdf-require"><code>require</code></a> will change each interrogation
-mark in the template by <code>filename</code>,
-which is <code>modname</code> with each dot replaced by a
-"directory separator" (such as "<code>/</code>" in Unix);
-then it will try to load the resulting file name.
-So, for instance, if the Lua path is
-
-<pre>
- "./?.lua;./?.lc;/usr/local/?/init.lua"
-</pre><p>
-the search for a Lua loader for module <code>foo</code>
-will try to load the files
-<code>./foo.lua</code>, <code>./foo.lc</code>, and
-<code>/usr/local/foo/init.lua</code>, in that order.
-
-
<p>
@@ -6374,6 +6633,10 @@ can be written as <code>s:byte(i)</code>.
<p>
+The string library assumes one-byte character encodings.
+
+
+<p>
<hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
Returns the internal numerical codes of the characters <code>s[i]</code>,
<code>s[i+1]</code>, &middot;&middot;&middot;, <code>s[j]</code>.
@@ -6423,7 +6686,7 @@ where this occurrence starts and ends;
otherwise, it returns <b>nil</b>.
A third, optional numerical argument <code>init</code> specifies
where to start the search;
-its default value is&nbsp;1 and may be negative.
+its default value is&nbsp;1 and can be negative.
A value of <b>true</b> as a fourth, optional argument <code>plain</code>
turns off the pattern matching facilities,
so the function does a plain "find substring" operation,
@@ -6524,11 +6787,12 @@ work as an anchor, as this would prevent the iteration.
<p>
<hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
Returns a copy of <code>s</code>
-in which all occurrences of the <code>pattern</code> have been
+in which all (or the first <code>n</code>, if given)
+occurrences of the <code>pattern</code> have been
replaced by a replacement string specified by <code>repl</code>,
-which may be a string, a table, or a function.
+which can be a string, a table, or a function.
<code>gsub</code> also returns, as its second value,
-the total number of substitutions made.
+the total number of matches that occurred.
<p>
@@ -6566,13 +6830,6 @@ then there is no replacement
<p>
-The optional last parameter <code>n</code> limits
-the maximum number of substitutions to occur.
-For instance, when <code>n</code> is 1 only the first occurrence of
-<code>pattern</code> is replaced.
-
-
-<p>
Here are some examples:
<pre>
@@ -6631,7 +6888,7 @@ If <code>pattern</code> specifies no captures,
then the whole match is returned.
A third, optional numerical argument <code>init</code> specifies
where to start the search;
-its default value is&nbsp;1 and may be negative.
+its default value is&nbsp;1 and can be negative.
@@ -6655,7 +6912,7 @@ Returns a string that is the string <code>s</code> reversed.
<hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
Returns the substring of <code>s</code> that
starts at <code>i</code> and continues until <code>j</code>;
-<code>i</code> and <code>j</code> may be negative.
+<code>i</code> and <code>j</code> can be negative.
If <code>j</code> is absent, then it is assumed to be equal to -1
(which is the same as the string length).
In particular,
@@ -6724,9 +6981,9 @@ when used to represent itself in a pattern.
<li><b><code>[<em>set</em>]</code>:</b>
represents the class which is the union of all
characters in <em>set</em>.
-A range of characters may be specified by
+A range of characters can be specified by
separating the end characters of the range with a '<code>-</code>'.
-All classes <code>%</code><em>x</em> described above may also be used as
+All classes <code>%</code><em>x</em> described above can also be used as
components in <em>set</em>.
All other characters in <em>set</em> represent themselves.
For example, <code>[%w_]</code> (or <code>[_%w]</code>)
@@ -6763,7 +7020,7 @@ In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</c
<h4>Pattern Item:</h4><p>
-A <em>pattern item</em> may be
+A <em>pattern item</em> can be
<ul>
@@ -6832,7 +7089,7 @@ At other positions,
<h4>Captures:</h4><p>
-A pattern may contain sub-patterns enclosed in parentheses;
+A pattern can contain sub-patterns enclosed in parentheses;
they describe <em>captures</em>.
When a match succeeds, the substrings of the subject string
that match captures are stored (<em>captured</em>) for future use.
@@ -7005,14 +7262,14 @@ Returns the arc tangent of <code>x</code> (in radians).
<p>
-<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (x, y)</code></a></h3>
+<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (y, x)</code></a></h3>
<p>
-Returns the arc tangent of <code>x/y</code> (in radians),
+Returns the arc tangent of <code>y/x</code> (in radians),
but uses the signs of both parameters to find the
quadrant of the result.
-(It also handles correctly the case of <code>y</code> being zero.)
+(It also handles correctly the case of <code>x</code> being zero.)
@@ -7062,7 +7319,7 @@ Returns the angle <code>x</code> (given in radians) in degrees.
<p>
-Returns the the value <em>e<sup>x</sup></em>.
+Returns the value <em>e<sup>x</sup></em>.
@@ -7082,7 +7339,8 @@ Returns the largest integer smaller than or equal to <code>x</code>.
<p>
-Returns the remainder of the division of <code>x</code> by <code>y</code>.
+Returns the remainder of the division of <code>x</code> by <code>y</code>
+that rounds the quotient towards zero.
@@ -7215,13 +7473,13 @@ pseudo-random generator function <code>rand</code> provided by ANSI&nbsp;C.
<p>
When called without arguments,
-returns a pseudo-random real number
+returns a uniform pseudo-random real number
in the range <em>[0,1)</em>.
-When called with a number <code>m</code>,
+When called with an integer number <code>m</code>,
<code>math.random</code> returns
-a pseudo-random integer in the range <em>[1, m]</em>.
-When called with two numbers <code>m</code> and <code>n</code>,
-<code>math.random</code> returns a pseudo-random
+a uniform pseudo-random integer in the range <em>[1, m]</em>.
+When called with two integer numbers <code>m</code> and <code>n</code>,
+<code>math.random</code> returns a uniform pseudo-random
integer in the range <em>[m, n]</em>.
@@ -7316,6 +7574,7 @@ and then all operations are supplied as methods of the file descriptor.
The table <code>io</code> also provides
three predefined file descriptors with their usual meanings from C:
<a name="pdf-io.stdin"><code>io.stdin</code></a>, <a name="pdf-io.stdout"><code>io.stdout</code></a>, and <a name="pdf-io.stderr"><code>io.stderr</code></a>.
+The I/O library never closes these files.
<p>
@@ -7418,7 +7677,7 @@ The <code>mode</code> string can be any of the following:
<li><b>"a+":</b> append update mode, previous data is preserved,
writing is only allowed at the end of file.</li>
</ul><p>
-The <code>mode</code> string may also have a '<code>b</code>' at the end,
+The <code>mode</code> string can also have a '<code>b</code>' at the end,
which is needed in some systems to open the file in binary mode.
This string is exactly what is used in the
standard&nbsp;C function <code>fopen</code>.
@@ -7829,9 +8088,9 @@ or <b>nil</b> if the request cannot be honored.
<p>
If <code>locale</code> is the empty string,
-the current locate is set to an implementation-defined native locale.
-If <code>locate</code> is the string "<code>C</code>",
-the current locate is set to the standard C locale.
+the current locale is set to an implementation-defined native locale.
+If <code>locale</code> is the string "<code>C</code>",
+the current locale is set to the standard C locale.
<p>
@@ -7876,6 +8135,22 @@ The file must be explicitly opened before its use
and explicitly removed when no longer needed.
+<p>
+On some systems (POSIX),
+this function also creates a file with that name,
+to avoid security risks.
+(Someone else might create the file with wrong permissions
+in the time between getting the name and creating the file.)
+You still have to open the file to use it
+and to remove it (even if you do not use it).
+
+
+<p>
+When possible,
+you may prefer to use <a href="#pdf-io.tmpfile"><code>io.tmpfile</code></a>,
+which automatically removes the file when the program ends.
+
+
@@ -7892,7 +8167,7 @@ and similar tasks, such as profiling.
Please resist the temptation to use them as a
usual programming tool:
they can be very slow.
-Moreover, several of its functions
+Moreover, several of these functions
violate some assumptions about Lua code
(e.g., that variables local to a function
cannot be accessed from outside or
@@ -7968,7 +8243,7 @@ then <code>getinfo</code> returns <b>nil</b>.
<p>
-The returned table may contain all the fields returned by <a href="#lua_getinfo"><code>lua_getinfo</code></a>,
+The returned table can contain all the fields returned by <a href="#lua_getinfo"><code>lua_getinfo</code></a>,
with the string <code>what</code> describing which fields to fill in.
The default for <code>what</code> is to get all information available,
except the table of valid lines.
@@ -7983,7 +8258,8 @@ valid lines.
<p>
For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
-a name of the current function, if a reasonable name can be found,
+a table with a name for the current function,
+if a reasonable name can be found,
and the expression <code>debug.getinfo(print)</code>
returns a table with all available information
about the <a href="#pdf-print"><code>print</code></a> function.
@@ -8070,9 +8346,9 @@ The string mask may have the following characters,
with the given meaning:
<ul>
-<li><b><code>"c"</code>:</b> The hook is called every time Lua calls a function;</li>
-<li><b><code>"r"</code>:</b> The hook is called every time Lua returns from a function;</li>
-<li><b><code>"l"</code>:</b> The hook is called every time Lua enters a new line of code.</li>
+<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li>
+<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li>
+<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li>
</ul><p>
With a <code>count</code> different from zero,
the hook is called after every <code>count</code> instructions.
@@ -8086,7 +8362,8 @@ When called without arguments,
<p>
When the hook is called, its first parameter is a string
describing the event that has triggered its call:
-<code>"call"</code>, <code>"return"</code> (or <code>"tail return"</code>),
+<code>"call"</code>, <code>"return"</code> (or <code>"tail return"</code>,
+when simulating a return from a tail call),
<code>"line"</code>, and <code>"count"</code>.
For line events,
the hook also gets the new line number as its second parameter.
@@ -8257,17 +8534,19 @@ then its value is used as the prompt.
Similarly, if the global variable <a name="pdf-_PROMPT2"><code>_PROMPT2</code></a> contains a string,
its value is used as the secondary prompt
(issued during incomplete statements).
-Therefore, both prompts can be changed directly on the command line.
-For instance,
+Therefore, both prompts can be changed directly on the command line
+or in any Lua programs by assigning to <code>_PROMPT</code>.
+See the next example:
<pre>
$ lua -e"_PROMPT='myprompt&gt; '" -i
</pre><p>
-(the outer pair of quotes is for the shell,
-the inner pair is for Lua),
-or in any Lua programs by assigning to <code>_PROMPT</code>.
-Note the use of <code>-i</code> to enter interactive mode; otherwise,
-the program would just end silently right after the assignment to <code>_PROMPT</code>.
+(The outer pair of quotes is for the shell,
+the inner pair is for Lua.)
+Note the use of <code>-i</code> to enter interactive mode;
+otherwise,
+the program would just end silently
+right after the assignment to <code>_PROMPT</code>.
<p>
@@ -8297,7 +8576,7 @@ is a more portable solution.)
<h1>7 - <a name="7">Incompatibilities with the Previous Version</a></h1>
<p>
-Here we list the incompatibilities that you may found when moving a program
+Here we list the incompatibilities that you may find when moving a program
from Lua&nbsp;5.0 to Lua&nbsp;5.1.
You can avoid most of the incompatibilities compiling Lua with
appropriate options (see file <code>luaconf.h</code>).
@@ -8446,29 +8725,29 @@ Here is the complete syntax of Lua in extended BNF.
block ::= chunk
- stat ::= varlist1 `<b>=</b>&acute; explist1 |
+ stat ::= varlist `<b>=</b>&acute; explist |
functioncall |
<b>do</b> block <b>end</b> |
<b>while</b> exp <b>do</b> block <b>end</b> |
<b>repeat</b> block <b>until</b> exp |
<b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b> |
<b>for</b> Name `<b>=</b>&acute; exp `<b>,</b>&acute; exp [`<b>,</b>&acute; exp] <b>do</b> block <b>end</b> |
- <b>for</b> namelist <b>in</b> explist1 <b>do</b> block <b>end</b> |
+ <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b> |
<b>function</b> funcname funcbody |
<b>local</b> <b>function</b> Name funcbody |
- <b>local</b> namelist [`<b>=</b>&acute; explist1]
+ <b>local</b> namelist [`<b>=</b>&acute; explist]
- laststat ::= <b>return</b> [explist1] | <b>break</b>
+ laststat ::= <b>return</b> [explist] | <b>break</b>
funcname ::= Name {`<b>.</b>&acute; Name} [`<b>:</b>&acute; Name]
- varlist1 ::= var {`<b>,</b>&acute; var}
+ varlist ::= var {`<b>,</b>&acute; var}
var ::= Name | prefixexp `<b>[</b>&acute; exp `<b>]</b>&acute; | prefixexp `<b>.</b>&acute; Name
namelist ::= Name {`<b>,</b>&acute; Name}
- explist1 ::= {exp `<b>,</b>&acute;} exp
+ explist ::= {exp `<b>,</b>&acute;} exp
exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | String | `<b>...</b>&acute; | function |
prefixexp | tableconstructor | exp binop exp | unop exp
@@ -8477,13 +8756,13 @@ Here is the complete syntax of Lua in extended BNF.
functioncall ::= prefixexp args | prefixexp `<b>:</b>&acute; Name args
- args ::= `<b>(</b>&acute; [explist1] `<b>)</b>&acute; | tableconstructor | String
+ args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute; | tableconstructor | String
function ::= <b>function</b> funcbody
- funcbody ::= `<b>(</b>&acute; [parlist1] `<b>)</b>&acute; block <b>end</b>
+ funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
- parlist1 ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
+ parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
tableconstructor ::= `<b>{</b>&acute; [fieldlist] `<b>}</b>&acute;
@@ -8508,13 +8787,14 @@ Here is the complete syntax of Lua in extended BNF.
+
<HR>
<SMALL>
Last update:
-Mon Mar 26 12:59:26 BRT 2007
+Mon Aug 18 13:25:46 BRT 2008
</SMALL>
<!--
-Last change: ready for Lua 5.1.2
+Last change: revised for Lua 5.1.4
-->
</body></html>
diff --git a/src/host/lua-5.1.2/doc/readme.html b/src/host/lua-5.1.4/doc/readme.html
index 28b1d14..38be6db 100644
--- a/src/host/lua-5.1.2/doc/readme.html
+++ b/src/host/lua-5.1.4/doc/readme.html
@@ -12,7 +12,7 @@
Documentation
</H1>
-This is the documentation included in the source distribution of Lua 5.1.2.
+This is the documentation included in the source distribution of Lua 5.1.4.
<UL>
<LI><A HREF="contents.html">Reference manual</A>
@@ -33,7 +33,7 @@ especially the
<HR>
<SMALL>
Last update:
-Fri Mar 23 14:19:36 BRT 2007
+Tue Aug 12 14:46:07 BRT 2008
</SMALL>
</BODY>
diff --git a/src/host/lua-5.1.2/etc/Makefile b/src/host/lua-5.1.4/etc/Makefile
index 6d00008..6d00008 100644
--- a/src/host/lua-5.1.2/etc/Makefile
+++ b/src/host/lua-5.1.4/etc/Makefile
diff --git a/src/host/lua-5.1.2/etc/README b/src/host/lua-5.1.4/etc/README
index 5149fc9..5149fc9 100644
--- a/src/host/lua-5.1.2/etc/README
+++ b/src/host/lua-5.1.4/etc/README
diff --git a/src/host/lua-5.1.2/etc/all.c b/src/host/lua-5.1.4/etc/all.c
index dab68fa..dab68fa 100644
--- a/src/host/lua-5.1.2/etc/all.c
+++ b/src/host/lua-5.1.4/etc/all.c
diff --git a/src/host/lua-5.1.2/etc/lua.hpp b/src/host/lua-5.1.4/etc/lua.hpp
index ec417f5..ec417f5 100644
--- a/src/host/lua-5.1.2/etc/lua.hpp
+++ b/src/host/lua-5.1.4/etc/lua.hpp
diff --git a/src/host/lua-5.1.2/etc/lua.ico b/src/host/lua-5.1.4/etc/lua.ico
index ccbabc4..ccbabc4 100644
--- a/src/host/lua-5.1.2/etc/lua.ico
+++ b/src/host/lua-5.1.4/etc/lua.ico
Binary files differ
diff --git a/src/host/lua-5.1.2/etc/lua.pc b/src/host/lua-5.1.4/etc/lua.pc
index 03a2e68..f52f55b 100644
--- a/src/host/lua-5.1.2/etc/lua.pc
+++ b/src/host/lua-5.1.4/etc/lua.pc
@@ -5,7 +5,7 @@
# grep '^V=' ../Makefile
V= 5.1
# grep '^R=' ../Makefile
-R= 5.1.2
+R= 5.1.4
# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
prefix= /usr/local
diff --git a/src/host/lua-5.1.4/etc/luavs.bat b/src/host/lua-5.1.4/etc/luavs.bat
new file mode 100644
index 0000000..08c2bed
--- /dev/null
+++ b/src/host/lua-5.1.4/etc/luavs.bat
@@ -0,0 +1,28 @@
+@rem Script to build Lua under "Visual Studio .NET Command Prompt".
+@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat .
+@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src.
+@rem (contributed by David Manura and Mike Pall)
+
+@setlocal
+@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
+@set MYLINK=link /nologo
+@set MYMT=mt /nologo
+
+cd src
+%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c
+del lua.obj luac.obj
+%MYLINK% /DLL /out:lua51.dll l*.obj
+if exist lua51.dll.manifest^
+ %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2
+%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c
+%MYLINK% /out:lua.exe lua.obj lua51.lib
+if exist lua.exe.manifest^
+ %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe
+%MYCOMPILE% l*.c print.c
+del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^
+ loslib.obj ltablib.obj lstrlib.obj loadlib.obj
+%MYLINK% /out:luac.exe *.obj
+if exist luac.exe.manifest^
+ %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe
+del *.obj *.manifest
+cd ..
diff --git a/src/host/lua-5.1.2/etc/min.c b/src/host/lua-5.1.4/etc/min.c
index 404bd50..6a85a4d 100644
--- a/src/host/lua-5.1.2/etc/min.c
+++ b/src/host/lua-5.1.4/etc/min.c
@@ -18,7 +18,7 @@ static int print(lua_State *L)
if (i>1) printf("\t");
if (lua_isstring(L,i))
printf("%s",lua_tostring(L,i));
- else if (lua_isnil(L,i)==2)
+ else if (lua_isnil(L,i))
printf("%s","nil");
else if (lua_isboolean(L,i))
printf("%s",lua_toboolean(L,i) ? "true" : "false");
diff --git a/src/host/lua-5.1.2/etc/noparser.c b/src/host/lua-5.1.4/etc/noparser.c
index 13ba546..13ba546 100644
--- a/src/host/lua-5.1.2/etc/noparser.c
+++ b/src/host/lua-5.1.4/etc/noparser.c
diff --git a/src/host/lua-5.1.2/etc/strict.lua b/src/host/lua-5.1.4/etc/strict.lua
index 16ee26b..604619d 100644
--- a/src/host/lua-5.1.2/etc/strict.lua
+++ b/src/host/lua-5.1.4/etc/strict.lua
@@ -6,6 +6,8 @@
-- anywhere or assigned to inside a function.
--
+local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
+
local mt = getmetatable(_G)
if mt == nil then
mt = {}
@@ -15,7 +17,7 @@ end
mt.__declared = {}
local function what ()
- local d = debug.getinfo(3, "S")
+ local d = getinfo(3, "S")
return d and d.what or "C"
end
diff --git a/src/host/lua-5.1.2/src/Makefile b/src/host/lua-5.1.4/src/Makefile
index cd7f6ba..e4a3cd6 100644
--- a/src/host/lua-5.1.2/src/Makefile
+++ b/src/host/lua-5.1.4/src/Makefile
@@ -99,9 +99,9 @@ linux:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
macosx:
- $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
-# use this on Mac OS X 10.4
-# $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
+# use this on Mac OS X 10.3-
+# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
@@ -148,8 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h
-loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
- lualib.h
+loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
diff --git a/src/host/lua-5.1.2/src/lapi.c b/src/host/lua-5.1.4/src/lapi.c
index 7c532b8..5d5145d 100644
--- a/src/host/lua-5.1.2/src/lapi.c
+++ b/src/host/lua-5.1.4/src/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $
+** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -93,15 +93,14 @@ void luaA_pushobject (lua_State *L, const TValue *o) {
LUA_API int lua_checkstack (lua_State *L, int size) {
- int res;
+ int res = 1;
lua_lock(L);
- if ((L->top - L->base + size) > LUAI_MAXCSTACK)
+ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
res = 0; /* stack overflow */
- else {
+ else if (size > 0) {
luaD_checkstack(L, size);
if (L->ci->top < L->top + size)
L->ci->top = L->top + size;
- res = 1;
}
lua_unlock(L);
return res;
@@ -123,6 +122,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
}
+LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
+ to->nCcalls = from->nCcalls;
+}
+
+
LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
lua_CFunction old;
lua_lock(L);
@@ -749,7 +753,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
res = 0;
break;
}
- luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
L->top--;
lua_unlock(L);
return res;
@@ -925,10 +929,13 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
g->GCthreshold = g->totalbytes - a;
else
g->GCthreshold = 0;
- while (g->GCthreshold <= g->totalbytes)
+ while (g->GCthreshold <= g->totalbytes) {
luaC_step(L);
- if (g->gcstate == GCSpause) /* end of cycle? */
- res = 1; /* signal it */
+ if (g->gcstate == GCSpause) { /* end of cycle? */
+ res = 1; /* signal it */
+ break;
+ }
+ }
break;
}
case LUA_GCSETPAUSE: {
diff --git a/src/host/lua-5.1.2/src/lapi.h b/src/host/lua-5.1.4/src/lapi.h
index 9d1d435..2c3fab2 100644
--- a/src/host/lua-5.1.2/src/lapi.h
+++ b/src/host/lua-5.1.4/src/lapi.h
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lauxlib.c b/src/host/lua-5.1.4/src/lauxlib.c
index 96a6b85..10f14e2 100644
--- a/src/host/lua-5.1.2/src/lauxlib.c
+++ b/src/host/lua-5.1.4/src/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $
+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -244,7 +244,7 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
if (libname) {
int size = libsize(l);
/* check whether lib already exists */
- luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
+ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
lua_getfield(L, -1, libname); /* get _LOADED[libname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
@@ -535,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
return "\n";
}
if (feof(lf->f)) return NULL;
- *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
+ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
return (*size > 0) ? lf->buff : NULL;
}
@@ -570,9 +570,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
if (c == '\n') c = getc(lf.f);
}
- if (c == LUA_SIGNATURE[0] && lf.f != stdin) { /* binary file? */
- fclose(lf.f);
- lf.f = fopen(filename, "rb"); /* reopen in binary mode */
+ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
+ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
/* skip eventual `#!...' */
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
@@ -581,7 +580,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
ungetc(c, lf.f);
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
readstatus = ferror(lf.f);
- if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */
+ if (filename) fclose(lf.f); /* close file (even in case of errors) */
if (readstatus) {
lua_settop(L, fnameindex); /* ignore results from `lua_load' */
return errfile(L, "read", fnameindex);
diff --git a/src/host/lua-5.1.2/src/lauxlib.h b/src/host/lua-5.1.4/src/lauxlib.h
index 1f34308..3425823 100644
--- a/src/host/lua-5.1.2/src/lauxlib.h
+++ b/src/host/lua-5.1.4/src/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 roberto Exp $
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lbaselib.c b/src/host/lua-5.1.4/src/lbaselib.c
index 147a727..2a4c079 100644
--- a/src/host/lua-5.1.2/src/lbaselib.c
+++ b/src/host/lua-5.1.4/src/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $
+** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -344,10 +344,12 @@ static int luaB_unpack (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+ if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
- if (n <= 0) return 0; /* empty range */
- luaL_checkstack(L, n, "table too big to unpack");
- for (; i<=e; i++) /* push arg[i...e] */
+ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
+ return luaL_error(L, "too many results to unpack");
+ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
+ while (i++ < e) /* push arg[i + 1...e] */
lua_rawgeti(L, 1, i);
return n;
}
@@ -477,19 +479,56 @@ static const luaL_Reg base_funcs[] = {
** =======================================================
*/
+#define CO_RUN 0 /* running */
+#define CO_SUS 1 /* suspended */
+#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
+#define CO_DEAD 3
+
+static const char *const statnames[] =
+ {"running", "suspended", "normal", "dead"};
+
+static int costatus (lua_State *L, lua_State *co) {
+ if (L == co) return CO_RUN;
+ switch (lua_status(co)) {
+ case LUA_YIELD:
+ return CO_SUS;
+ case 0: {
+ lua_Debug ar;
+ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
+ return CO_NOR; /* it is running */
+ else if (lua_gettop(co) == 0)
+ return CO_DEAD;
+ else
+ return CO_SUS; /* initial state */
+ }
+ default: /* some error occured */
+ return CO_DEAD;
+ }
+}
+
+
+static int luaB_costatus (lua_State *L) {
+ lua_State *co = lua_tothread(L, 1);
+ luaL_argcheck(L, co, 1, "coroutine expected");
+ lua_pushstring(L, statnames[costatus(L, co)]);
+ return 1;
+}
+
+
static int auxresume (lua_State *L, lua_State *co, int narg) {
- int status;
+ int status = costatus(L, co);
if (!lua_checkstack(co, narg))
luaL_error(L, "too many arguments to resume");
- if (lua_status(co) == 0 && lua_gettop(co) == 0) {
- lua_pushliteral(L, "cannot resume dead coroutine");
+ if (status != CO_SUS) {
+ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
return -1; /* error flag */
}
lua_xmove(L, co, narg);
+ lua_setlevel(L, co);
status = lua_resume(co, narg);
if (status == 0 || status == LUA_YIELD) {
int nres = lua_gettop(co);
- if (!lua_checkstack(L, nres))
+ if (!lua_checkstack(L, nres + 1))
luaL_error(L, "too many results to resume");
lua_xmove(co, L, nres); /* move yielded values */
return nres;
@@ -556,39 +595,10 @@ static int luaB_yield (lua_State *L) {
}
-static int luaB_costatus (lua_State *L) {
- lua_State *co = lua_tothread(L, 1);
- luaL_argcheck(L, co, 1, "coroutine expected");
- if (L == co) lua_pushliteral(L, "running");
- else {
- switch (lua_status(co)) {
- case LUA_YIELD:
- lua_pushliteral(L, "suspended");
- break;
- case 0: {
- lua_Debug ar;
- if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
- lua_pushliteral(L, "normal"); /* it is running */
- else if (lua_gettop(co) == 0)
- lua_pushliteral(L, "dead");
- else
- lua_pushliteral(L, "suspended"); /* initial state */
- break;
- }
- default: /* some error occured */
- lua_pushliteral(L, "dead");
- break;
- }
- }
- return 1;
-}
-
-
static int luaB_corunning (lua_State *L) {
if (lua_pushthread(L))
- return 0; /* main thread is not a coroutine */
- else
- return 1;
+ lua_pushnil(L); /* main thread is not a coroutine */
+ return 1;
}
diff --git a/src/host/lua-5.1.2/src/lcode.c b/src/host/lua-5.1.4/src/lcode.c
index 9ce515a..cff626b 100644
--- a/src/host/lua-5.1.2/src/lcode.c
+++ b/src/host/lua-5.1.4/src/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -699,7 +699,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
switch (op) {
case OPR_MINUS: {
- if (e->k == VK)
+ if (!isnumeral(e))
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
codearith(fs, OP_UNM, e, &e2);
break;
diff --git a/src/host/lua-5.1.2/src/lcode.h b/src/host/lua-5.1.4/src/lcode.h
index c02cb2b..b941c60 100644
--- a/src/host/lua-5.1.2/src/lcode.h
+++ b/src/host/lua-5.1.4/src/lcode.h
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $
+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/ldblib.c b/src/host/lua-5.1.4/src/ldblib.c
index 26a19b6..67de122 100644
--- a/src/host/lua-5.1.2/src/ldblib.c
+++ b/src/host/lua-5.1.4/src/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -255,24 +255,25 @@ static void gethooktable (lua_State *L) {
static int db_sethook (lua_State *L) {
- int arg;
+ int arg, mask, count;
+ lua_Hook func;
lua_State *L1 = getthread(L, &arg);
if (lua_isnoneornil(L, arg+1)) {
lua_settop(L, arg+1);
- lua_sethook(L1, NULL, 0, 0); /* turn off hooks */
+ func = NULL; mask = 0; count = 0; /* turn off hooks */
}
else {
const char *smask = luaL_checkstring(L, arg+2);
- int count = luaL_optint(L, arg+3, 0);
luaL_checktype(L, arg+1, LUA_TFUNCTION);
- lua_sethook(L1, hookf, makemask(smask, count), count);
+ count = luaL_optint(L, arg+3, 0);
+ func = hookf; mask = makemask(smask, count);
}
- gethooktable(L1);
- lua_pushlightuserdata(L1, L1);
+ gethooktable(L);
+ lua_pushlightuserdata(L, L1);
lua_pushvalue(L, arg+1);
- lua_xmove(L, L1, 1);
- lua_rawset(L1, -3); /* set new hook */
- lua_pop(L1, 1); /* remove hook table */
+ lua_rawset(L, -3); /* set new hook */
+ lua_pop(L, 1); /* remove hook table */
+ lua_sethook(L1, func, mask, count); /* set hooks */
return 0;
}
@@ -286,11 +287,10 @@ static int db_gethook (lua_State *L) {
if (hook != NULL && hook != hookf) /* external hook? */
lua_pushliteral(L, "external hook");
else {
- gethooktable(L1);
- lua_pushlightuserdata(L1, L1);
- lua_rawget(L1, -2); /* get hook */
- lua_remove(L1, -2); /* remove hook table */
- lua_xmove(L1, L, 1);
+ gethooktable(L);
+ lua_pushlightuserdata(L, L1);
+ lua_rawget(L, -2); /* get hook */
+ lua_remove(L, -2); /* remove hook table */
}
lua_pushstring(L, unmakemask(mask, buff));
lua_pushinteger(L, lua_gethookcount(L1));
diff --git a/src/host/lua-5.1.2/src/ldebug.c b/src/host/lua-5.1.4/src/ldebug.c
index 9c8bdf2..50ad3d3 100644
--- a/src/host/lua-5.1.2/src/ldebug.c
+++ b/src/host/lua-5.1.4/src/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $
+** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -275,12 +275,12 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
static int precheck (const Proto *pt) {
check(pt->maxstacksize <= MAXSTACK);
- lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
- lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) ||
+ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
+ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
(pt->is_vararg & VARARG_HASARG));
check(pt->sizeupvalues <= pt->nups);
check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
- check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
+ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
return 1;
}
@@ -346,9 +346,18 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
int dest = pc+1+b;
check(0 <= dest && dest < pt->sizecode);
if (dest > 0) {
- /* cannot jump to a setlist count */
- Instruction d = pt->code[dest-1];
- check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0));
+ int j;
+ /* check that it does not jump to a setlist count; this
+ is tricky, because the count from a previous setlist may
+ have the same value of an invalid setlist; so, we must
+ go all the way back to the first of them (if any) */
+ for (j = 0; j < dest; j++) {
+ Instruction d = pt->code[dest-1-j];
+ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
+ }
+ /* if 'j' is even, previous value is not a setlist (even if
+ it looks like one) */
+ check((j&1) == 0);
}
}
break;
@@ -363,7 +372,11 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
switch (op) {
case OP_LOADBOOL: {
- check(c == 0 || pc+2 < pt->sizecode); /* check its jump */
+ if (c == 1) { /* does it jump? */
+ check(pc+2 < pt->sizecode); /* check its jump */
+ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
+ GETARG_C(pt->code[pc+1]) != 0);
+ }
break;
}
case OP_LOADNIL: {
@@ -428,7 +441,10 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
case OP_SETLIST: {
if (b > 0) checkreg(pt, a + b);
- if (c == 0) pc++;
+ if (c == 0) {
+ pc++;
+ check(pc < pt->sizecode - 1);
+ }
break;
}
case OP_CLOSURE: {
@@ -563,8 +579,8 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
- if (ttisstring(p1)) p1 = p2;
- lua_assert(!ttisstring(p1));
+ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
luaG_typeerror(L, p1, "concatenate");
}
diff --git a/src/host/lua-5.1.2/src/ldebug.h b/src/host/lua-5.1.4/src/ldebug.h
index 9c76aa1..ba28a97 100644
--- a/src/host/lua-5.1.2/src/ldebug.h
+++ b/src/host/lua-5.1.4/src/ldebug.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $
+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/ldo.c b/src/host/lua-5.1.4/src/ldo.c
index ab86fb7..8de05f7 100644
--- a/src/host/lua-5.1.2/src/ldo.c
+++ b/src/host/lua-5.1.4/src/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -83,7 +83,7 @@ static void resetstack (lua_State *L, int status) {
L->base = L->ci->base;
luaF_close(L, L->base); /* close eventual pending closures */
luaD_seterrorobj(L, status, L->base);
- L->nCcalls = 0;
+ L->nCcalls = L->baseCcalls;
L->allowhook = 1;
restore_stack_limit(L);
L->errfunc = 0;
@@ -332,7 +332,7 @@ static StkId callrethooks (lua_State *L, StkId firstResult) {
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
luaD_callhook(L, LUA_HOOKRET, -1);
if (f_isLua(L->ci)) { /* Lua function? */
- while (L->ci->tailcalls--) /* call hook for eventual tail calls */
+ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
luaD_callhook(L, LUA_HOOKTAILRET, -1);
}
return restorestack(L, fr);
@@ -417,22 +417,24 @@ static int resume_error (lua_State *L, const char *msg) {
LUA_API int lua_resume (lua_State *L, int nargs) {
int status;
lua_lock(L);
- if (L->status != LUA_YIELD) {
- if (L->status != 0)
- return resume_error(L, "cannot resume dead coroutine");
- else if (L->ci != L->base_ci)
+ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
return resume_error(L, "cannot resume non-suspended coroutine");
- }
+ if (L->nCcalls >= LUAI_MAXCCALLS)
+ return resume_error(L, "C stack overflow");
luai_userstateresume(L, nargs);
- lua_assert(L->errfunc == 0 && L->nCcalls == 0);
+ lua_assert(L->errfunc == 0);
+ L->baseCcalls = ++L->nCcalls;
status = luaD_rawrunprotected(L, resume, L->top - nargs);
if (status != 0) { /* error? */
L->status = cast_byte(status); /* mark thread as `dead' */
luaD_seterrorobj(L, status, L->top);
L->ci->top = L->top;
}
- else
+ else {
+ lua_assert(L->nCcalls == L->baseCcalls);
status = L->status;
+ }
+ --L->nCcalls;
lua_unlock(L);
return status;
}
@@ -441,7 +443,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) {
LUA_API int lua_yield (lua_State *L, int nresults) {
luai_userstateyield(L, nresults);
lua_lock(L);
- if (L->nCcalls > 0)
+ if (L->nCcalls > L->baseCcalls)
luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
L->base = L->top - nresults; /* protect stack slots below */
L->status = LUA_YIELD;
diff --git a/src/host/lua-5.1.2/src/ldo.h b/src/host/lua-5.1.4/src/ldo.h
index b2de92b..98fddac 100644
--- a/src/host/lua-5.1.2/src/ldo.h
+++ b/src/host/lua-5.1.4/src/ldo.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $
+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/ldump.c b/src/host/lua-5.1.4/src/ldump.c
index f08277d..c9d3d48 100644
--- a/src/host/lua-5.1.2/src/ldump.c
+++ b/src/host/lua-5.1.4/src/ldump.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $
+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lfunc.c b/src/host/lua-5.1.4/src/lfunc.c
index 05bd5ff..813e88f 100644
--- a/src/host/lua-5.1.2/src/lfunc.c
+++ b/src/host/lua-5.1.4/src/lfunc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $
+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lfunc.h b/src/host/lua-5.1.4/src/lfunc.h
index 2e02419..a68cf51 100644
--- a/src/host/lua-5.1.2/src/lfunc.h
+++ b/src/host/lua-5.1.4/src/lfunc.h
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $
+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lgc.c b/src/host/lua-5.1.4/src/lgc.c
index 2d24a12..d9e0b78 100644
--- a/src/host/lua-5.1.2/src/lgc.c
+++ b/src/host/lua-5.1.4/src/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lgc.h b/src/host/lua-5.1.4/src/lgc.h
index 5f69acb..5a8dc60 100644
--- a/src/host/lua-5.1.2/src/lgc.h
+++ b/src/host/lua-5.1.4/src/lgc.h
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $
+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/linit.c b/src/host/lua-5.1.4/src/linit.c
index 483d9c8..c1f90df 100644
--- a/src/host/lua-5.1.2/src/linit.c
+++ b/src/host/lua-5.1.4/src/linit.c
@@ -1,5 +1,5 @@
/*
-** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $
+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
** Initialization of libraries for lua.c
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/liolib.c b/src/host/lua-5.1.4/src/liolib.c
index be60972..e79ed1c 100644
--- a/src/host/lua-5.1.2/src/liolib.c
+++ b/src/host/lua-5.1.4/src/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -51,7 +51,7 @@ static void fileerror (lua_State *L, int arg, const char *filename) {
}
-#define topfile(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
static int io_type (lua_State *L) {
@@ -70,7 +70,7 @@ static int io_type (lua_State *L) {
static FILE *tofile (lua_State *L) {
- FILE **f = topfile(L);
+ FILE **f = tofilep(L);
if (*f == NULL)
luaL_error(L, "attempt to use a closed file");
return *f;
@@ -93,19 +93,31 @@ static FILE **newfile (lua_State *L) {
/*
-** this function has a separated environment, which defines the
-** correct __close for 'popen' files
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+ lua_pushnil(L);
+ lua_pushliteral(L, "cannot close standard file");
+ return 2;
+}
+
+
+/*
+** function to close 'popen' files
*/
static int io_pclose (lua_State *L) {
- FILE **p = topfile(L);
+ FILE **p = tofilep(L);
int ok = lua_pclose(L, *p);
*p = NULL;
return pushresult(L, ok, NULL);
}
+/*
+** function to close regular files
+*/
static int io_fclose (lua_State *L) {
- FILE **p = topfile(L);
+ FILE **p = tofilep(L);
int ok = (fclose(*p) == 0);
*p = NULL;
return pushresult(L, ok, NULL);
@@ -128,18 +140,18 @@ static int io_close (lua_State *L) {
static int io_gc (lua_State *L) {
- FILE *f = *topfile(L);
- /* ignore closed files and standard files */
- if (f != NULL && f != stdin && f != stdout && f != stderr)
+ FILE *f = *tofilep(L);
+ /* ignore closed files */
+ if (f != NULL)
aux_close(L);
return 0;
}
static int io_tostring (lua_State *L) {
- FILE *f = *topfile(L);
+ FILE *f = *tofilep(L);
if (f == NULL)
- lua_pushstring(L, "file (closed)");
+ lua_pushliteral(L, "file (closed)");
else
lua_pushfstring(L, "file (%p)", f);
return 1;
@@ -155,6 +167,10 @@ static int io_open (lua_State *L) {
}
+/*
+** this function has a separated environment, which defines the
+** correct __close for 'popen' files
+*/
static int io_popen (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
@@ -280,7 +296,7 @@ static int read_line (lua_State *L, FILE *f) {
char *p = luaL_prepbuffer(&b);
if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
luaL_pushresult(&b); /* close buffer */
- return (lua_strlen(L, -1) > 0); /* check whether read something */
+ return (lua_objlen(L, -1) > 0); /* check whether read something */
}
l = strlen(p);
if (l == 0 || p[l-1] != '\n')
@@ -308,7 +324,7 @@ static int read_chars (lua_State *L, FILE *f, size_t n) {
n -= nr; /* still have to read `n' chars */
} while (n > 0 && nr == rlen); /* until end of count or eof */
luaL_pushresult(&b); /* close buffer */
- return (n == 0 || lua_strlen(L, -1) > 0);
+ return (n == 0 || lua_objlen(L, -1) > 0);
}
@@ -502,31 +518,36 @@ static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
lua_pushvalue(L, -1);
lua_rawseti(L, LUA_ENVIRONINDEX, k);
}
- lua_setfield(L, -2, fname);
+ lua_pushvalue(L, -2); /* copy environment */
+ lua_setfenv(L, -2); /* set it */
+ lua_setfield(L, -3, fname);
+}
+
+
+static void newfenv (lua_State *L, lua_CFunction cls) {
+ lua_createtable(L, 0, 1);
+ lua_pushcfunction(L, cls);
+ lua_setfield(L, -2, "__close");
}
LUALIB_API int luaopen_io (lua_State *L) {
createmeta(L);
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
- lua_createtable(L, 2, 1);
+ newfenv(L, io_fclose);
lua_replace(L, LUA_ENVIRONINDEX);
/* open library */
luaL_register(L, LUA_IOLIBNAME, iolib);
/* create (and set) default files */
+ newfenv(L, io_noclose); /* close function for default files */
createstdfile(L, stdin, IO_INPUT, "stdin");
createstdfile(L, stdout, IO_OUTPUT, "stdout");
createstdfile(L, stderr, 0, "stderr");
- /* create environment for 'popen' */
+ lua_pop(L, 1); /* pop environment for default files */
lua_getfield(L, -1, "popen");
- lua_createtable(L, 0, 1);
- lua_pushcfunction(L, io_pclose);
- lua_setfield(L, -2, "__close");
- lua_setfenv(L, -2);
+ newfenv(L, io_pclose); /* create environment for 'popen' */
+ lua_setfenv(L, -2); /* set fenv for 'popen' */
lua_pop(L, 1); /* pop 'popen' */
- /* set default close function */
- lua_pushcfunction(L, io_fclose);
- lua_setfield(L, LUA_ENVIRONINDEX, "__close");
return 1;
}
diff --git a/src/host/lua-5.1.2/src/llex.c b/src/host/lua-5.1.4/src/llex.c
index 1c07cad..6dc3193 100644
--- a/src/host/lua-5.1.2/src/llex.c
+++ b/src/host/lua-5.1.4/src/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.20 2006/03/09 18:14:31 roberto Exp $
+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/llex.h b/src/host/lua-5.1.4/src/llex.h
index ff07e83..a9201ce 100644
--- a/src/host/lua-5.1.2/src/llex.h
+++ b/src/host/lua-5.1.4/src/llex.h
@@ -1,5 +1,5 @@
/*
-** $Id: llex.h,v 1.58 2006/03/23 18:23:32 roberto Exp $
+** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/llimits.h b/src/host/lua-5.1.4/src/llimits.h
index b03221a..ca8dcb7 100644
--- a/src/host/lua-5.1.2/src/llimits.h
+++ b/src/host/lua-5.1.4/src/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lmathlib.c b/src/host/lua-5.1.4/src/lmathlib.c
index d181a73..441fbf7 100644
--- a/src/host/lua-5.1.2/src/lmathlib.c
+++ b/src/host/lua-5.1.4/src/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $
+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lmem.c b/src/host/lua-5.1.4/src/lmem.c
index cef2bc5..ae7d8c9 100644
--- a/src/host/lua-5.1.2/src/lmem.c
+++ b/src/host/lua-5.1.4/src/lmem.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $
+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lmem.h b/src/host/lua-5.1.4/src/lmem.h
index 19df1fb..7c2dcb3 100644
--- a/src/host/lua-5.1.2/src/lmem.h
+++ b/src/host/lua-5.1.4/src/lmem.h
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $
+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/loadlib.c b/src/host/lua-5.1.4/src/loadlib.c
index 808368b..0d401eb 100644
--- a/src/host/lua-5.1.2/src/loadlib.c
+++ b/src/host/lua-5.1.4/src/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -506,8 +506,10 @@ static int ll_require (lua_State *L) {
static void setfenv (lua_State *L) {
lua_Debug ar;
- lua_getstack(L, 1, &ar);
- lua_getinfo(L, "f", &ar);
+ if (lua_getstack(L, 1, &ar) == 0 ||
+ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
+ lua_iscfunction(L, -1))
+ luaL_error(L, LUA_QL("module") " not called from a Lua function");
lua_pushvalue(L, -2);
lua_setfenv(L, -2);
lua_pop(L, 1);
diff --git a/src/host/lua-5.1.2/src/lobject.c b/src/host/lua-5.1.4/src/lobject.c
index acde82c..4ff5073 100644
--- a/src/host/lua-5.1.2/src/lobject.c
+++ b/src/host/lua-5.1.4/src/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $
+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lobject.h b/src/host/lua-5.1.4/src/lobject.h
index 8ce4405..f1e447e 100644
--- a/src/host/lua-5.1.2/src/lobject.h
+++ b/src/host/lua-5.1.4/src/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
+** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -208,7 +208,7 @@ typedef union TString {
#define getstr(ts) cast(const char *, (ts) + 1)
-#define svalue(o) getstr(tsvalue(o))
+#define svalue(o) getstr(rawtsvalue(o))
diff --git a/src/host/lua-5.1.2/src/lopcodes.c b/src/host/lua-5.1.4/src/lopcodes.c
index bf9cd52..4cc7452 100644
--- a/src/host/lua-5.1.2/src/lopcodes.c
+++ b/src/host/lua-5.1.4/src/lopcodes.c
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $
+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lopcodes.h b/src/host/lua-5.1.4/src/lopcodes.h
index 48105f1..41224d6 100644
--- a/src/host/lua-5.1.2/src/lopcodes.h
+++ b/src/host/lua-5.1.4/src/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $
+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/loslib.c b/src/host/lua-5.1.4/src/loslib.c
index fdda474..da06a57 100644
--- a/src/host/lua-5.1.2/src/loslib.c
+++ b/src/host/lua-5.1.4/src/loslib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $
+** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/
@@ -215,7 +215,6 @@ static int os_setlocale (lua_State *L) {
static int os_exit (lua_State *L) {
exit(luaL_optint(L, 1, EXIT_SUCCESS));
- return 0; /* to avoid warnings */
}
static const luaL_Reg syslib[] = {
diff --git a/src/host/lua-5.1.2/src/lparser.c b/src/host/lua-5.1.4/src/lparser.c
index 6c473c4..1e2a9a8 100644
--- a/src/host/lua-5.1.2/src/lparser.c
+++ b/src/host/lua-5.1.4/src/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $
+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -938,6 +938,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
primaryexp(ls, &nv.v);
if (nv.v.k == VLOCAL)
check_conflict(ls, lh, &nv.v);
+ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
+ "variables in assignment");
assignment(ls, &nv, nvars+1);
}
else { /* assignment -> `=' explist1 */
diff --git a/src/host/lua-5.1.2/src/lparser.h b/src/host/lua-5.1.4/src/lparser.h
index e5b5b57..18836af 100644
--- a/src/host/lua-5.1.2/src/lparser.h
+++ b/src/host/lua-5.1.4/src/lparser.h
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lstate.c b/src/host/lua-5.1.4/src/lstate.c
index 4bcb759..4313b83 100644
--- a/src/host/lua-5.1.2/src/lstate.c
+++ b/src/host/lua-5.1.4/src/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $
+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
@@ -93,7 +93,7 @@ static void preinit_state (lua_State *L, global_State *g) {
resethookcount(L);
L->openupval = NULL;
L->size_ci = 0;
- L->nCcalls = 0;
+ L->nCcalls = L->baseCcalls = 0;
L->status = 0;
L->base_ci = L->ci = NULL;
L->savedpc = NULL;
@@ -205,7 +205,7 @@ LUA_API void lua_close (lua_State *L) {
do { /* repeat until no more errors */
L->ci = L->base_ci;
L->base = L->top = L->ci->base;
- L->nCcalls = 0;
+ L->nCcalls = L->baseCcalls = 0;
} while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
lua_assert(G(L)->tmudata == NULL);
luai_userstateclose(L);
diff --git a/src/host/lua-5.1.2/src/lstate.h b/src/host/lua-5.1.4/src/lstate.h
index d296a4c..3bc575b 100644
--- a/src/host/lua-5.1.2/src/lstate.h
+++ b/src/host/lua-5.1.4/src/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
@@ -112,6 +112,7 @@ struct lua_State {
int stacksize;
int size_ci; /* size of array `base_ci' */
unsigned short nCcalls; /* number of nested C calls */
+ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
lu_byte hookmask;
lu_byte allowhook;
int basehookcount;
diff --git a/src/host/lua-5.1.2/src/lstring.c b/src/host/lua-5.1.4/src/lstring.c
index 4319930..4911315 100644
--- a/src/host/lua-5.1.2/src/lstring.c
+++ b/src/host/lua-5.1.4/src/lstring.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $
+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lstring.h b/src/host/lua-5.1.4/src/lstring.h
index 1d2e91e..73a2ff8 100644
--- a/src/host/lua-5.1.2/src/lstring.h
+++ b/src/host/lua-5.1.4/src/lstring.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $
+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
** String table (keep all strings handled by Lua)
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lstrlib.c b/src/host/lua-5.1.4/src/lstrlib.c
index fc7ae48..1b4763d 100644
--- a/src/host/lua-5.1.2/src/lstrlib.c
+++ b/src/host/lua-5.1.4/src/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -35,7 +35,8 @@ static int str_len (lua_State *L) {
static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
/* relative string position: negative means back from end */
- return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
+ if (pos < 0) pos += (ptrdiff_t)len + 1;
+ return (pos >= 0) ? pos : 0;
}
@@ -629,10 +630,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
lua_gettable(L, 3);
break;
}
- default: {
- luaL_argerror(L, 3, "string/function/table expected");
- return;
- }
}
if (!lua_toboolean(L, -1)) { /* nil or false? */
lua_pop(L, 1);
@@ -648,11 +645,15 @@ static int str_gsub (lua_State *L) {
size_t srcl;
const char *src = luaL_checklstring(L, 1, &srcl);
const char *p = luaL_checkstring(L, 2);
+ int tr = lua_type(L, 3);
int max_s = luaL_optint(L, 4, srcl+1);
int anchor = (*p == '^') ? (p++, 1) : 0;
int n = 0;
MatchState ms;
luaL_Buffer b;
+ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+ "string/function/table expected");
luaL_buffinit(L, &b);
ms.L = L;
ms.src_init = src;
diff --git a/src/host/lua-5.1.2/src/ltable.c b/src/host/lua-5.1.4/src/ltable.c
index bc91cac..ec84f4f 100644
--- a/src/host/lua-5.1.2/src/ltable.c
+++ b/src/host/lua-5.1.4/src/ltable.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -84,8 +84,8 @@ static const Node dummynode_ = {
static Node *hashnum (const Table *t, lua_Number n) {
unsigned int a[numints];
int i;
- n += 1; /* normalize number (avoid -0) */
- lua_assert(sizeof(a) <= sizeof(n));
+ if (luai_numeq(n, 0)) /* avoid problems with -0 */
+ return gnode(t, 0);
memcpy(a, &n, sizeof(a));
for (i = 1; i < numints; i++) a[0] += a[i];
return hashmod(t, a[0]);
diff --git a/src/host/lua-5.1.2/src/ltable.h b/src/host/lua-5.1.4/src/ltable.h
index 09193cd..f5b9d5e 100644
--- a/src/host/lua-5.1.2/src/ltable.h
+++ b/src/host/lua-5.1.4/src/ltable.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $
+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/ltablib.c b/src/host/lua-5.1.4/src/ltablib.c
index 453b23b..b6d9cb4 100644
--- a/src/host/lua-5.1.2/src/ltablib.c
+++ b/src/host/lua-5.1.4/src/ltablib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $
+** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -118,7 +118,8 @@ static int tinsert (lua_State *L) {
static int tremove (lua_State *L) {
int e = aux_getn(L, 1);
int pos = luaL_optint(L, 2, e);
- if (e == 0) return 0; /* table is `empty' */
+ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
+ return 0; /* nothing to remove */
luaL_setn(L, 1, e - 1); /* t.n = n-1 */
lua_rawgeti(L, 1, pos); /* result = t[pos] */
for ( ;pos<e; pos++) {
@@ -131,6 +132,15 @@ static int tremove (lua_State *L) {
}
+static void addfield (lua_State *L, luaL_Buffer *b, int i) {
+ lua_rawgeti(L, 1, i);
+ if (!lua_isstring(L, -1))
+ luaL_error(L, "invalid value (%s) at index %d in table for "
+ LUA_QL("concat"), luaL_typename(L, -1), i);
+ luaL_addvalue(b);
+}
+
+
static int tconcat (lua_State *L) {
luaL_Buffer b;
size_t lsep;
@@ -140,13 +150,12 @@ static int tconcat (lua_State *L) {
i = luaL_optint(L, 3, 1);
last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
luaL_buffinit(L, &b);
- for (; i <= last; i++) {
- lua_rawgeti(L, 1, i);
- luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings");
- luaL_addvalue(&b);
- if (i != last)
- luaL_addlstring(&b, sep, lsep);
+ for (; i < last; i++) {
+ addfield(L, &b, i);
+ luaL_addlstring(&b, sep, lsep);
}
+ if (i == last) /* add last value (if interval was not empty) */
+ addfield(L, &b, i);
luaL_pushresult(&b);
return 1;
}
diff --git a/src/host/lua-5.1.2/src/ltm.c b/src/host/lua-5.1.4/src/ltm.c
index 097b815..c27f0f6 100644
--- a/src/host/lua-5.1.2/src/ltm.c
+++ b/src/host/lua-5.1.4/src/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $
+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/ltm.h b/src/host/lua-5.1.4/src/ltm.h
index 866c796..64343b7 100644
--- a/src/host/lua-5.1.2/src/ltm.h
+++ b/src/host/lua-5.1.4/src/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $
+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lua.c b/src/host/lua-5.1.4/src/lua.c
index 5cee7fa..3a46609 100644
--- a/src/host/lua-5.1.2/src/lua.c
+++ b/src/host/lua-5.1.4/src/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -74,6 +74,8 @@ static int report (lua_State *L, int status) {
static int traceback (lua_State *L) {
+ if (!lua_isstring(L, 1)) /* 'message' not a string? */
+ return 1; /* keep it intact */
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
@@ -144,7 +146,7 @@ static int dostring (lua_State *L, const char *s, const char *name) {
static int dolibrary (lua_State *L, const char *name) {
lua_getglobal(L, "require");
lua_pushstring(L, name);
- return report(L, lua_pcall(L, 1, 0, 0));
+ return report(L, docall(L, 1, 1));
}
diff --git a/src/host/lua-5.1.2/src/lua.h b/src/host/lua-5.1.4/src/lua.h
index 2865a7f..e4bdfd3 100644
--- a/src/host/lua-5.1.2/src/lua.h
+++ b/src/host/lua-5.1.4/src/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
** Lua - An Extensible Extension Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
#define LUA_VERSION "Lua 5.1"
-#define LUA_RELEASE "Lua 5.1.2"
+#define LUA_RELEASE "Lua 5.1.4"
#define LUA_VERSION_NUM 501
-#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
@@ -294,6 +294,9 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
#define lua_Chunkwriter lua_Writer
+/* hack */
+LUA_API void lua_setlevel (lua_State *from, lua_State *to);
+
/*
** {======================================================================
@@ -359,7 +362,7 @@ struct lua_Debug {
/******************************************************************************
-* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved.
+* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
diff --git a/src/host/lua-5.1.2/src/luac.c b/src/host/lua-5.1.4/src/luac.c
index d070173..d070173 100644
--- a/src/host/lua-5.1.2/src/luac.c
+++ b/src/host/lua-5.1.4/src/luac.c
diff --git a/src/host/lua-5.1.2/src/luaconf.h b/src/host/lua-5.1.4/src/luaconf.h
index cfc12dc..e2cb261 100644
--- a/src/host/lua-5.1.2/src/luaconf.h
+++ b/src/host/lua-5.1.4/src/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $
+** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -440,9 +440,10 @@
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C
-** functions to consume unlimited stack space.
+** functions to consume unlimited stack space. (must be smaller than
+** -LUA_REGISTRYINDEX)
*/
-#define LUAI_MAXCSTACK 2048
+#define LUAI_MAXCSTACK 8000
@@ -666,7 +667,7 @@ union luai_Cast { double l_d; long l_l; };
*/
#if defined(LUA_USE_POPEN)
-#define lua_popen(L,c,m) ((void)L, popen(c,m))
+#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
@@ -756,11 +757,6 @@ union luai_Cast { double l_d; long l_l; };
** without modifying the main part of the file.
*/
-/* JP - disable Visual Studio warnings */
-#if _MSC_VER
-#pragma warning(disable:4127) /* conditional expression is constant */
-#pragma warning(disable:4702) /* unreachable code detected */
-#endif
#endif
diff --git a/src/host/lua-5.1.2/src/lualib.h b/src/host/lua-5.1.4/src/lualib.h
index 0c76232..469417f 100644
--- a/src/host/lua-5.1.2/src/lualib.h
+++ b/src/host/lua-5.1.4/src/lualib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lundump.c b/src/host/lua-5.1.4/src/lundump.c
index 7fc635e..8010a45 100644
--- a/src/host/lua-5.1.2/src/lundump.c
+++ b/src/host/lua-5.1.4/src/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
+** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -29,6 +29,7 @@ typedef struct {
#ifdef LUAC_TRUST_BINARIES
#define IF(c,s)
+#define error(S,s)
#else
#define IF(c,s) if (c) error(S,s)
@@ -113,7 +114,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setnilvalue(o);
break;
case LUA_TBOOLEAN:
- setbvalue(o,LoadChar(S));
+ setbvalue(o,LoadChar(S)!=0);
break;
case LUA_TNUMBER:
setnvalue(o,LoadNumber(S));
@@ -122,7 +123,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setsvalue2n(S->L,o,LoadString(S));
break;
default:
- IF (1, "bad constant");
+ error(S,"bad constant");
break;
}
}
@@ -159,7 +160,9 @@ static void LoadDebug(LoadState* S, Proto* f)
static Proto* LoadFunction(LoadState* S, TString* p)
{
- Proto* f=luaF_newproto(S->L);
+ Proto* f;
+ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
+ f=luaF_newproto(S->L);
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
f->source=LoadString(S); if (f->source==NULL) f->source=p;
f->linedefined=LoadInt(S);
@@ -173,6 +176,7 @@ static Proto* LoadFunction(LoadState* S, TString* p)
LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code");
S->L->top--;
+ S->L->nCcalls--;
return f;
}
diff --git a/src/host/lua-5.1.2/src/lundump.h b/src/host/lua-5.1.4/src/lundump.h
index 58cca5d..c80189d 100644
--- a/src/host/lua-5.1.2/src/lundump.h
+++ b/src/host/lua-5.1.4/src/lundump.h
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lvm.c b/src/host/lua-5.1.4/src/lvm.c
index 08802f4..ee3256a 100644
--- a/src/host/lua-5.1.2/src/lvm.c
+++ b/src/host/lua-5.1.4/src/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -61,11 +61,9 @@ static void traceexec (lua_State *L, const Instruction *pc) {
lu_byte mask = L->hookmask;
const Instruction *oldpc = L->savedpc;
L->savedpc = pc;
- if (mask > LUA_MASKLINE) { /* instruction-hook set? */
- if (L->hookcount == 0) {
- resethookcount(L);
- luaD_callhook(L, LUA_HOOKCOUNT, -1);
- }
+ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
+ resethookcount(L);
+ luaD_callhook(L, LUA_HOOKCOUNT, -1);
}
if (mask & LUA_MASKLINE) {
Proto *p = ci_func(L->ci)->l.p;
diff --git a/src/host/lua-5.1.2/src/lvm.h b/src/host/lua-5.1.4/src/lvm.h
index 788423f..bfe4f56 100644
--- a/src/host/lua-5.1.2/src/lvm.h
+++ b/src/host/lua-5.1.4/src/lvm.h
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $
+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lzio.c b/src/host/lua-5.1.4/src/lzio.c
index 5121ada..293edd5 100644
--- a/src/host/lua-5.1.2/src/lzio.c
+++ b/src/host/lua-5.1.4/src/lzio.c
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $
+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
** a generic input stream interface
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/lzio.h b/src/host/lua-5.1.4/src/lzio.h
index 8f403b8..51d695d 100644
--- a/src/host/lua-5.1.2/src/lzio.h
+++ b/src/host/lua-5.1.4/src/lzio.h
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
** Buffered streams
** See Copyright Notice in lua.h
*/
diff --git a/src/host/lua-5.1.2/src/print.c b/src/host/lua-5.1.4/src/print.c
index e240cfc..e240cfc 100644
--- a/src/host/lua-5.1.2/src/print.c
+++ b/src/host/lua-5.1.4/src/print.c
diff --git a/src/host/lua-5.1.2/test/README b/src/host/lua-5.1.4/test/README
index 0c7f38b..0c7f38b 100644
--- a/src/host/lua-5.1.2/test/README
+++ b/src/host/lua-5.1.4/test/README
diff --git a/src/host/lua-5.1.2/test/bisect.lua b/src/host/lua-5.1.4/test/bisect.lua
index f91e69b..f91e69b 100644
--- a/src/host/lua-5.1.2/test/bisect.lua
+++ b/src/host/lua-5.1.4/test/bisect.lua
diff --git a/src/host/lua-5.1.2/test/cf.lua b/src/host/lua-5.1.4/test/cf.lua
index 8cda54b..8cda54b 100644
--- a/src/host/lua-5.1.2/test/cf.lua
+++ b/src/host/lua-5.1.4/test/cf.lua
diff --git a/src/host/lua-5.1.2/test/echo.lua b/src/host/lua-5.1.4/test/echo.lua
index 4313439..4313439 100644
--- a/src/host/lua-5.1.2/test/echo.lua
+++ b/src/host/lua-5.1.4/test/echo.lua
diff --git a/src/host/lua-5.1.2/test/env.lua b/src/host/lua-5.1.4/test/env.lua
index 9e62a57..9e62a57 100644
--- a/src/host/lua-5.1.2/test/env.lua
+++ b/src/host/lua-5.1.4/test/env.lua
diff --git a/src/host/lua-5.1.2/test/factorial.lua b/src/host/lua-5.1.4/test/factorial.lua
index 7c4cf0f..7c4cf0f 100644
--- a/src/host/lua-5.1.2/test/factorial.lua
+++ b/src/host/lua-5.1.4/test/factorial.lua
diff --git a/src/host/lua-5.1.2/test/fib.lua b/src/host/lua-5.1.4/test/fib.lua
index 97a921b..97a921b 100644
--- a/src/host/lua-5.1.2/test/fib.lua
+++ b/src/host/lua-5.1.4/test/fib.lua
diff --git a/src/host/lua-5.1.2/test/fibfor.lua b/src/host/lua-5.1.4/test/fibfor.lua
index 8bbba39..8bbba39 100644
--- a/src/host/lua-5.1.2/test/fibfor.lua
+++ b/src/host/lua-5.1.4/test/fibfor.lua
diff --git a/src/host/lua-5.1.2/test/globals.lua b/src/host/lua-5.1.4/test/globals.lua
index d4c20e1..d4c20e1 100644
--- a/src/host/lua-5.1.2/test/globals.lua
+++ b/src/host/lua-5.1.4/test/globals.lua
diff --git a/src/host/lua-5.1.2/test/hello.lua b/src/host/lua-5.1.4/test/hello.lua
index 0925498..0925498 100644
--- a/src/host/lua-5.1.2/test/hello.lua
+++ b/src/host/lua-5.1.4/test/hello.lua
diff --git a/src/host/lua-5.1.2/test/life.lua b/src/host/lua-5.1.4/test/life.lua
index 911d9fe..911d9fe 100644
--- a/src/host/lua-5.1.2/test/life.lua
+++ b/src/host/lua-5.1.4/test/life.lua
diff --git a/src/host/lua-5.1.2/test/luac.lua b/src/host/lua-5.1.4/test/luac.lua
index 96a0a97..96a0a97 100644
--- a/src/host/lua-5.1.2/test/luac.lua
+++ b/src/host/lua-5.1.4/test/luac.lua
diff --git a/src/host/lua-5.1.2/test/printf.lua b/src/host/lua-5.1.4/test/printf.lua
index 58c63ff..58c63ff 100644
--- a/src/host/lua-5.1.2/test/printf.lua
+++ b/src/host/lua-5.1.4/test/printf.lua
diff --git a/src/host/lua-5.1.2/test/readonly.lua b/src/host/lua-5.1.4/test/readonly.lua
index 85c0b4e..85c0b4e 100644
--- a/src/host/lua-5.1.2/test/readonly.lua
+++ b/src/host/lua-5.1.4/test/readonly.lua
diff --git a/src/host/lua-5.1.2/test/sieve.lua b/src/host/lua-5.1.4/test/sieve.lua
index 0871bb2..0871bb2 100644
--- a/src/host/lua-5.1.2/test/sieve.lua
+++ b/src/host/lua-5.1.4/test/sieve.lua
diff --git a/src/host/lua-5.1.2/test/sort.lua b/src/host/lua-5.1.4/test/sort.lua
index 0bcb15f..0bcb15f 100644
--- a/src/host/lua-5.1.2/test/sort.lua
+++ b/src/host/lua-5.1.4/test/sort.lua
diff --git a/src/host/lua-5.1.2/test/table.lua b/src/host/lua-5.1.4/test/table.lua
index 235089c..235089c 100644
--- a/src/host/lua-5.1.2/test/table.lua
+++ b/src/host/lua-5.1.4/test/table.lua
diff --git a/src/host/lua-5.1.2/test/trace-calls.lua b/src/host/lua-5.1.4/test/trace-calls.lua
index 6d7a7b3..6d7a7b3 100644
--- a/src/host/lua-5.1.2/test/trace-calls.lua
+++ b/src/host/lua-5.1.4/test/trace-calls.lua
diff --git a/src/host/lua-5.1.2/test/trace-globals.lua b/src/host/lua-5.1.4/test/trace-globals.lua
index 295e670..295e670 100644
--- a/src/host/lua-5.1.2/test/trace-globals.lua
+++ b/src/host/lua-5.1.4/test/trace-globals.lua
diff --git a/src/host/lua-5.1.2/test/xd.lua b/src/host/lua-5.1.4/test/xd.lua
index ebc3eff..ebc3eff 100644
--- a/src/host/lua-5.1.2/test/xd.lua
+++ b/src/host/lua-5.1.4/test/xd.lua