lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi there.

Maybe these fixes are already done, but I haven't seen anything, so:

1. lposix.c (lposix-c-fixes.diff)
-luaL_findstring has been replaced with luaL_checkoption in 5.1-alpha

2. posix.lua (posix-lua.diff)
-no magic required anymore, or? (maybe posix.lua could even be removed?)

3. test.lua
-fix changed semantics (though I'm not sure, if it is fixed the best way it could; yet, it-works^TM)

George
--- posix/lposix.c	2003-11-06 01:23:48.000000000 +0100
+++ posix-5.1-alpha/lposix.c	2005-09-04 13:59:15.000000000 +0200
@@ -64,7 +64,7 @@
 	}
 	else
 	{
-		int j=luaL_findstring(luaL_checkstring(L, i), S);
+		int j=luaL_checkoption(L, i, NULL, S);
 		if (j==-1) luaL_argerror(L, i, "unknown selector");
 		return F(L, j, data);
 	}
@@ -802,7 +802,7 @@
 	{NULL,			NULL}
 };
 
-LUALIB_API int luaopen_posix (lua_State *L)
+LUALIB_API int luaopen_lposix (lua_State *L)
 {
 	luaL_openlib(L, MYNAME, R, 0);
 	lua_pushliteral(L,"version");		/** version */
--- posix/posix.lua	2003-06-18 14:47:44.000000000 +0200
+++ posix-5.1-alpha/posix.lua	2005-09-04 14:15:14.000000000 +0200
@@ -1,10 +1,4 @@
 -- posix.lua
 -- support code for posix library
--- usage lua -lposix ...
 
-local function so(x)
-	local SOPATH= os.getenv"LUA_SOPATH" or "./"
-	assert(loadlib(SOPATH.."l"..x..".so","luaopen_"..x))()
-end
-
-so"posix"
+require"lposix"
--- posix/test.lua	2003-11-07 12:42:30.000000000 +0100
+++ posix-5.1-alpha/test.lua	2005-09-04 13:51:39.000000000 +0200
@@ -41,7 +41,7 @@
 f"HOME"
 f"SHELL"
 f"absent"
-for k in ox.getenv() do io.write(k,"\t") end io.write"\n"
+for k,_ in pairs(ox.getenv()) do io.write(k,"\t") end io.write"\n"
 
 ------------------------------------------------------------------------------
 testing"putenv"
@@ -179,11 +179,11 @@
 ------------------------------------------------------------------------------
 testing"times"
 a=ox.times()
-for k,v in a do print(k,v) end
+for k,v in pairs(a) do print(k,v) end
 print"sleeping 10 seconds..."
 ox.sleep(10)
 b=ox.times()
-for k,v in b do print(k,v) end
+for k,v in pairs(b) do print(k,v) end
 print""
 print("elapsed",b.elapsed-a.elapsed)
 print("clock",os.clock())