Bug 1204129 - Enable compatibility with lua 5.2
Summary: Enable compatibility with lua 5.2
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: lua
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tim Niemueller
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-20 12:55 UTC by Kalev Lember
Modified: 2015-04-21 19:06 UTC (History)
5 users (show)

Fixed In Version: cardpeek-0.8.4-1.fc22
Clone Of:
Environment:
Last Closed: 2015-03-23 07:08:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
[PATCH] Define LUA_COMPAT_5_2 in addition to LUA_COMPAT_5_1 (1.96 KB, text/plain)
2015-03-20 12:57 UTC, Kalev Lember
no flags Details

Description Kalev Lember 2015-03-20 12:55:07 UTC
cardpeek fails to build for F22 / rawhide:

  OBJCLD   cardpeek
lua_bytes.o: In function `subr_bytes_set':
/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:296: undefined reference to `luaL_checkint'
/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:302: undefined reference to `luaL_checkint'
lua_bytes.o: In function `subr_bytes_get':
/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:262: undefined reference to `luaL_checkint'
/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:270: undefined reference to `luaL_checkint'
lua_bytes.o: In function `subr_bytes_convert':
/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:440: undefined reference to `luaL_checkint'
lua_bytes.o:/home/kalev/fedora-git/cardpeek/cardpeek-0.8.4/lua_bytes.c:434: more undefined references to `luaL_checkint' follow
collect2: error: ld returned 1 exit status

luaL_checkint() is guarded by the LUA_COMPAT_5_2 macro which the lua build currently does not define.

Comment 1 Kalev Lember 2015-03-20 12:57:27 UTC
Created attachment 1004480 [details]
[PATCH] Define LUA_COMPAT_5_2 in addition to LUA_COMPAT_5_1

Comment 2 Kalev Lember 2015-03-20 13:05:33 UTC
13:58 < kalev> spot: hey, ok to commit the lua patch in https://bugzilla.redhat.com/show_bug.cgi?id=1204129 ?
13:59 < spot> kalev: definitely.

Comment 3 Fedora Update System 2015-03-20 15:16:19 UTC
cardpeek-0.8.4-1.fc22,lua-5.3.0-2.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/cardpeek-0.8.4-1.fc22,lua-5.3.0-2.fc22

Comment 4 Fedora Update System 2015-03-22 04:34:21 UTC
Package cardpeek-0.8.4-1.fc22, lua-5.3.0-2.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing cardpeek-0.8.4-1.fc22 lua-5.3.0-2.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-4397/cardpeek-0.8.4-1.fc22,lua-5.3.0-2.fc22
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2015-03-23 07:08:13 UTC
cardpeek-0.8.4-1.fc22, lua-5.3.0-2.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Thomas Moschny 2015-04-20 17:03:11 UTC
Now, while compatibility is good, this change creates a problem with code like this:

#if LUA_VERSION_NUM >= 503
#define luaL_checkunsigned(L,n) ((lua_Unsigned)luaL_checkinteger(L,n))
#endif

throwing a "luaL_checkunsigned" redefined" error.

What is the proper way to handle this?

Variant 1:

#if LUA_VERSION_NUM >= 503
#ifndef LUA_COMPAT_APIINTCASTS
#define luaL_checkunsigned(L,n) ((lua_Unsigned)luaL_checkinteger(L,n))
#endif
#endif

Variant 2:

#include <lua.h>
#if LUA_VERSION_NUM >= 503
#define LUA_COMPAT_APIINTCASTS
#endif
#include <lauxlib.h>

I am a bit confused.

Comment 7 Tom "spot" Callaway 2015-04-21 19:06:22 UTC
I'll try to answer. 

lua 5.3 says (in lauxlib.h)

/*
** {============================================================
** Compatibility with deprecated conversions
** =============================================================
*/
#if defined(LUA_COMPAT_APIINTCASTS)

#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))

...

This means that if Lua is compiled with LUA_COMPAT_APIINTCASTS, you can safely use the deprecated luaL_checkunsigned(L,a) function instead of using the new luaL_checkinteger.

Of your two proposed versions, Variant 1 is a correct way to handle this case.
Variant 2 is incorrect, because LUA_COMPAT_APIINTCASTS is defined in luaconf.h, so you're asking for trouble. (It also changes lua in ways deeper than the headers.)


Note You need to log in before you can comment on or make changes to this bug.