1
1
/* --------------------------------------------------------------------------
2
* lua language specific functions (for compiled Lua chunks)
3
* Copyright (c) 2003-2007 Nathan Angelacos (nangel@users.sourceforge.net)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License, version 2,
7
* as published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
------------------------------------------------------------------------- */
2
* Copyright 2003-2011 (inclusive) Nathan Angelacos
3
* (nangel@users.sourceforge.net)
5
* This file is part of haserl.
7
* Haserl is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2,
9
* as published by the Free Software Foundation.
11
* Haserl is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with haserl. If not, see <http://www.gnu.org/licenses/>.
19
* ------------------------------------------------------------------------ */
21
22
#include <config.h>
34
35
/* tokenizer was not used, so script is NULL, but name is the filename to process */
36
luac_doscript (buffer_t *script, char *name)
37
luac_doscript (buffer_t * script, char *name)
38
if (luaL_loadfile (lua_vm, name) || lua_pcall(lua_vm, 0, LUA_MULTRET, 0))
39
if (luaL_loadfile (lua_vm, name) || lua_pcall (lua_vm, 0, LUA_MULTRET, 0))
40
die_with_message (NULL, NULL, "Cannot load lua and execute chunk: %s", lua_tostring(lua_vm, -1));
41
die_with_message (NULL, NULL, "Cannot load lua and execute chunk: %s",
42
lua_tostring (lua_vm, -1));
45
h_luac_loadfile (lua_State *L)
47
h_luac_loadfile (lua_State * L)
47
49
const char *filename = luaL_checkstring (L, 1);
49
51
if (luaL_loadfile (L, filename))
51
die_with_message (NULL, NULL, "Cannot load file '%s': %s", filename, lua_tostring(L, -1));
52
} /* no error: function is on the stack */
53
die_with_message (NULL, NULL, "Cannot load file '%s': %s", filename,
54
lua_tostring (L, -1));
55
} /* no error: function is on the stack */