Accepting request 960438 from home:gmbr3:Lua

- Added patches from upstream:
  * luabugs1.patch
  * luabugs2.patch
- Adjust buildsystem so that it matches upstream git (testes??)

OBS-URL: https://build.opensuse.org/request/show/960438
OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=52
This commit is contained in:
Callum Farmer 2022-03-09 10:14:38 +00:00 committed by Git OBS Bridge
parent a04ac87775
commit 42bd18111b
7 changed files with 159 additions and 16 deletions

View File

@ -1,5 +1,5 @@
--- a/attrib.lua
+++ b/attrib.lua
--- a/testes/attrib.lua
+++ b/testes/attrib.lua
@@ -269,7 +269,7 @@ local p = "" -- On Mac OS X, redefine
local st, err, when = package.loadlib(DC"lib1", "*")
if not st then

View File

@ -1,7 +1,7 @@
Index: lua/files.lua
===================================================================
--- lua.orig/files.lua
+++ lua/files.lua
--- lua.orig/testes/files.lua
+++ lua/testes/files.lua
@@ -81,7 +81,7 @@ assert(io.output() ~= io.stdout)
if not _port then -- invalid seek

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Mar 9 10:12:55 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
- Added patches from upstream:
* luabugs1.patch
* luabugs2.patch
- Adjust buildsystem so that it matches upstream git (testes??)
-------------------------------------------------------------------
Mon Mar 7 10:19:17 UTC 2022 - Bjørn Lie <bjorn.lie@gmail.com>

View File

@ -43,6 +43,10 @@ Patch1: attrib_test.patch
Patch2: files_test.patch
Patch3: main_test.patch
Patch6: shared_link.patch
# PATCH-FIX-UPSTREAM luabugsX.patch https://www.lua.org/bugs.html#5.4.4-X
Patch7: luabugs1.patch
Patch8: luabugs2.patch
#
%if "%{flavor}" == "test"
BuildRequires: lua54
%else
@ -137,16 +141,9 @@ scripting, and rapid prototyping. Lua is implemented as a small library
of C functions, written in ANSI C.
%prep
%if "%{flavor}" == "test"
%setup -T -q -b1 -n lua-%{version}-tests
%patch1 -p1
%patch2 -p1
%patch3 -p1
%else
%setup -q -n lua-%{version}
%patch0 -p1
%patch6 -p1
%endif
%setup -q -n lua-%{version} -a1
mv lua-%{version}-tests testes
%autopatch -p1
# manpage
%if "%{flavor}" != "test"
@ -206,6 +203,7 @@ touch %{buildroot}%{_sysconfdir}/alternatives/lua.pc
ln -sf %{_sysconfdir}/alternatives/lua.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
%else
%check
cd testes
LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua
%endif

94
luabugs1.patch Normal file
View File

