# What to install.
TO_BIN= lua luac
-TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+TO_LIB= liblua.a liblua.so.$(V)
TO_MAN= lua.1 luac.1
# Lua version and release.
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)
+ ln -s liblua.so.$(V) $(INSTALL_LIB)/liblua.so
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
--- /dev/null
+liblua
+ targetarch ia64 block!
--- /dev/null
+* Fri Mar 22 2013 Anas Nashif <anas.nashif@intel.com> submit/trunk/20121215.004706@978b56f
+- Fixed package groups
+
+* Thu Feb 21 2013 Patrick McCarty <patrick.mccarty@linux.intel.com> 8fc91fd
+- Resolve rpmlint warnings
+- Install a /usr/bin/lua symlink
+
+* Fri Dec 14 2012 Anas Nashif <anas.nashif@intel.com> upstream/5.1.4@c9e8879
+- Update to version 5.1.4
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: lua
+Version: 5.1.4
+Release: 0
+License: MIT
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Url: http://www.lua.org
+Group: Base/Libraries
+Source: %{name}-%{version}.tar.gz
+Source1: macros.lua
+Source2: baselibs.conf
+Source1001: lua.manifest
+%define major_version 5.1
+BuildRequires: pkg-config
+BuildRequires: readline-devel
+
+%description
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%package devel
+Summary: Development files for lua
+Group: Development/Libraries
+Requires: %{name} = %{version}
+
+%description devel
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+This package contains files needed for embedding lua into your
+application.
+
+%package -n liblua
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Group: Base/Libraries
+
+%description -n liblua
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%package doc
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Group: Documentation
+BuildArch: noarch
+
+%description doc
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%prep
+%setup -q -n lua-%{version}
+cp %{SOURCE1001} .
+
+%build
+export LDFLAGS+=" -Wl,-E -ldl -lreadline -lhistory -lncurses"
+sed -i 's:LUA_ROOT2 "LIBDIR/lua/%{major_version}/":LUA_ROOT2 \"%{_lib}/lua/%{major_version}/":' src/luaconf.h
+make %{?_smp_mflags} -C src CC="%{__cc}" MYCFLAGS="%{optflags} -fPIC -DLUA_USE_LINUX" MYLIBS="$LDFLAGS" V=%{major_version} all
+
+%install
+make install INSTALL_TOP="%{buildroot}%{_prefix}" INSTALL_LIB="%{buildroot}%{_libdir}" INSTALL_CMOD=%{buildroot}%{_libdir}/lua/%{major_version} INSTALL_MAN="%{buildroot}%{_mandir}/man1"
+install -D -m644 etc/lua.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
+for file in lua luac ; do
+ mv "%{buildroot}%{_bindir}/${file}" "%{buildroot}%{_bindir}/${file}%{major_version}"
+ mv "%{buildroot}%{_mandir}/man1/${file}.1" "%{buildroot}%{_mandir}/man1/${file}%{major_version}.1"
+done
+install -d -m 0755 %{buildroot}%{_libdir}/lua/%{major_version}
+install -d -m 0755 %{buildroot}%{_datadir}/lua/%{major_version}
+install -D -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/macros.lua
+
+chmod +x %{buildroot}/%{_libdir}/liblua.so.%{major_version}
+
+ln -s lua%{major_version} %{buildroot}%{_bindir}/lua
+
+%post -n liblua -p /sbin/ldconfig
+
+%postun -n liblua -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_mandir}/man1/lua%{major_version}.1*
+%{_mandir}/man1/luac%{major_version}.1*
+%{_bindir}/lua
+%{_bindir}/lua%{major_version}
+%{_bindir}/luac%{major_version}
+%dir %{_libdir}/lua
+%dir %{_libdir}/lua/%{major_version}
+%dir %{_datadir}/lua
+%dir %{_datadir}/lua/%{major_version}
+%{_sysconfdir}/rpm/macros.lua
+
+%files -n liblua
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%license COPYRIGHT
+%{_libdir}/liblua.so.%{major_version}
+
+%files devel
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_includedir}/lauxlib.h
+%{_includedir}/lua.h
+%{_includedir}/lua.hpp
+%{_includedir}/luaconf.h
+%{_includedir}/lualib.h
+%{_libdir}/pkgconfig/lua.pc
+%{_libdir}/liblua.a
+%{_libdir}/liblua.so
+
+%files doc
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%doc doc/*
+
+%changelog
--- /dev/null
+# RPM macros for Lua
+
+# The major.minor version of Lua
+%lua_version %(lua -e 'print(_VERSION)' | cut -d ' ' -f 2)
+
+# compiled modules should go here
+%lua_archdir %{_libdir}/lua/%{lua_version}
+
+# pure Lua modules should go here
+%lua_noarchdir %{_datadir}/lua/%{lua_version}
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
-CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
- lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
- ltm.o lundump.o lvm.o lzio.o
-LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
- lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
-BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
+LUA_SO= liblua.so
+CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+ lundump.o lvm.o lzio.o
+LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
+ lstrlib.o loadlib.o linit.o
LUA_T= lua
LUA_O= lua.o
LUAC_T= luac
LUAC_O= luac.o
-ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+ALL_T= $(LUA_SO) $(LUA_A) $(LUA_T) $(LUAC_T)
ALL_A= $(LUA_A)
# Targets start here.
a: $(ALL_A)
-$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
+# shared libraries (for Linux)
+$(LUA_SO): $(CORE_O) $(LIB_O)
+ $(CC) -o $(LUA_SO).$V -shared -Wl,-soname,$(LUA_SO).$V $(CORE_O) $(LIB_O) -lm -ldl
+ ln -fs $(LUA_SO).$(V) $(LUA_SO)
+
+$(LUA_A): $(CORE_O) $(LIB_O)
+ $(AR) $@ $?
$(RANLIB) $@
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) -L. -llua $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+ $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) -L. -llua $(LIBS)
clean:
$(RM) $(ALL_T) $(ALL_O)
/*
-** $Id: lcode.c,v 2.109 2016/05/13 19:09:21 roberto Exp $
+** $Id: lcode.c,v 2.25.1.4 2009/06/15 14:12:25 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
pc = e->u.info; /* save jump position */
break;
}
- case VK: case VKFLT: case VKINT: case VTRUE: {
- pc = NO_JUMP; /* always true; do nothing */
+ 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); /* jump when false */
break;
int pc; /* pc of new jump */
luaK_dischargevars(fs, e);
switch (e->k) {
- case VJMP: {
- pc = e->u.info; /* already jump if true */
- break;
- }
case VNIL: case VFALSE: {
pc = NO_JUMP; /* always false; do nothing */
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); /* jump if true */
break;
/*
-** $Id: ldblib.c,v 1.151 2015/11/23 11:29:43 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
}
-static int db_getuservalue (lua_State *L) {
- if (lua_type(L, 1) != LUA_TUSERDATA)
- lua_pushnil(L);
- else
- lua_getuservalue(L, 1);
+static int db_getfenv (lua_State *L) {
+ luaL_checkany(L, 1);
+ lua_getfenv(L, 1);
return 1;
}
/*
-** $Id: liolib.c,v 2.149 2016/05/02 14:03:19 roberto Exp $
+** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
rn->c = l_getc(rn->f); /* read next one */
return 1;
}
-}
-
-
-/*
-** Accept current char if it is in 'set' (of size 2)
-*/
-static int test2 (RN *rn, const char *set) {
- if (rn->c == set[0] || rn->c == set[1])
- return nextc(rn);
- else return 0;
-}
-
-
-/*
-** Read a sequence of (hex)digits
-*/
-static int readdigits (RN *rn, int hex) {
- int count = 0;
- while ((hex ? isxdigit(rn->c) : isdigit(rn->c)) && nextc(rn))
- count++;
- return count;
-}
-
-
-/*
-** Read a number: first reads a valid prefix of a numeral into a buffer.
-** Then it calls 'lua_stringtonumber' to check whether the format is
-** correct and to convert it to a Lua number
-*/
-static int read_number (lua_State *L, FILE *f) {
- RN rn;
- int count = 0;
- int hex = 0;
- char decp[2];
- rn.f = f; rn.n = 0;
- decp[0] = lua_getlocaledecpoint(); /* get decimal point from locale */
- decp[1] = '.'; /* always accept a dot */
- l_lockfile(rn.f);
- do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */
- test2(&rn, "-+"); /* optional signal */
- if (test2(&rn, "00")) {
- if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */
- else count = 1; /* count initial '0' as a valid digit */
- }
- count += readdigits(&rn, hex); /* integral part */
- if (test2(&rn, decp)) /* decimal point? */
- count += readdigits(&rn, hex); /* fractional part */
- if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */
- test2(&rn, "-+"); /* exponent signal */
- readdigits(&rn, 0); /* exponent digits */
- }
- ungetc(rn.c, rn.f); /* unread look-ahead char */
- l_unlockfile(rn.f);
- rn.buff[rn.n] = '\0'; /* finish string */
- if (lua_stringtonumber(L, rn.buff)) /* is this a valid number? */
- return 1; /* ok */
- else { /* invalid format */
- lua_pushnil(L); /* "result" to be removed */
- return 0; /* read fails */
+ else {
+ lua_pushnil(L); /* "result" to be removed */
+ return 0; /* read fails */
}
}
/*
-** $Id: llex.c,v 2.96 2016/05/02 14:02:12 roberto Exp $
+** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
*/
TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
lua_State *L = ls->L;
- TValue *o; /* entry for 'str' */
- TString *ts = luaS_newlstr(L, str, l); /* create new string */
- setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
- o = luaH_set(L, ls->h, L->top - 1);
- if (ttisnil(o)) { /* not in use yet? */
- /* boolean value does not need GC barrier;
- table has no metatable, so it does not need to invalidate cache */
- setbvalue(o, 1); /* t[string] = true */
+ TString *ts = luaS_newlstr(L, str, l);
+ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
+ if (ttisnil(o)) {
+ setbvalue(o, 1); /* make sure `str' will not be collected */
luaC_checkGC(L);
}
- else { /* string already present */
- ts = tsvalue(keyfromval(o)); /* re-use value previously stored */
- }
- L->top--; /* remove string from stack */
return ts;
}
/*
-** $Id: loadlib.c,v 1.127 2015/11/23 11:30:45 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
static const lua_CFunction searchers[] =
{searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL};
int i;
- /* create 'searchers' table */
- lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0);
- /* fill it with predefined searchers */
- for (i=0; searchers[i] != NULL; i++) {
- lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */
- lua_pushcclosure(L, searchers[i], 1);
+ /* create new type _LOADLIB */
+ luaL_newmetatable(L, "_LOADLIB");
+ lua_pushcfunction(L, gctm);
+ lua_setfield(L, -2, "__gc");
+ /* create `package' table */
+ luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
+#if defined(LUA_COMPAT_LOADLIB)
+ lua_getfield(L, -1, "loadlib");
+ lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
+#endif
+ lua_pushvalue(L, -1);
+ lua_replace(L, LUA_ENVIRONINDEX);
+ /* create `loaders' table */
+ lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
+ /* fill it with pre-defined loaders */
+ for (i=0; loaders[i] != NULL; i++) {
+ lua_pushcfunction(L, loaders[i]);
lua_rawseti(L, -2, i+1);
}
#if defined(LUA_COMPAT_LOADERS)
/*
-** $Id: lstrlib.c,v 1.251 2016/05/20 14:13:21 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
else if (*++strfrmt == L_ESC)
luaL_addchar(&b, *strfrmt++); /* %% */
else { /* format item */
- char form[MAX_FORMAT]; /* to store the format ('%...') */
- char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */
- int nb = 0; /* number of bytes in added item */
+ char form[MAX_FORMAT]; /* to store the format (`%...') */
+ char buff[MAX_ITEM]; /* to store the formatted item */
if (++arg > top)
luaL_argerror(L, arg, "no value");
strfrmt = scanformat(L, strfrmt, form);
#else /* }{ */
#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
-#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
+#define LUA_ROOT2 "/usr/"
+#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
+#define LUA_LDIR2 LUA_ROOT2 "share/lua/5.1/"
+#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#define LUA_CDIR2 LUA_ROOT2 "LIBDIR/lua/5.1/"
#define LUA_PATH_DEFAULT \
- LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
- "./?.lua;" "./?/init.lua"
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
+ LUA_LDIR2"?.lua;" LUA_LDIR2"?/init.lua"
#define LUA_CPATH_DEFAULT \
- LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
-#endif /* } */
+ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR2"?.so;" LUA_CDIR"loadall.so"
+#endif
/*
** definitions and LUAI_DDEC for declarations).
** CHANGE them if you need to mark them in some special way. Elf/gcc
** (versions 3.2 and later) mark them as "hidden" to optimize access
-** when Lua is compiled as a shared library. Not all elf targets support
-** this attribute. Unfortunately, gcc does not offer a way to check
-** whether the target offers that support, and those without support
-** give a warning about it. To avoid these warnings, change to the
-** default definition.
-*/
-#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
- defined(__ELF__) /* { */
-#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
-#else /* }{ */
+** when Lua is compiled as a shared library.
+*/
+#if defined(luaall_c)
+#define LUAI_FUNC static
+#define LUAI_DATA /* empty */
+
+#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+ defined(__ELF__)
+#define LUAI_FUNC extern
+#define LUAI_DATA LUAI_FUNC
+
+#else
#define LUAI_FUNC extern
#endif /* } */
/*
-** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp $
+** $Id: lvm.c,v 2.63.1.4 2009/07/01 21:10:33 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
}
-/*
-** Finish a table assignment 't[key] = val'.
-** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points
-** to the entry 't[key]', or to 'luaO_nilobject' if there is no such
-** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset'
-** would have done the job.)
-*/
-void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
- StkId val, const TValue *slot) {
- int loop; /* counter to avoid infinite loops */
+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; /* '__newindex' metamethod */
if (slot != NULL) { /* is 't' a table? */
luaT_callTM(L, tm, t, key, val, 0);
return;
}
- t = tm; /* else repeat assignment over 'tm' */
- if (luaV_fastset(L, t, key, slot, luaH_get, val))
- return; /* done */
- /* else loop */
+ /* else repeat with `tm' */
+ setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
+ t = &temp;
}
luaG_runerror(L, "'__newindex' chain too long; possible loop");
}