0001-Add-missing-define-for-luaL_newlib-for-Lua-5.1.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From 7f9fcbd827295df72b15466fd3c47589d52117b9 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
  3. Date: Wed, 31 Oct 2018 18:22:31 +0100
  4. Subject: [PATCH] Add missing define for luaL_newlib for Lua 5.1
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Since commit c286f3b741d0968fd1c49c28da83bc723468ecba, which bumped the
  9. library luv to version 1.22.0-1, building luvi fails.
  10. The reason for this error is, that instead of defining Lua 5.3 API itself,
  11. luv now [1] uses lua-compat-5.3 [1,2] for providing a Lua 5.3 API.
  12. Unfortunately, upstreams "luv.h" now exposes "compat-5.3.h" directly, causing
  13. redefinition errors when building luvi 2.7.6 (as well as latest release 2.8.0)
  14. with luv 1.22.0-1. Instead, "compat-5.3.h" should only be included in "luv.c",
  15. which is addressed in patching luv (Patch: "Do not include compat-5.3.h in luv
  16. header file").
  17. Patching luv reveals an issue in luvi itself, as it is using the Lua 5.3 API,
  18. without defining the Lua 5.3 itself, nor using lua-compat-5.3. Instead, it was
  19. using the definition provided by the "luv.h" file in luv versions before 1.22.0.
  20. Correctly, luvi should define the necessary Lua 5.3 itself, which is done by
  21. this patch, by providing a definition for `luaL_newlib`.
  22. Note, that this patch is not upstreamable, as upstream already switched to
  23. using lua-compat-5.3 [3,4]. However, backporting this patch set is to much of a
  24. burden, so we keep it simple, by just defining `luaL_newlib`.
  25. [1] https://github.com/luvit/luv/commit/34ada3e1d75796d2295ec54f3f20b3e2abf93406
  26. [2] https://github.com/keplerproject/lua-compat-5.3
  27. [3] https://github.com/luvit/luvi/commit/3a444d183d2fde91b6c2f3798b37881cdaa29691
  28. [4] https://github.com/luvit/luvi/commit/0376894bae7c1c3bee42ddad65e824da9cccdada
  29. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  30. ---
  31. src/luvi.h | 6 ++++++
  32. 1 file changed, 6 insertions(+)
  33. diff --git a/src/luvi.h b/src/luvi.h
  34. index e7558b3..ceca2b9 100644
  35. --- a/src/luvi.h
  36. +++ b/src/luvi.h
  37. @@ -52,6 +52,12 @@ int luaopen_lpeg(lua_State* L);
  38. #endif
  39. #endif
  40. +#if LUA_VERSION_NUM < 502
  41. +#ifndef luaL_newlib
  42. +# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
  43. +#endif
  44. +#endif
  45. +
  46. #if (LUA_VERSION_NUM >= 502)
  47. # undef luaL_register
  48. # define luaL_register(L,n,f) \
  49. --
  50. 2.19.1