diff options
Diffstat (limited to '')
-rw-r--r-- | src/LuaSL/LuaSL_compile.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index f2fa37e..41d354f 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c | |||
@@ -2338,38 +2338,42 @@ boolean compileLSL(gameGlobals *ourGlobals, Ecore_Con_Client *client, char *SID, | |||
2338 | fclose(out); | 2338 | fclose(out); |
2339 | 2339 | ||
2340 | // Compile the Lua source code. | 2340 | // Compile the Lua source code. |
2341 | L = luaL_newstate(); | 2341 | if ((L = luaL_newstate())) |
2342 | luaL_openlibs(L); | ||
2343 | // This ends up pushing a function onto the stack. The function is the compiled code. | ||
2344 | err = luaL_loadfile(L, luaName); | ||
2345 | if (err) | ||
2346 | { | 2342 | { |
2347 | compiler.script.bugCount++; | 2343 | luaL_openlibs(L); |
2348 | if (LUA_ERRSYNTAX == err) | 2344 | // This ends up pushing a function onto the stack. The function is the compiled code. |
2349 | PE("Lua syntax error in %s: %s", luaName, lua_tostring(L, -1)); | 2345 | err = luaL_loadfile(L, luaName); |
2350 | else if (LUA_ERRFILE == err) | 2346 | if (err) |
2351 | PE("Lua compile file error in %s: %s", luaName, lua_tostring(L, -1)); | ||
2352 | else if (LUA_ERRMEM == err) | ||
2353 | PE("Lua compile memory allocation error in %s: %s", luaName, lua_tostring(L, -1)); | ||
2354 | } | ||
2355 | else | ||
2356 | { | ||
2357 | // Write the compiled code to a file. | ||
2358 | strcat(luaName, ".out"); | ||
2359 | out = fopen(luaName, "w"); | ||
2360 | if (out) | ||
2361 | { | 2347 | { |
2362 | err = lua_dump(L, luaWriter, out); | 2348 | compiler.script.bugCount++; |
2363 | if (err) | 2349 | if (LUA_ERRSYNTAX == err) |
2350 | PE("Lua syntax error in %s: %s", luaName, lua_tostring(L, -1)); | ||
2351 | else if (LUA_ERRFILE == err) | ||
2352 | PE("Lua compile file error in %s: %s", luaName, lua_tostring(L, -1)); | ||
2353 | else if (LUA_ERRMEM == err) | ||
2354 | PE("Lua compile memory allocation error in %s: %s", luaName, lua_tostring(L, -1)); | ||
2355 | } | ||
2356 | else | ||
2357 | { | ||
2358 | // Write the compiled code to a file. | ||
2359 | strcat(luaName, ".out"); | ||
2360 | out = fopen(luaName, "w"); | ||
2361 | if (out) | ||
2364 | { | 2362 | { |
2365 | compiler.script.bugCount++; | 2363 | err = lua_dump(L, luaWriter, out); |
2366 | PE("Lua compile file error writing to %s", luaName); | 2364 | if (err) |
2365 | { | ||
2366 | compiler.script.bugCount++; | ||
2367 | PE("Lua compile file error writing to %s", luaName); | ||
2368 | } | ||
2369 | fclose(out); | ||
2367 | } | 2370 | } |
2368 | fclose(out); | 2371 | else |
2372 | PC("Unable to open file %s for writing!", luaName); | ||
2369 | } | 2373 | } |
2370 | else | ||
2371 | PC("Unable to open file %s for writing!", luaName); | ||
2372 | } | 2374 | } |
2375 | else | ||
2376 | PE("Can't create a new Lua state!"); | ||
2373 | } | 2377 | } |
2374 | else | 2378 | else |
2375 | PC("Unable to open file %s for writing!", luaName); | 2379 | PC("Unable to open file %s for writing!", luaName); |