.gear-rules | 2 + .../899e61f82439ab4671d99b12c6c82a82e4022beb | 13 + .gear-tags/list | 1 + COPYRIGHT | 4 + doc/lua.1 | 2 + doc/manual.html | 2 +- etc/lua.pc | 32 +-- lua5.spec | 310 ++++++++++++++++++++ src/lapi.c | 5 + src/lauxlib.c | 4 +- src/lcode.c | 22 +- src/ldblib.c | 1 + src/ldo.c | 2 +- src/liblua.map | 17 + src/luaconf.h | 25 ++- src/lvm.c | 5 +- 16 files changed, 400 insertions(+), 47 deletions(-) diff --git a/.gear-rules b/.gear-rules new file mode 100644 index 0000000..059fd57 --- /dev/null +++ b/.gear-rules @@ -0,0 +1,2 @@ +tar: @version@:. name=lua-@version@ +diff: @version@:. . diff --git a/.gear-tags/899e61f82439ab4671d99b12c6c82a82e4022beb b/.gear-tags/899e61f82439ab4671d99b12c6c82a82e4022beb new file mode 100644 index 0000000..4e29319 --- /dev/null +++ b/.gear-tags/899e61f82439ab4671d99b12c6c82a82e4022beb @@ -0,0 +1,13 @@ +object 520d14dafcf4b691f185b337d648b862b835ddfc +type commit +tag 5.1.4 +tagger Alexey Tourbin 1254088071 +0400 + +5.1.4 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (GNU/Linux) + +iEYEABECAAYFAkq/3YcACgkQfBKgtDjnu0a+ewCfQXaTpSTXs7480pyRzhxMF+dW +YA4An0EHUYe8p6rE8eNB/va/4L6Q3QYm +=jtPH +-----END PGP SIGNATURE----- diff --git a/.gear-tags/list b/.gear-tags/list new file mode 100644 index 0000000..4d411ba --- /dev/null +++ b/.gear-tags/list @@ -0,0 +1 @@ +899e61f82439ab4671d99b12c6c82a82e4022beb 5.1.4 diff --git a/COPYRIGHT b/COPYRIGHT index 3a53e74..82805c2 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -32,3 +32,7 @@ THE SOFTWARE. =============================================================================== (end of COPYRIGHT) + +The Lua command line interpeter of this build uses the GNU readline library, +which is subject to the GNU General Public License. However, the Lua library +itself does not link with readline and thus is not tainted by the GPL. diff --git a/doc/lua.1 b/doc/lua.1 index 24809cc..6e94adb 100644 --- a/doc/lua.1 +++ b/doc/lua.1 @@ -152,6 +152,8 @@ show version information. .SH "SEE ALSO" .BR luac (1) .br +lua5-doc package +.br http://www.lua.org/ .SH DIAGNOSTICS Error messages should be self explanatory. diff --git a/doc/manual.html b/doc/manual.html index f46f17c..5ee4b5a 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2550,7 +2550,7 @@ Sets a new panic function and returns the old one.

