Compare commits

7 Commits

Author SHA256 Message Date
6415b3491a interpreter should not conflict/provide lua symbol (bsc#1247521) 2025-08-04 13:52:52 +02:00
b8aaa33c80 this package also provides devel symlink directly and conflicts other -devel packages 2025-07-25 22:10:48 +02:00
a5fee331d4 don't require lua-interpreter when not using libalternatives 2025-07-25 13:29:22 +02:00
c3d42d0aa9 Set up support for using libalternatives for Tumbleweed
update-alternatives are still used for SLE.
Also, fix .gitignore and overall improve the packaging.
2025-07-23 23:04:14 +02:00
cb9e5d9061 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua53?expand=0&rev=39 2025-07-23 23:04:13 +02:00
96512089c2 Accepting request 1002891 from home:gmbr3:Lua
- Add shared_link.patch: fix dynamic linking executable
- Stop building static library

OBS-URL: https://build.opensuse.org/request/show/1002891
OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua53?expand=0&rev=38
2025-07-23 23:04:13 +02:00
e69166c718 Accepting request 837721 from home:gmbr3:Active
- Update to version 5.3.6:
  * Fixes bugs found in Lua 5.3.5 and Lua 5.4.0
  * Lua 5.3 is now EOL
- Removed upstream-bugs.patch: new release (no bugs found yet)
- Removed upstream-bugs-backport-lua54.patch: new release (no bugs found yet)

OBS-URL: https://build.opensuse.org/request/show/837721
OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua53?expand=0&rev=36
2025-07-23 23:04:13 +02:00
9 changed files with 129 additions and 387 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
.osc
_scmsync.obsinfo
_buildconfig-*
_buildinfo-*.xml
lua53-*-build/

BIN
lua-5.3.5.tar.gz (Stored with Git LFS)

Binary file not shown.

BIN
lua-5.3.6.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -40,9 +40,10 @@ Index: lua-5.3.4/Makefile
# How to install. If your install program does not support "-p", then
# you may have to run ranlib on the installed liblua.a.
INSTALL= install -p
INSTALL_EXEC= $(INSTALL) -m 0755
-INSTALL_EXEC= $(INSTALL) -m 0755
+INSTALL_EXEC= $(LIBTOOL) --mode=install install -m 0755
INSTALL_DATA= $(INSTALL) -m 0644
+INSTALL_LIBTOOL= $(LIBTOOL) --mode=install install -m 0644
+INSTALL_LIBTOOL= $(LIBTOOL) --mode=install install -m 0755
#
# If you don't have "install" you can use "cp" instead.
# INSTALL= cp -p
@@ -134,15 +135,15 @@ Index: lua-5.3.4/src/Makefile
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -rpath /usr/lib -version-info 8:0:3 -o liblua$(V).la
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -rpath /usr/lib -shared -version-info 8:0:3 -o liblua$(V).la
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LIBS) -static liblua$(V).la -Wl,-E lua.lo -o $@
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LIBS) $(LUA_A) -Wl,-E lua.lo -o $@
$(LUAC_T): $(LUAC_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -static liblua$(V).la luac.lo -o $@
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LUA_A) luac.lo -o $@
clean:
$(RM) $(ALL_T) $(ALL_O)

View File

