--- a/lua.c Wed Jul 25 11:49:11 2012 -0700
+++ b/lua.c Tue Jun 09 12:01:57 2015 -0700
@@ -1,6 +1,6 @@
/* vim: set noet nosta sw=4 ts=4 ft=c : */
/*
-Copyright (c) 2011-2012, Mahlon E. Smith <mahlon@martini.nu>
+Copyright (c) 2011-2015, Mahlon E. Smith <mahlon@martini.nu>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -79,25 +79,23 @@
luaL_openlibs( lua ); /* include lua standard libraries */
/* Predeclare the request table. */
- lua_pushstring( lua, "request" );
lua_createtable( lua, 0, 7 );
- lua_settable( lua, LUA_GLOBALSINDEX );
+ lua_setglobal( lua, "request" );
/* Predeclare a table for shared data */
- lua_pushstring( lua, "shared" );
lua_newtable( lua );
- lua_settable( lua, LUA_GLOBALSINDEX );
+ lua_setglobal( lua, "shared" );
/* replace the lua print() function with one that calls debug() instead */
lua_register( lua, "print", luaV_print );
/* Restrict additional globals. */
- lua_createtable( lua, 0, 1);
- lua_pushcfunction( lua, luaV_globalindex );
- lua_setfield( lua, -2, "__newindex");
- lua_pushboolean( lua, 0 );
- lua_setfield( lua, -2, "__metatable");
- lua_setmetatable( lua, LUA_GLOBALSINDEX );
+ lua_createtable( lua, 0, 1);
+ lua_pushcfunction( lua, luaV_globalindex );
+ lua_setfield( lua, -2, "__newindex");
+ lua_pushboolean( lua, 0 );
+ lua_setfield( lua, -2, "__metatable");
+ lua_setmetatable( lua, -2 );
lua_settop( lua, 0 ); /* wipe the stack */
return( lua );
@@ -111,7 +109,7 @@
void
luaV_setup_request( parsed *request )
{
- lua_getfield( v.lua, LUA_GLOBALSINDEX, "request" );
+ lua_getglobal( v.lua, "request" );
lua_pushstring( v.lua, request->scheme );
lua_setfield( v.lua, 1, "scheme" );
lua_pushstring( v.lua, request->host );