openbsd-ports/astro/celestia/patches/patch-src_celestia_celx_cpp

56 lines
1.7 KiB
Plaintext
Raw Normal View History

$OpenBSD: patch-src_celestia_celx_cpp,v 1.1.1.1 2007/07/16 17:39:21 ajacoutot Exp $
$NetBSD: patch-ai,v 1.3 2006/08/14 22:43:08 wiz Exp $
--- src/celestia/celx.cpp.orig Thu Jul 12 12:02:16 2007
+++ src/celestia/celx.cpp Thu Jul 12 12:09:51 2007
@@ -368,6 +368,17 @@ static CelestiaCore* getAppCore(lua_State* l, FatalErr
return appCore;
}
+static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
+ (void)ud; /* not used */
+ (void)osize; /* not used */
+ if (nsize == 0) {
+ free(ptr); /* ANSI requires that free(NULL) has no effect */
+ return NULL;
+ }
+ else
+ /* ANSI requires that realloc(NULL, size) == malloc(size) */
+ return realloc(ptr, nsize);
+}
LuaState::LuaState() :
timeout(MaxTimeslice),
@@ -378,7 +389,7 @@ LuaState::LuaState() :
scriptAwakenTime(0.1),
ioMode(NoIO)
{
- state = lua_open();
+ state = lua_newstate(l_alloc, NULL);
timer = CreateTimer();
screenshotCount = 0;
}
@@ -598,7 +609,7 @@ bool LuaState::charEntered(const char* c_p)
int stackTop = lua_gettop(costate);
if (strcmp(c_p, "y") == 0)
{
- lua_iolibopen(costate);
+ luaopen_io(costate);
ioMode = IOAllowed;
}
else
@@ -4577,10 +4588,10 @@ bool LuaState::init(CelestiaCore* appCore)
initMaps();
// Import the base and math libraries
- lua_baselibopen(state);
- lua_mathlibopen(state);
- lua_tablibopen(state);
- lua_strlibopen(state);
+ luaopen_base(state);
+ luaopen_math(state);
+ luaopen_table(state);
+ luaopen_string(state);
// Add an easy to use wait function, so that script writers can
// live in ignorance of coroutines. There will probably be a significant