@ -0,0 +1,94 @@
From 25b143dd34fb587d1e35290c4b25bc08954800e2 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Feb 2022 10:16:35 -0300
Subject: [PATCH] Bug: lua.c assumes that argv has at least one element
---
lua.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/lua.c b/lua.c
index 0f1900444..7f7dc2b22 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -177,10 +177,11 @@ static void print_version (void) {
** to the script (everything after 'script') go to positive indices;
** other arguments (before the script name) go to negative indices.
** If there is no script name, assume interpreter's name as base.
+** (If there is no interpreter's name either, 'script' is -1, so
+** table sizes are zero.)
*/
static void createargtable (lua_State *L, char **argv, int argc, int script) {
int i, narg;
- if (script == argc) script = 0; /* no script name? */
narg = argc - (script + 1); /* number of positive indices */
lua_createtable(L, narg, script + 1);
for (i = 0; i < argc; i++) {
@@ -268,14 +269,23 @@ static int handle_script (lua_State *L, char **argv) {
/*
** Traverses all arguments from 'argv', returning a mask with those
-** needed before running any Lua code (or an error code if it finds
-** any invalid argument). 'first' returns the first not-handled argument
-** (either the script name or a bad argument in case of error).
+** needed before running any Lua code or an error code if it finds any
+** invalid argument. In case of error, 'first' is the index of the bad
+** argument. Otherwise, 'first' is -1 if there is no program name,
+** 0 if there is no script name, or the index of the script name.
*/
static int collectargs (char **argv, int *first) {
int args = 0;
int i;
- for (i = 1; argv[i] != NULL; i++) {
+ if (argv[0] != NULL) { /* is there a program name? */
+ if (argv[0][0]) /* not empty? */
+ progname = argv[0]; /* save it */
+ }
+ else { /* no program name */
+ *first = -1;
+ return 0;
+ }
+ for (i = 1; argv[i] != NULL; i++) { /* handle arguments */
*first = i;
if (argv[i][0] != '-') /* not an option? */
return args; /* stop handling options */
@@ -316,7 +326,7 @@ static int collectargs (char **argv, int *first) {
return has_error;
}
}
- *first = i; /* no script name */
+ *first = 0; /* no script name */
return args;
}
@@ -609,8 +619,8 @@ static int pmain (lua_State *L) {
char **argv = (char **)lua_touserdata(L, 2);
int script;
int args = collectargs(argv, &script);
+ int optlim = (script > 0) ? script : argc; /* first argv not an option */
luaL_checkversion(L); /* check that interpreter has correct version */
- if (argv[0] && argv[0][0]) progname = argv[0];
if (args == has_error) { /* bad arg? */
print_usage(argv[script]); /* 'script' has index of bad arg. */
return 0;
@@ -628,14 +638,15 @@ static int pmain (lua_State *L) {
if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
return 0; /* error running LUA_INIT */
}
- if (!runargs(L, argv, script)) /* execute arguments -e and -l */
+ if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */
return 0; /* something failed */
- if (script < argc && /* execute main script (if there is one) */
- handle_script(L, argv + script) != LUA_OK)
- return 0;
+ if (script > 0) { /* execute main script (if there is one) */
+ if (handle_script(L, argv + script) != LUA_OK)
+ return 0; /* interrupt in case of error */
+ }
if (args & has_i) /* -i option? */
doREPL(L); /* do read-eval-print loop */
- else if (script == argc && !(args & (has_e | has_v))) { /* no arguments? */
+ else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */
if (lua_stdin_is_tty()) { /* running in interactive mode? */
print_version();
doREPL(L); /* do read-eval-print loop */

43
luabugs2.patch Normal file
View File

@ -0,0 +1,43 @@
From 1f3c6f4534c6411313361697d98d1145a1f030fa Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 15 Feb 2022 12:28:46 -0300
Subject: [PATCH] Bug: Lua can generate wrong code when _ENV is <const>
---
lparser.c | 1 +
testes/attrib.lua | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/lparser.c b/lparser.c
index 3abe3d751..a5cd55257 100644
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -468,6 +468,7 @@ static void singlevar (LexState *ls, expdesc *var) {
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k != VVOID); /* this one must exist */
+ luaK_exp2anyregup(fs, var); /* but could be a constant */
codestring(&key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}
diff --git a/testes/attrib.lua b/testes/attrib.lua
index b1076c768..83821c069 100644
--- a/testes/attrib.lua
+++ b/testes/attrib.lua
@@ -434,6 +434,16 @@ a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 ==
10)
+do
+ -- _ENV constant
+ local function foo ()
+ local _ENV <const> = 11
+ X = "hi"
+ end
+ local st, msg = pcall(foo)
+ assert(not st and string.find(msg, "number"))
+end
+
-- test of large float/integer indices

View File

@ -1,5 +1,5 @@
--- a/main.lua
+++ b/main.lua
--- a/testes/main.lua
+++ b/testes/main.lua
@@ -47,7 +47,7 @@
assert(string.sub(s, -1) == "\n")
local t = getoutput()