@@ -1,3 +1,25 @@
-------------------------------------------------------------------
Mon Aug 4 11:52:12 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- interpreter should not conflict/provide lua symbol (bsc#1247521)
-------------------------------------------------------------------
Mon Sep 12 11:10:48 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
- Add shared-link.patch: fix dynamic linking executable
- Stop building static library
- this package also provides devel symlink directly and conflicts
other -devel packages
-------------------------------------------------------------------
Fri Sep 25 14:46:59 UTC 2020 - Callum Farmer <callumjfarmer13@gmail.com>
- Update to version 5.3.6:
* Fixes bugs found in Lua 5.3.5 and Lua 5.4.0
* Lua 5.3 is now EOL
- Removed upstream-bugs.patch: new release (no bugs found yet)
- Removed upstream-bugs-backport-lua54.patch: new release (no bugs found yet)
-------------------------------------------------------------------
Wed Aug 19 14:03:08 UTC 2020 - Callum Farmer <callumjfarmer13@gmail.com>

View File

@@ -18,30 +18,42 @@
%define major_version 5.3
%define libname liblua5_3-5
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
Name: lua53
Version: 5.3.5
Version: 5.3.6
Release: 0
Summary: Small Embeddable Language with Procedural Syntax
License: MIT
Group: Development/Languages/Other
Url: http://www.lua.org
Source: http://www.lua.org/ftp/lua-%{version}.tar.gz
URL: https://www.lua.org
Source: https://www.lua.org/ftp/lua-%{version}.tar.gz
Source99: baselibs.conf
# PATCH-FIX-SUSE tweak the buildsystem to produce what is needed for SUSE
Patch0: lua-build-system.patch
# PATCH-FIX-UPSTREAM https://www.lua.org/bugs.html#5.3.5
Patch1: upstream-bugs.patch
# PATCH-FIX-UPSTREAM https://www.lua.org/bugs.html#5.3.6
#Patch1: upstream-bugs.patch
# PATCH-FIX-UPSTREAM https://www.lua.org/bugs.html#5.4.0
Patch2: upstream-bugs-backport-lua54.patch
#Patch2: upstream-bugs-backport-lua54.patch
Patch3: shared-link.patch
BuildRequires: libtool
BuildRequires: lua-macros
BuildRequires: pkgconfig
BuildRequires: readline-devel
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides: lua = %{version}
Obsoletes: lua < %{version}
Provides: Lua(API) = %{major_version}
%if %{with libalternatives}
BuildRequires: alts
BuildRequires: lua-interpreter
Requires: alts
Requires: lua-interpreter
%else
Requires(post): update-alternatives
Requires(postun): update-alternatives
%endif
%description
Lua is a programming language originally designed for extending
@@ -61,8 +73,7 @@ Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
Requires: %{name} = %{version}
Requires: lua-macros
Requires(post): update-alternatives
Requires(postun): update-alternatives
Conflicts: lua-devel
Provides: lua-devel = %{version}
Provides: Lua(devel) = %{major_version}
Provides: pkgconfig(lua) = %{version}
@@ -79,15 +90,15 @@ application.
Summary: The Lua integration library
# Compat as libtool changes the soname
Group: System/Libraries
Provides: liblua5_3 = %{version}-%{release}
Obsoletes: liblua5_3 < %{version}-%{release}
Provides: %{name}-libs = %{version}
Obsoletes: %{name}-libs < %{version}
%ifarch aarch64 x86_64 ppc64 ppc64le s390x riscv64
Provides: liblua.so.5.3()(64bit)
%else
Provides: liblua.so.5.3
%endif
Provides: liblua5_3 = %{version}-%{release}
Obsoletes: liblua5_3 < %{version}-%{release}
Provides: %{name}-libs = %{version}
Obsoletes: %{name}-libs < %{version}
%description -n %{libname}
Lua is a programming language originally designed for extending
@@ -130,7 +141,7 @@ cat doc/luac.1 | sed 's/TH LUAC 1/TH LUAC%{major_version} 1/' > doc/luac%{major_
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
sed -i -e "s@lib/lua/@%{_lib}/lua/@g" src/luaconf.h
export LIBTOOL="libtool --quiet"
make %{?_smp_mflags} -C src \
%make_build -C src \
CC="cc" \
MYCFLAGS="%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_USE_LINUX -DLUA_COMPAT_MODULE" \
MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" \
@@ -142,7 +153,6 @@ make install \
V=%{major_version} \
INSTALL_TOP="%{buildroot}%{_prefix}" \
INSTALL_LIB="%{buildroot}%{_libdir}"
find %{buildroot} -type f -name "*.la" -delete -print
# create pkg-config file
@@ -150,18 +160,31 @@ cat > lua%{major_version}.pc <<-EOF
prefix=%{_prefix}
exec_prefix=%{_prefix}
libdir=%{_libdir}
includedir=%{_prefix}/include/lua%{major_version}
includedir=%{_includedir}/lua%{major_version}
INSTALL_LMOD=%{_datadir}/lua/%{major_version}
INSTALL_CMOD=%{_libdir}/lua/%{major_version}
Name: Lua %{major_version}
Name: Lua %{major_version}
Description: An Extensible Extension Language
Version: %{version}
Version: %{version}
Libs: -llua%{major_version} -lm
Cflags: -I\${includedir}
EOF
install -D -m 644 lua%{major_version}.pc %{buildroot}/%{_libdir}/pkgconfig/lua%{major_version}.pc
install -D -m 644 lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua%{major_version}.pc
%if %{with libalternatives}
# alternatives - create configuration file
mkdir -p %{buildroot}%{_datadir}/libalternatives/lua
cat > %{buildroot}%{_datadir}/libalternatives/lua/53.conf <<EOF
binary=%{_bindir}/lua5.3
man=lua5.3
EOF
mkdir -p %{buildroot}%{_datadir}/libalternatives/luac
cat > %{buildroot}%{_datadir}/libalternatives/luac/53.conf <<EOF
binary=%{_bindir}/luac5.3
man=luac5.3
EOF
%else
# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for file in lua luac ; do
@@ -170,16 +193,17 @@ for file in lua luac ; do
touch "%{buildroot}%{_sysconfdir}/alternatives/${file}.1%{ext_man}"
ln -sf "%{_sysconfdir}/alternatives/${file}.1%{ext_man}" "%{buildroot}%{_mandir}/man1/${file}.1%{ext_man}"
done
%endif
# Compat link with older unprefixed library and with soname 0 from deb/etc
chmod +x %{buildroot}%{_libdir}/*
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version}
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version}
# Library devel alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so
ln -sf %{_sysconfdir}/alternatives/liblua.so %{buildroot}%{_libdir}/liblua.so
touch %{buildroot}%{_sysconfdir}/alternatives/lua.pc
ln -sf %{_sysconfdir}/alternatives/lua.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
# We dont create alternatives for -devel content, just conflict those
ln -s %{_libdir}/liblua%{major_version}.so %{buildroot}%{_libdir}/liblua.so
ln -s %{_libdir}/pkgconfig/lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
%check
cd src
@@ -188,6 +212,7 @@ LD_LIBRARY_PATH=`pwd` ./lua%{major_version} -e 'print(0)' > /dev/null
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%if %{without libalternatives}
%post
%{_sbindir}/update-alternatives --install \
%{_bindir}/lua lua %{_bindir}/lua%{major_version} 53 \
@@ -199,16 +224,7 @@ LD_LIBRARY_PATH=`pwd` ./lua%{major_version} -e 'print(0)' > /dev/null
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove lua %{_bindir}/lua%{major_version}
fi
%post devel
%{_sbindir}/update-alternatives --install \
%{_libdir}/liblua.so liblua.so %{_libdir}/liblua%{major_version}.so 53 \
--slave %{_libdir}/pkgconfig/lua.pc lua.pc %{_libdir}/pkgconfig/lua%{major_version}.pc
%postun devel
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove liblua.so %{_libdir}/liblua%{major_version}.so
fi
%endif
%files
%doc README
@@ -218,17 +234,22 @@ fi
%dir %{_datadir}/lua/%{major_version}
%{_bindir}/lua%{major_version}
%{_bindir}/luac%{major_version}
%{_mandir}/man1/lua%{major_version}.1%{ext_man}
%{_mandir}/man1/luac%{major_version}.1%{ext_man}
%{_mandir}/man1/lua%{major_version}.1%{?ext_man}
%{_mandir}/man1/luac%{major_version}.1%{?ext_man}
%if %{with libalternatives}
%{_datadir}/libalternatives/lua/53.conf
%{_datadir}/libalternatives/luac/53.conf
%else
# alternatives
%{_bindir}/lua
%{_bindir}/luac
%{_mandir}/man1/lua.1%{ext_man}
%{_mandir}/man1/luac.1%{ext_man}
%{_mandir}/man1/lua.1%{?ext_man}
%{_mandir}/man1/luac.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/lua
%ghost %{_sysconfdir}/alternatives/luac
%ghost %{_sysconfdir}/alternatives/lua.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/luac.1%{ext_man}
%endif
%files -n %{libname}
%{_libdir}/liblua%{major_version}.so.*
@@ -241,14 +262,10 @@ fi
%{_includedir}/lua%{major_version}/lua.hpp
%{_includedir}/lua%{major_version}/luaconf.h
%{_includedir}/lua%{major_version}/lualib.h
%{_libdir}/liblua%{major_version}.a
%{_libdir}/liblua%{major_version}.so
%{_libdir}/pkgconfig/lua%{major_version}.pc
# alternatives
%{_libdir}/liblua.so
%{_libdir}/pkgconfig/lua.pc
%ghost %{_sysconfdir}/alternatives/liblua.so
%ghost %{_sysconfdir}/alternatives/lua.pc
%files doc
%doc doc/*

33
shared-link.patch Normal file
View File

@@ -0,0 +1,33 @@
--- a/src/lundump.h
+++ b/src/lundump.h
@@ -26,7 +26,7 @@
LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
void* data, int strip);
#endif
--- a/src/lopcodes.h
+++ b/src/lopcodes.h
@@ -278,7 +278,7 @@
OpArgK /* argument is a constant or register/constant */
};
-LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
+LUA_API const lu_byte luaP_opmodes[NUM_OPCODES];
#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
@@ -287,7 +287,7 @@
#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
-LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
+LUA_API const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
/* number of list items to accumulate before a SETLIST instruction */

View File

@@ -1,82 +0,0 @@
--- a/src/ldebug.c
+++ b/src/ldebug.c
@@ -133,10 +133,11 @@ static const char *upvalname (Proto *p, int uv) {
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
int nparams = clLvalue(ci->func)->p->numparams;
- if (n >= cast_int(ci->u.l.base - ci->func) - nparams)
+ int nvararg = cast_int(ci->u.l.base - ci->func) - nparams;
+ if (n <= -nvararg)
return NULL; /* no such vararg */
else {
- *pos = ci->func + nparams + n;
+ *pos = ci->func + nparams - n;
return "(*vararg)"; /* generic name for any vararg */
}
}
@@ -148,7 +149,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
StkId base;
if (isLua(ci)) {
if (n < 0) /* access to vararg values? */
- return findvararg(ci, -n, pos);
+ return findvararg(ci, n, pos);
else {
base = ci->u.l.base;
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
--- a/src/liolib.c
+++ b/src/liolib.c
@@ -277,6 +277,8 @@ static int io_popen (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
LStream *p = newprefile(L);
+ luaL_argcheck(L, ((mode[0] == 'r' || mode[0] == 'w') && mode[1] == '\0'),
+ 2, "invalid mode");
p->f = l_popen(L, filename, mode);
p->closef = &io_pclose;
return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -1013,10 +1013,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
}
else { /* cannot fail when shrinking a block */
void *newptr = realloc(ptr, nsize);
- if (newptr == NULL && ptr != NULL && nsize <= osize)
- return ptr; /* keep the original block */
- else /* no fail or not shrinking */
- return newptr; /* use the new block */
+ if (newptr == NULL && ptr != NULL && nsize <= osize)
+ return ptr; /* keep the original block */
+ else /* no fail or not shrinking */
+ return newptr; /* use the new block */
}
}
--- a/src/lundump.c
+++ b/src/lundump.c
@@ -86,6 +86,7 @@ static lua_Integer LoadInteger (LoadState *S) {
static TString *LoadString (LoadState *S, Proto *p) {
+ lua_State *L = S->L;
size_t size = LoadByte(S);
TString *ts;
if (size == 0xFF)
@@ -95,13 +96,16 @@ static TString *LoadString (LoadState *S, Proto *p) {
else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
char buff[LUAI_MAXSHORTLEN];
LoadVector(S, buff, size);
- ts = luaS_newlstr(S->L, buff, size);
+ ts = luaS_newlstr(L, buff, size);
}
else { /* long string */
- ts = luaS_createlngstrobj(S->L, size);
+ ts = luaS_createlngstrobj(L, size);
+ setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
+ luaD_inctop(L);
LoadVector(S, getstr(ts), size); /* load directly in final place */
+ L->top--; /* pop string */
}
- luaC_objbarrier(S->L, p, ts);
+ luaC_objbarrier(L, p, ts);
return ts;
}

View File

@@ -1,253 +0,0 @@
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -1011,8 +1011,13 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
free(ptr);
return NULL;
}
- else
- return realloc(ptr, nsize);
+ else { /* cannot fail when shrinking a block */
+ void *newptr = realloc(ptr, nsize);
+ if (newptr == NULL && ptr != NULL && nsize <= osize)
+ return ptr; /* keep the original block */
+ else /* no fail or not shrinking */
+ return newptr; /* use the new block */
+ }
}
--- a/src/llex.c
+++ b/src/llex.c
@@ -244,12 +244,12 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) {
/*
-** skip a sequence '[=*[' or ']=*]'; if sequence is well formed, return
-** its number of '='s; otherwise, return a negative number (-1 iff there
-** are no '='s after initial bracket)
+** reads a sequence '[=*[' or ']=*]', leaving the last bracket.
+** If sequence is well formed, return its number of '='s + 2; otherwise,
+** return 1 if there is no '='s or 0 otherwise (an unfinished '[==...').
*/
-static int skip_sep (LexState *ls) {
- int count = 0;
+static size_t skip_sep (LexState *ls) {
+ size_t count = 0;
int s = ls->current;
lua_assert(s == '[' || s == ']');
save_and_next(ls);
@@ -257,11 +257,14 @@ static int skip_sep (LexState *ls) {
save_and_next(ls);
count++;
}
- return (ls->current == s) ? count : (-count) - 1;
+ return (ls->current == s) ? count + 2
+ : (count == 0) ? 1
+ : 0;
+
}
-static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
+static void read_long_string (LexState *ls, SemInfo *seminfo, size_t sep) {
int line = ls->linenumber; /* initial line (for error message) */
save_and_next(ls); /* skip 2nd '[' */
if (currIsNewline(ls)) /* string starts with a newline? */
@@ -295,8 +298,8 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
}
} endloop:
if (seminfo)
- seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
- luaZ_bufflen(ls->buff) - 2*(2 + sep));
+ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + sep,
+ luaZ_bufflen(ls->buff) - 2 * sep);
}
@@ -444,9 +447,9 @@ static int llex (LexState *ls, SemInfo *seminfo) {
/* else is a comment */
next(ls);
if (ls->current == '[') { /* long comment? */
- int sep = skip_sep(ls);
+ size_t sep = skip_sep(ls);
luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */
- if (sep >= 0) {
+ if (sep >= 2) {
read_long_string(ls, NULL, sep); /* skip long comment */
luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */
break;
@@ -458,12 +461,12 @@ static int llex (LexState *ls, SemInfo *seminfo) {
break;
}
case '[': { /* long string or simply '[' */
- int sep = skip_sep(ls);
- if (sep >= 0) {
+ size_t sep = skip_sep(ls);
+ if (sep >= 2) {
read_long_string(ls, seminfo, sep);
return TK_STRING;
}
- else if (sep != -1) /* '[=...' missing second bracket */
+ else if (sep == 0) /* '[=...' missing second bracket */
lexerror(ls, "invalid long string delimiter", TK_STRING);
return '[';
}
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -544,6 +544,7 @@ static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) {
fs->bl = NULL;
f = fs->f;
f->source = ls->source;
+ luaC_objbarrier(ls->L, f, f->source);
f->maxstacksize = 2; /* registers 0/1 are always valid */
enterblock(fs, bl, 0);
}
@@ -1616,6 +1617,7 @@ static void mainfunc (LexState *ls, FuncState *fs) {
fs->f->is_vararg = 1; /* main function is always declared vararg */
init_exp(&v, VLOCAL, 0); /* create and... */
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
+ luaC_objbarrier(ls->L, fs->f, ls->envn);
luaX_next(ls); /* read first token */
statlist(ls); /* parse main body */
check(ls, TK_EOS);
@@ -1634,6 +1636,7 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
sethvalue(L, L->top, lexstate.h); /* anchor it */
luaD_inctop(L);
funcstate.f = cl->p = luaF_newproto(L);
+ luaC_objbarrier(L, cl, cl->p);
funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
lua_assert(iswhite(funcstate.f)); /* do not need barrier here */
lexstate.buff = buff;
--- a/src/lundump.c
+++ b/src/lundump.c
@@ -85,8 +85,9 @@ static lua_Integer LoadInteger (LoadState *S) {
}
-static TString *LoadString (LoadState *S) {
+static TString *LoadString (LoadState *S, Proto *p) {
size_t size = LoadByte(S);
+ TString *ts;
if (size == 0xFF)
LoadVar(S, size);
if (size == 0)
@@ -94,13 +95,14 @@ static TString *LoadString (LoadState *S) {
else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
char buff[LUAI_MAXSHORTLEN];
LoadVector(S, buff, size);
- return luaS_newlstr(S->L, buff, size);
+ ts = luaS_newlstr(S->L, buff, size);
}
else { /* long string */
- TString *ts = luaS_createlngstrobj(S->L, size);
+ ts = luaS_createlngstrobj(S->L, size);
LoadVector(S, getstr(ts), size); /* load directly in final place */
- return ts;
}
+ luaC_objbarrier(S->L, p, ts);
+ return ts;
}
@@ -140,7 +142,7 @@ static void LoadConstants (LoadState *S, Proto *f) {
break;
case LUA_TSHRSTR:
case LUA_TLNGSTR:
- setsvalue2n(S->L, o, LoadString(S));
+ setsvalue2n(S->L, o, LoadString(S, f));
break;
default:
lua_assert(0);
@@ -158,6 +160,7 @@ static void LoadProtos (LoadState *S, Proto *f) {
f->p[i] = NULL;
for (i = 0; i < n; i++) {
f->p[i] = luaF_newproto(S->L);
+ luaC_objbarrier(S->L, f, f->p[i]);
LoadFunction(S, f->p[i], f->source);
}
}
@@ -189,18 +192,18 @@ static void LoadDebug (LoadState *S, Proto *f) {
for (i = 0; i < n; i++)
f->locvars[i].varname = NULL;
for (i = 0; i < n; i++) {
- f->locvars[i].varname = LoadString(S);
+ f->locvars[i].varname = LoadString(S, f);
f->locvars[i].startpc = LoadInt(S);
f->locvars[i].endpc = LoadInt(S);
}
n = LoadInt(S);
for (i = 0; i < n; i++)
- f->upvalues[i].name = LoadString(S);
+ f->upvalues[i].name = LoadString(S, f);
}
static void LoadFunction (LoadState *S, Proto *f, TString *psource) {
- f->source = LoadString(S);
+ f->source = LoadString(S, f);
if (f->source == NULL) /* no source in dump? */
f->source = psource; /* reuse parent's source */
f->linedefined = LoadInt(S);
@@ -271,6 +274,7 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {
setclLvalue(L, L->top, cl);
luaD_inctop(L);
cl->p = luaF_newproto(L);
+ luaC_objbarrier(L, cl, cl->p);
LoadFunction(&S, cl->p, NULL);
lua_assert(cl->nupvalues == cl->p->sizeupvalues);
luai_verifycode(L, buff, cl->p);
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -1254,13 +1254,12 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
}
-static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
+static UpVal **getupvalref (lua_State *L, int fidx, int n) {
LClosure *f;
StkId fi = index2addr(L, fidx);
api_check(L, ttisLclosure(fi), "Lua function expected");
f = clLvalue(fi);
api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
- if (pf) *pf = f;
return &f->upvals[n - 1]; /* get its upvalue pointer */
}
@@ -1269,7 +1268,7 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
StkId fi = index2addr(L, fidx);
switch (ttype(fi)) {
case LUA_TLCL: { /* lua closure */
- return *getupvalref(L, fidx, n, NULL);
+ return *getupvalref(L, fidx, n);
}
case LUA_TCCL: { /* C closure */
CClosure *f = clCvalue(fi);
@@ -1286,9 +1285,10 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
int fidx2, int n2) {
- LClosure *f1;
- UpVal **up1 = getupvalref(L, fidx1, n1, &f1);
- UpVal **up2 = getupvalref(L, fidx2, n2, NULL);
+ UpVal **up1 = getupvalref(L, fidx1, n1);
+ UpVal **up2 = getupvalref(L, fidx2, n2);
+ if (*up1 == *up2)
+ return;
luaC_upvdeccount(L, *up1);
*up1 = *up2;
(*up1)->refcount++;
@@ -1289,6 +1289,8 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
LClosure *f1;
UpVal **up1 = getupvalref(L, fidx1, n1, &f1);
UpVal **up2 = getupvalref(L, fidx2, n2, NULL);
+ if (*up1 == *up2)
+ return;
luaC_upvdeccount(L, *up1);
*up1 = *up2;
(*up1)->refcount++;
--- a/Makefile
+++ b/Makefile
@@ -49 +49 @@
-R= $V.4
+R= $V.5