Thank you for the LUA_COMPAT_MODULE trick and for the links, worth reading! :-)

In attachment the submitted updated rockspec for lrandom:
 - lrandom-20101118-1.rockspec compatible with lua >= 5.1, < 5.3
 - lrandom-20120430-1.rockspec compatible with lua ~> 5.2

It is worth noting:
1. the current lrandom rockspecs share exactly the same url! So I did not update older rockspecs and I think they should be removed unless someone has url to the previous lrandom versions [1] ;
 2. the md5 of the 5.1 lrandom changed, as mentioned by Philipp [2] ;
3. the lrandom license is actually not only "Public domain" but "Public domain + BSD 3-Clause" [3] 4. because of the minor change between the versions 5.2 and 5.1 of lrandom (see in attachement), do you think keeping only lrandom-20101118-1.rockspec is enough ?

The attached rockspec includes updated md5 and license. Running lrandom test.lua worked here with lua 5.2 for both rockspec.

Thanks in advance for further comments or for the update if it is OK.

  Cyril

[1] I think the upstream lrandom.tar.gz for lua 5.1 simply got overwritten over updates, without reflecting change in tarball name or url.
[2] probably due to an unnoticed upstream update.
[3] lrandom actually compiles with two files: lrandom.c (Public domain) and random.c (BSD 3-Clause)
package = "lrandom"
version = "20101118-1"
source = {
   url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lrandom.tar.gz";,
   md5 = "ab8f9cc2d84435ea7c759ca29837a223",
   dir = "random"
}
description = {
   summary = "A library for generating random numbers.",
   detailed = [[
      A library for generating random numbers based on the Mersenne Twister,
      a pseudorandom number generating algorithm developped by Makoto Matsumoto
      and Takuji Nishimura (alphabetical order) in 1996/1997.
   ]],
   homepage = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lrandom";,
   license = "Public domain, BSD 3-Clause"
}
dependencies = {
   "lua >= 5.1, < 5.3"
}
build = {
   type = "builtin",
   modules = {
      random = {
        sources = {"lrandom.c"},
        defines = {"LUA_COMPAT_MODULE=1"}
      }
   }
}
package = "lrandom"
version = "20120430-1"
source = {
   url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lrandom.tar.gz";,
   md5 = "db145615058fd6729c01a59c45397eca",
   dir = "random"
}
description = {
   summary = "A library for generating random numbers.",
   detailed = [[
      A library for generating random numbers based on the Mersenne Twister,
      a pseudorandom number generating algorithm developped by Makoto Matsumoto
      and Takuji Nishimura (alphabetical order) in 1996/1997.
   ]],
   homepage = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lrandom";,
   license = "Public domain, BSD 3-Clause"
}
dependencies = {
   "lua ~> 5.2"
}
build = {
   type = "builtin",
   modules = {
      random = "lrandom.c"
   }
}
>From 68adb5ea05e6551854086b40799597c2f5b1998b Mon Sep 17 00:00:00 2001
From: Cyril Romain <public.cy...@romain.tf>
Date: Sun, 9 Jun 2013 20:38:00 +0200
Subject: [PATCH] update to 5.2 version

---
 Makefile  |  2 +-
 README    |  2 +-
 lrandom.c | 14 ++++++--------
 test.lua  |  2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 2596b26..8ae5917 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # makefile for random library for Lua
 
 # change these to reflect your Lua installation
-LUA= /tmp/lhf/lua-5.1.5
+LUA= /tmp/lhf/lua-5.2.0
 LUAINC= $(LUA)/src
 LUALIB= $(LUA)/src
 LUABIN= $(LUA)/src
diff --git a/README b/README
index 8714259..79962e0 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is a random-number library for Lua 5.1. It is based on the Mersenne
+This is a random-number library for Lua 5.2. It is based on the Mersenne
 Twister random number generator available at
 	http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
 
diff --git a/lrandom.c b/lrandom.c
index db10d9f..8cbfe19 100644
--- a/lrandom.c
+++ b/lrandom.c
@@ -1,8 +1,8 @@
 /*
 * lrandom.c
-* random-number library for Lua 5.1 based on the Mersenne Twister
+* random-number library for Lua 5.2 based on the Mersenne Twister
 * Luiz Henrique de Figueiredo <l...@tecgraf.puc-rio.br>
-* 18 Nov 2010 19:11:40
+* 30 Apr 2012 14:10:37
 * This code is hereby placed in the public domain.
 */
 
@@ -16,11 +16,11 @@
 #include "random.c"
 
 #define MYNAME		"random"
-#define MYVERSION	MYNAME " library for " LUA_VERSION " / Nov 2010 / "\
+#define MYVERSION	MYNAME " library for " LUA_VERSION " / Apr 2012 / "\
 			"using " AUTHOR
 #define MYTYPE		MYNAME " handle"
 
-#define SEED		2010UL
+#define SEED		2012UL
 
 static MT *Pget(lua_State *L, int i)
 {
@@ -30,8 +30,7 @@ static MT *Pget(lua_State *L, int i)
 static MT *Pnew(lua_State *L)
 {
  MT *c=lua_newuserdata(L,sizeof(MT));
- luaL_getmetatable(L,MYTYPE);
- lua_setmetatable(L,-2);
+ luaL_setmetatable(L,MYTYPE);
  return c;
 }
 
@@ -106,8 +105,7 @@ static const luaL_Reg R[] =
 LUALIB_API int luaopen_random(lua_State *L)
 {
  luaL_newmetatable(L,MYTYPE);
- lua_setglobal(L,MYNAME);
- luaL_register(L,MYNAME,R);
+ luaL_setfuncs(L,R,0);
  lua_pushliteral(L,"version");			/** version */
  lua_pushliteral(L,MYVERSION);
  lua_settable(L,-3);
diff --git a/test.lua b/test.lua
index 30137a5..2d8035e 100644
--- a/test.lua
+++ b/test.lua
@@ -1,6 +1,6 @@
 -- test random library
 
-require"random"
+local random=require"random"
 
 print(random.version)
 print""
-- 
1.8.3

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Luarocks-developers mailing list
Luarocks-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/luarocks-developers

Reply via email to