~ubuntu-branches/ubuntu/raring/haserl/raring

« back to all changes in this revision

Viewing changes to src/h_luac.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2011-05-11 01:53:02 UTC
  • mfrom: (0.1.2 sid) (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511015302-xr0yki5ivh3dz4g5
Tags: 0.9.29-1
Initial release (Closes: #611445)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* --------------------------------------------------------------------------
2
 
 * lua language specific functions (for compiled Lua chunks)
3
 
 * Copyright (c) 2003-2007   Nathan Angelacos (nangel@users.sourceforge.net)
4
 
 *
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.
8
 
 *
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.
13
 
 *
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
17
 
 *
18
 
 ------------------------------------------------------------------------- */
 
2
 * Copyright 2003-2011 (inclusive) Nathan Angelacos 
 
3
 *                   (nangel@users.sourceforge.net)
 
4
 * 
 
5
 *   This file is part of haserl.
 
6
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 *
 
19
 * ------------------------------------------------------------------------ */
19
20
 
20
21
#if HAVE_CONFIG_H
21
22
#include <config.h>
33
34
 
34
35
        /* tokenizer was not used, so script is NULL, but name is the filename to process */
35
36
void
36
 
luac_doscript (buffer_t *script, char *name)
 
37
luac_doscript (buffer_t * script, char *name)
37
38
{
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))
39
40
    {
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));
41
43
    }
42
44
}
43
45
 
44
46
int
45
 
h_luac_loadfile (lua_State *L)
 
47
h_luac_loadfile (lua_State * L)
46
48
{
47
49
  const char *filename = luaL_checkstring (L, 1);
48
50
 
49
51
  if (luaL_loadfile (L, filename))
50
52
    {
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 */
53
56
 
54
57
  return 1;
55
58
}