If an error happens outside any protected environment, Lua calls a panic function -and then calls exit(EXIT_FAILURE), +and then calls abort(), thus exiting the host application. Your panic function can avoid this exit by never returning (e.g., doing a long jump). diff --git a/etc/lua.pc b/etc/lua.pc index f52f55b..5d4fe94 100644 --- a/etc/lua.pc +++ b/etc/lua.pc @@ -1,31 +1,5 @@ -# lua.pc -- pkg-config data for Lua - -# vars from install Makefile - -# grep '^V=' ../Makefile -V= 5.1 -# grep '^R=' ../Makefile -R= 5.1.4 - -# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' -prefix= /usr/local -INSTALL_BIN= ${prefix}/bin -INSTALL_INC= ${prefix}/include -INSTALL_LIB= ${prefix}/lib -INSTALL_MAN= ${prefix}/man/man1 -INSTALL_LMOD= ${prefix}/share/lua/${V} -INSTALL_CMOD= ${prefix}/lib/lua/${V} - -# canonical vars -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include - Name: Lua Description: An Extensible Extension Language -Version: ${R} -Requires: -Libs: -L${libdir} -llua -lm -Cflags: -I${includedir} - -# (end of lua.pc) +Version: 5.1.4 +Libs: -llua +Libs.private: -lm -ldl diff --git a/lua5.spec b/lua5.spec new file mode 100644 index 0000000..5eadbfd --- /dev/null +++ b/lua5.spec @@ -0,0 +1,310 @@ +Name: lua5 +Version: 5.1.4 +Release: alt1 + +Summary: Embeddable programming language +License: MIT +Group: Development/Other + +URL: http://www.lua.org +Source: lua-%version.tar +Patch: %name-%version-%release.patch + +Requires: liblua5.1 = %version-%release +Provides: lua = %version +Conflicts: lua4 + +# Automatically added by buildreq on Mon Sep 28 2009 +BuildRequires: libreadline-devel + +%package -n liblua5.1 +Summary: Embeddable programming language +Group: System/Libraries + +%package -n liblua5-devel +Summary: Embeddable programming language +Group: Development/Other +Requires: liblua5.1 = %version-%release +Conflicts: liblua4-devel + +%package -n liblua5-devel-static +Summary: Embeddable programming language +Group: Development/Other +Requires: liblua5-devel = %version-%release +Conflicts: liblua4-devel-static + +%package doc +Summary: Embeddable programming language +Group: Development/Documentation +Conflicts: lua5 < 5.1.1-alt2 +BuildArch: noarch + +%description +Lua is a powerful, light-weight programming language designed for extending +applications. The language engine is accessible as a library, having a C +API which allows the application to exchange data with Lua programs and also +to extend Lua with C functions. Lua is also used as a general-purpose, +stand-alone language through the simple command line interpreter provided. + +%description -n liblua5.1 +Lua is a powerful, light-weight programming language designed for extending +applications. The language engine is accessible as a library, having a C +API which allows the application to exchange data with Lua programs and also +to extend Lua with C functions. Lua is also used as a general-purpose, +stand-alone language through the simple command line interpreter provided. + +%description -n liblua5-devel +Lua is a powerful, light-weight programming language designed for extending +applications. The language engine is accessible as a library, having a C +API which allows the application to exchange data with Lua programs and also +to extend Lua with C functions. Lua is also used as a general-purpose, +stand-alone language through the simple command line interpreter provided. + +%description -n liblua5-devel-static +Lua is a powerful, light-weight programming language designed for extending +applications. The language engine is accessible as a library, having a C +API which allows the application to exchange data with Lua programs and also +to extend Lua with C functions. Lua is also used as a general-purpose, +stand-alone language through the simple command line interpreter provided. + +%description doc +Lua is a powerful, light-weight programming language designed for extending +applications. The language engine is accessible as a library, having a C +API which allows the application to exchange data with Lua programs and also +to extend Lua with C functions. Lua is also used as a general-purpose, +stand-alone language through the simple command line interpreter provided. + +%prep +%setup -q -n lua-%version +%patch -p1 + +%build +%def_enable Werror + +cd ./src +# from Makefile +core='lapi lcode ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio' +lib='lauxlib lbaselib ldblib liolib lmathlib loslib ltablib lstrlib loadlib linit' + +for f in $core $lib; do gcc %optflags -c $f.c; done +ar rcu liblua.a *.o +ranlib liblua.a + +%define soffix -5.1.so.0 +for f in $core $lib; do gcc %optflags %optflags_shared -c $f.c; done +gcc -shared -o liblua%soffix -Wl,-soname=liblua%soffix -Wl,--version-script=liblua.map -Wl,-z,defs *.o -lm -ldl + +gcc -o lua %optflags lua.c ./liblua%soffix -lreadline +gcc -o luac %optflags luac.c print.c ./liblua%soffix + +LD_LIBRARY_PATH=$PWD ./lua ../test/hello.lua + +%install +%define pkgdocdir %_docdir/lua-5.1 +mkdir -p %buildroot{%_libdir,%_bindir,%_includedir,%_man1dir,%pkgdocdir/html} + +cd ./src +cp -p liblua.a liblua%soffix %buildroot%_libdir/ +ln -s liblua%soffix %buildroot%_libdir/liblua.so +cp -p lua %buildroot%_bindir/lua5.1 +cp -p luac %buildroot%_bindir/luac5.1 +ln -s lua5.1 %buildroot%_bindir/lua +ln -s luac5.1 %buildroot%_bindir/luac +cp -p lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp %buildroot%_includedir/ +install -pD -m644 ../etc/lua.pc %buildroot%_pkgconfigdir/lua.pc + +cd .. +cp -av COPYRIGHT HISTORY README etc test %buildroot%pkgdocdir/ +cd ./doc +cp -p lua.1 %buildroot%_man1dir/lua5.1.1 +cp -p luac.1 %buildroot%_man1dir/luac5.1.1 +ln -s lua5.1.1 %buildroot%_man1dir/lua.1 +ln -s luac5.1.1 %buildroot%_man1dir/luac.1 +cp -p *.html *.css *.gif *.png %buildroot%pkgdocdir/html/ +mv %buildroot%pkgdocdir/html/{readme,index}.html + +mkdir -p %buildroot{%_libdir,%_datadir}/lua5 + +%files +%_bindir/lua* +%_man1dir/lua* + +%files -n liblua5.1 +%_libdir/liblua%soffix +%dir %_libdir/lua5 +%dir %_datadir/lua5 +%dir %pkgdocdir +%pkgdocdir/COPYRIGHT +%pkgdocdir/HISTORY +%pkgdocdir/README + +%files -n liblua5-devel +%_includedir/*.* +%_libdir/liblua.so +%_pkgconfigdir/lua.pc + +%files -n liblua5-devel-static +%_libdir/liblua.a + +%files doc +%dir %pkgdocdir +%pkgdocdir/html +%pkgdocdir/etc +%pkgdocdir/test + +%changelog +* Mon Sep 28 2009 Alexey Tourbin 5.1.4-alt1 +- 5.1.3 -> 5.1.4 +- applied 3 official patches from lua.org/bugs.html +- reverted lua-5.0 compatibility hacks +- disabled APICHECK to workaround assertion failures (#18557) + +* Tue Jun 24 2008 Alexey Tourbin 5.1.3-alt2.1 +- spec: removed "BuildArch: %%_target_cpu" + +* Sun Jun 22 2008 Alexey Tourbin 5.1.3-alt2 +- http://www.lua.org/ftp/patch-lua-5.1.3 (20080508) +- made lua5-doc package noarch + +* Sat Mar 01 2008 Alexey Tourbin 5.1.3-alt1 +- 5.1.2 -> 5.1.3 + +* Wed Oct 24 2007 Alexey Tourbin 5.1.2-alt4 +- luaconf.h (lua_popen): call fflush(NULL) before popen() +- applied 1 more official patch from lua.org/bugs.html: + + An error in a module loaded through the '-l' option shows no traceback. + +* Sun Aug 12 2007 Alexey Tourbin 5.1.2-alt3 +- applied 2 more official patches from lua.org/bugs.html: + + Very small numbers all collide in the hash function. + + Too many variables in an assignment may cause a C stack overflow. +- changed src.rpm packaging to keep unmodified upstream tarball + +* Sun Jun 17 2007 Alexey Tourbin 5.1.2-alt2 +- applied official patches from lua.org/bugs.html: + + Code generated for "-nil", "-true", and "-false" is wrong. + + Count hook may be called without being set. + + Wrong error message in some concatenations. +- ldo.c (luaD_throw): abort() instead of exit(EXIT_FAILURE) +- relaxed lua5-doc dependencies + +* Wed Apr 04 2007 Alexey Tourbin 5.1.2-alt1 +- updated to 5.1.2 +- installed %_pkgconfigdir/lua.pc + +* Mon Mar 19 2007 Alexey Tourbin 5.1.1-alt3 +- applied 3 more official patches from lua.org/bugs.html +- in the COPYRIGHT file, added notice about readline/GPL + +* Sat Oct 14 2006 Alexey Tourbin 5.1.1-alt2 +- imported sources into git and built with gear +- applied 3 official patches from lua.org/bugs.html +- added version script for the shared library to avoid static luac linkage +- split html documentation and examples into separate lua5-doc subpackage + +* Mon Jun 12 2006 Alexey Tourbin 5.1.1-alt1 +- 5.1 -> 5.1.1 + +* Tue May 16 2006 Alexey Tourbin 5.1-alt1 +- 5.0.2 -> 5.1 +- changed soname to liblua-5.1.so.0 +- applied fixes for known bugs from lua.org +- removed alternatives, lua4 goes obsolete + +* Fri Dec 30 2005 ALT QA Team Robot 5.0.2-alt5.1 +- Rebuilt with libreadline.so.5. + +* Wed Jun 29 2005 Alexey Tourbin 5.0.2-alt5 +- fixed segfaults introduced in previous release (type casts) +- fixed linkage (linked liblualib.so with liblua.so) + +* Sat Jun 11 2005 Alexey Tourbin 5.0.2-alt4 +- compat-5.1r2 -> compat-5.1r3 +- in sync with Debian: lua50_5.0.2-5.diff.gz +- fixed invalid type casts on x86_64 (Kachalov Anton, #6539) + +* Mon May 09 2005 Alexey Tourbin 5.0.2-alt3 +- packaged Compat-5.1 (implementation of Lua-5.1 package proposal) +- applied 3 official patches from http://www.lua.org/bugs.html +- removed old dependencies + +* Sat Sep 18 2004 Alexey Tourbin 5.0.2-alt2 +- %_datadir/lua5/loadlib.lua -- implemented require()-like path search + for loadlib(); compiled extensions should reside in %_libdir/lua5 +- added %_datadir/lua5 to default LUA_PATH +- enabled os.tmpname() +- upgraded to new alternatives format + +* Fri Mar 19 2004 Alexey Tourbin 5.0.2-alt1 +- updated to 5.0.2 release +- enabled partial compatibility with old upvalue syntax +- pedro-openbsd-snprintf.patch: use snprintf(3) instead of sprintf(3) + +* Sun Mar 07 2004 Alexey Tourbin 5.0.2-alt0.1 +- updated to 5.0.2 pre-release, with all official patches in + +* Mon Feb 23 2004 Alexey Tourbin 5.0-alt7.2 +- %_docdir/lua5-%version -> %_docdir/lua-%version +- fixed luac symilnk (alternatives) + +* Mon Feb 02 2004 Alexey Tourbin 5.0-alt7.1 +- fixed %_docdir/lua5-%version ownership + +* Fri Jan 30 2004 Alexey Tourbin 5.0-alt7 +- fixed _customdocdir misusage +- Werror mode enabled + +* Tue Nov 18 2003 Alexey Tourbin 5.0-alt6 +- 5 more official patches applied + +* Sun Aug 24 2003 Alexey Tourbin 5.0-alt5 +- moved lua4 (weight=10) and lua5 (weight=20) packages under alternatives control +- in sync with debian (deb-paths.patch): + + Added support for -C to load compatibility library on startup + + Added an initial LUA_PATH to support /usr/share/lua5 etc. + + Added a -P switch to suppress the LUA_PATH code if need-be + + Updated the manpage lua.1 for the -C and -P switches + +* Fri Jun 20 2003 Alexey Tourbin 5.0-alt4 +- packages renamed: s/lua/lua5/ +- lua4 will be kept; thus Provides/Obsoletes reconsidered, Conflicts added +- two patches from http://www.lua.org/bugs.html +- Sisyphus release + +* Wed May 07 2003 Alexey Tourbin 5.0-alt3 +- added Provides and Obsoletes for smooth upgrade + +* Mon May 05 2003 Alexey Tourbin 5.0-alt2 +- desert Makefile/config/patches; custom build with direct commands +- features enabled: dlopen (loadlib), popen, fastround, libreadline +- new package layout: lua, liblua, liblua-devel, liblua-devel-static + +* Mon Apr 28 2003 Alexey Tourbin 5.0-alt1 +- 5.0; API changes; soname changed; license: MIT +- loadlib now implemented, so drop that stuff borrowed from PLD + +* Sun Jan 19 2003 Alexey Tourbin 4.0.1-alt6 +- minor enhancements + +* Thu Dec 26 2002 Alexey Tourbin 4.0.1-alt5 +- corrected s/-lc/-lc -lm -ldl/ for liblualib.so in alt-soname patch +- shared optimization flags + +* Tue Dec 24 2002 Alexey Tourbin 4.0.1-alt4 +- error in previous build: *.so files are binary copy of *.so.* files, + not symlinks; fixed +- really shared build (s/ld -shared/ld -shared -lc/ in alt-soname patch) +- post and postun sections added (ldconfig) + +* Fri Dec 20 2002 Alexey Tourbin 4.0.1-alt3 +- shared build; alt-soname patch; lua-devel-static subpackage +- reference manual and code samples included in lua-devel package +- additional features from XTG Systems (loadlib files) and + PLD Team (pld-loadlib-require patch) +- buildreq applied (none) + +* Mon Oct 28 2002 Konstantin Volckov 4.0.1-alt2 +- Rebuilt in new environment + +* Wed Aug 28 2002 Konstantin Volckov 4.0.1-alt1 +- First build for Sisyphus diff --git a/src/lapi.c b/src/lapi.c index 5d5145d..8e97a48 100644 --- a/src/lapi.c +++ b/src/lapi.c @@ -1085,3 +1085,8 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { return name; } +/* XXX ABI compat */ +LUA_API const char *lua_version (void) { + return LUA_VERSION; +} + diff --git a/src/lauxlib.c b/src/lauxlib.c index 10f14e2..5dbb1af 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -275,7 +275,9 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname, ** ======================================================= */ -#if defined(LUA_COMPAT_GETN) +#if defined(LUA_COMPAT_GETN) || 1 /* XXX ABI compat */ +#undef luaL_getn +#undef luaL_setn static int checkint (lua_State *L, int topop) { int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; diff --git a/src/lcode.c b/src/lcode.c index cff626b..84f286b 100644 --- a/src/lcode.c +++ b/src/lcode.c @@ -544,15 +544,18 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always true; do nothing */ break; } - case VFALSE: { - pc = luaK_jump(fs); /* always jump */ - break; - } case VJMP: { invertjump(fs, e); pc = e->u.s.info; break; } + case VFALSE: { + if (!hasjumps(e)) { + pc = luaK_jump(fs); /* always jump */ + break; + } + /* else go through */ + } default: { pc = jumponcond(fs, e, 0); break; @@ -572,14 +575,17 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always false; do nothing */ break; } - case VTRUE: { - pc = luaK_jump(fs); /* always jump */ - break; - } case VJMP: { pc = e->u.s.info; break; } + case VTRUE: { + if (!hasjumps(e)) { + pc = luaK_jump(fs); /* always jump */ + break; + } + /* else go through */ + } default: { pc = jumponcond(fs, e, 1); break; diff --git a/src/ldblib.c b/src/ldblib.c index 67de122..21116ac 100644 --- a/src/ldblib.c +++ b/src/ldblib.c @@ -45,6 +45,7 @@ static int db_setmetatable (lua_State *L) { static int db_getfenv (lua_State *L) { + luaL_checkany(L, 1); lua_getfenv(L, 1); return 1; } diff --git a/src/ldo.c b/src/ldo.c index 8de05f7..b394f55 100644 --- a/src/ldo.c +++ b/src/ldo.c @@ -103,7 +103,7 @@ void luaD_throw (lua_State *L, int errcode) { lua_unlock(L); G(L)->panic(L); } - exit(EXIT_FAILURE); + abort(); } } diff --git a/src/liblua.map b/src/liblua.map new file mode 100644 index 0000000..703cd88 --- /dev/null +++ b/src/liblua.map @@ -0,0 +1,17 @@ +LUAC_PRIVATE { + global: + luaD_growstack; + luaF_newproto; + luaM_realloc_; + luaM_toobig; + luaP_opmodes; + luaP_opnames; + luaS_newlstr; + luaU_dump; + local: + lua[^Lo_]*; +}; +LUA_5.1.3 { + global: + lua_setlevel; +}; diff --git a/src/luaconf.h b/src/luaconf.h index e2cb261..17db0aa 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -33,6 +33,12 @@ #define LUA_WIN #endif +#ifdef __linux__ +#ifndef LUA_USE_LINUX +#define LUA_USE_LINUX +#endif +#endif + #if defined(LUA_USE_LINUX) #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ @@ -94,9 +100,13 @@ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_ROOT "/usr/" +#define LUA_LDIR LUA_ROOT "share/lua5/" +#if defined(__x86_64) || defined(__amd64) +#define LUA_CDIR LUA_ROOT "lib64/lua5/" +#else +#define LUA_CDIR LUA_ROOT "lib/lua5/" +#endif #define LUA_PATH_DEFAULT \ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" @@ -178,7 +188,10 @@ ** (versions 3.2 and later) mark them as "hidden" to optimize access ** when Lua is compiled as a shared library. */ -#if defined(luaall_c) +#if 1 +#define LUAI_FUNC extern +#define LUAI_DATA extern +#elif defined(luaall_c) #define LUAI_FUNC static #define LUAI_DATA /* empty */ @@ -259,7 +272,7 @@ @* stand-alone interpreter. ** CHANGE it if you need longer lines. */ -#define LUA_MAXINPUT 512 +#define LUA_MAXINPUT BUFSIZ /* @@ -667,7 +680,7 @@ union luai_Cast { double l_d; long l_l; }; */ #if defined(LUA_USE_POPEN) -#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_popen(L,c,m) ((void)L, (void)fflush(NULL), popen(c,m)) #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) #elif defined(LUA_WIN) diff --git a/src/lvm.c b/src/lvm.c index ee3256a..4ac2e71 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -133,6 +133,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { int loop; + TValue temp; for (loop = 0; loop < MAXTAGLOOP; loop++) { const TValue *tm; if (ttistable(t)) { /* `t' is a table? */ @@ -152,7 +153,9 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { callTM(L, tm, t, key, val); return; } - t = tm; /* else repeat with `tm' */ + /* else repeat with `tm' */ + setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */ + t = &temp; } luaG_runerror(L, "loop in settable"); }