The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lua.cpp
Go to the documentation of this file.
1 /*
2 ** Lua stand-alone interpreter
3 ** See Copyright Notice in lua.h
4 */
5 
6 
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 
12 #define lua_c
13 
14 #include "lua.h"
15 
16 #include "lauxlib.h"
17 #include "lualib.h"
18 
19 
20 #if !defined(LUA_PROMPT)
21 #define LUA_PROMPT "> "
22 #define LUA_PROMPT2 ">> "
23 #endif
24 
25 #if !defined(LUA_PROGNAME)
26 #define LUA_PROGNAME "lua"
27 #endif
28 
29 #if !defined(LUA_MAXINPUT)
30 #define LUA_MAXINPUT 512
31 #endif
32 
33 #if !defined(LUA_INIT)
34 #define LUA_INIT "LUA_INIT"
35 #endif
36 
37 #define LUA_INITVERSION \
38  LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
39 
40 
41 /*
42 ** lua_stdin_is_tty detects whether the standard input is a 'tty' (that
43 ** is, whether we're running lua interactively).
44 */
45 #if defined(LUA_USE_ISATTY)
46 #include <unistd.h>
47 #define lua_stdin_is_tty() isatty(0)
48 #elif defined(LUA_WIN)
49 #include <io.h>
50 #include <stdio.h>
51 #define lua_stdin_is_tty() _isatty(_fileno(stdin))
52 #else
53 #define lua_stdin_is_tty() 1 /* assume stdin is a tty */
54 #endif
55 
56 
57 /*
58 ** lua_readline defines how to show a prompt and then read a line from
59 ** the standard input.
60 ** lua_saveline defines how to "save" a read line in a "history".
61 ** lua_freeline defines how to free a line read by lua_readline.
62 */
63 #if defined(LUA_USE_READLINE)
64 
65 #include <stdio.h>
66 #include <readline/readline.h>
67 #include <readline/history.h>
68 #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
69 #define lua_saveline(L,idx) \
70  if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \
71  add_history(lua_tostring(L, idx)); /* add it to history */
72 #define lua_freeline(L,b) ((void)L, free(b))
73 
74 #elif !defined(lua_readline)
75 
76 #define lua_readline(L,b,p) \
77  ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
78  fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
79 #define lua_saveline(L,idx) { (void)L; (void)idx; }
80 #define lua_freeline(L,b) { (void)L; (void)b; }
81 
82 #endif
83 
84 
85 
86 
87 static lua_State *globalL = NULL;
88 
89 static const char *progname = LUA_PROGNAME;
90 
91 
92 
93 static void lstop (lua_State *L, lua_Debug *ar) {
94  (void)ar; /* unused arg. */
95  lua_sethook(L, NULL, 0, 0);
96  luaL_error(L, "interrupted!");
97 }
98 
99 
100 static void laction (int i) {
101  signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
102  terminate process (default action) */
104 }
105 
106 
107 static void print_usage (const char *badoption) {
109  if (badoption[1] == 'e' || badoption[1] == 'l')
110  luai_writestringerror("'%s' needs argument\n", badoption);
111  else
112  luai_writestringerror("unrecognized option '%s'\n", badoption);
114  "usage: %s [options] [script [args]]\n"
115  "Available options are:\n"
116  " -e stat execute string " LUA_QL("stat") "\n"
117  " -i enter interactive mode after executing " LUA_QL("script") "\n"
118  " -l name require library " LUA_QL("name") "\n"
119  " -v show version information\n"
120  " -E ignore environment variables\n"
121  " -- stop handling options\n"
122  " - stop handling options and execute stdin\n"
123  ,
124  progname);
125 }
126 
127 
128 static void l_message (const char *pname, const char *msg) {
129  if (pname) luai_writestringerror("%s: ", pname);
130  luai_writestringerror("%s\n", msg);
131 }
132 
133 
134 static int report (lua_State *L, int status) {
135  if (status != LUA_OK && !lua_isnil(L, -1)) {
136  const char *msg = lua_tostring(L, -1);
137  if (msg == NULL) msg = "(error object is not a string)";
138  l_message(progname, msg);
139  lua_pop(L, 1);
140  /* force a complete garbage collection in case of errors */
141  lua_gc(L, LUA_GCCOLLECT, 0);
142  }
143  return status;
144 }
145 
146 
147 /* the next function is called unprotected, so it must avoid errors */
148 static void finalreport (lua_State *L, int status) {
149  if (status != LUA_OK) {
150  const char *msg = (lua_type(L, -1) == LUA_TSTRING) ? lua_tostring(L, -1)
151  : NULL;
152  if (msg == NULL) msg = "(error object is not a string)";
153  l_message(progname, msg);
154  lua_pop(L, 1);
155  }
156 }
157 
158 
159 static int traceback (lua_State *L) {
160  const char *msg = lua_tostring(L, 1);
161  if (msg)
162  luaL_traceback(L, L, msg, 1);
163  else if (!lua_isnoneornil(L, 1)) { /* is there an error object? */
164  if (!luaL_callmeta(L, 1, "__tostring")) /* try its 'tostring' metamethod */
165  lua_pushliteral(L, "(no error message)");
166  }
167  return 1;
168 }
169 
170 
171 static int docall (lua_State *L, int narg, int nres) {
172  int status;
173  int base = lua_gettop(L) - narg; /* function index */
174  lua_pushcfunction(L, traceback); /* push traceback function */
175  lua_insert(L, base); /* put it under chunk and args */
176  globalL = L; /* to be available to 'laction' */
177  signal(SIGINT, laction);
178  status = lua_pcall(L, narg, nres, base);
179  signal(SIGINT, SIG_DFL);
180  lua_remove(L, base); /* remove traceback function */
181  return status;
182 }
183 
184 
185 static void print_version (void) {
186  luai_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT));
187  luai_writeline();
188 }
189 
190 
191 static int getargs (lua_State *L, char **argv, int n) {
192  int narg;
193  int i;
194  int argc = 0;
195  while (argv[argc]) argc++; /* count total number of arguments */
196  narg = argc - (n + 1); /* number of arguments to the script */
197  luaL_checkstack(L, narg + 3, "too many arguments to script");
198  for (i=n+1; i < argc; i++)
199  lua_pushstring(L, argv[i]);
200  lua_createtable(L, narg, n + 1);
201  for (i=0; i < argc; i++) {
202  lua_pushstring(L, argv[i]);
203  lua_rawseti(L, -2, i - n);
204  }
205  return narg;
206 }
207 
208 
209 static int dofile (lua_State *L, const char *name) {
210  int status = luaL_loadfile(L, name);
211  if (status == LUA_OK) status = docall(L, 0, 0);
212  return report(L, status);
213 }
214 
215 
216 static int dostring (lua_State *L, const char *s, const char *name) {
217  int status = luaL_loadbuffer(L, s, strlen(s), name);
218  if (status == LUA_OK) status = docall(L, 0, 0);
219  return report(L, status);
220 }
221 
222 
223 static int dolibrary (lua_State *L, const char *name) {
224  int status;
225  lua_getglobal(L, "require");
226  lua_pushstring(L, name);
227  status = docall(L, 1, 1); /* call 'require(name)' */
228  if (status == LUA_OK)
229  lua_setglobal(L, name); /* global[name] = require return */
230  return report(L, status);
231 }
232 
233 
234 static const char *get_prompt (lua_State *L, int firstline) {
235  const char *p;
236  lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2");
237  p = lua_tostring(L, -1);
238  if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2);
239  return p;
240 }
241 
242 /* mark in error messages for incomplete statements */
243 #define EOFMARK "<eof>"
244 #define marklen (sizeof(EOFMARK)/sizeof(char) - 1)
245 
246 static int incomplete (lua_State *L, int status) {
247  if (status == LUA_ERRSYNTAX) {
248  size_t lmsg;
249  const char *msg = lua_tolstring(L, -1, &lmsg);
250  if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) {
251  lua_pop(L, 1);
252  return 1;
253  }
254  }
255  return 0; /* else... */
256 }
257 
258 
259 static int pushline (lua_State *L, int firstline) {
260  char buffer[LUA_MAXINPUT];
261  char *b = buffer;
262  size_t l;
263  const char *prmt = get_prompt(L, firstline);
264  int readstatus = lua_readline(L, b, prmt);
265  lua_pop(L, 1); /* remove result from 'get_prompt' */
266  if (readstatus == 0)
267  return 0; /* no input */
268  l = strlen(b);
269  if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
270  b[l-1] = '\0'; /* remove it */
271  if (firstline && b[0] == '=') /* first line starts with `=' ? */
272  lua_pushfstring(L, "return %s", b+1); /* change it to `return' */
273  else
274  lua_pushstring(L, b);
275  lua_freeline(L, b);
276  return 1;
277 }
278 
279 
280 static int loadline (lua_State *L) {
281  int status;
282  lua_settop(L, 0);
283  if (!pushline(L, 1))
284  return -1; /* no input */
285  for (;;) { /* repeat until gets a complete line */
286  size_t l;
287  const char *line = lua_tolstring(L, 1, &l);
288  status = luaL_loadbuffer(L, line, l, "=stdin");
289  if (!incomplete(L, status)) break; /* cannot try to add lines? */
290  if (!pushline(L, 0)) /* no more input? */
291  return -1;
292  lua_pushliteral(L, "\n"); /* add a new line... */
293  lua_insert(L, -2); /* ...between the two lines */
294  lua_concat(L, 3); /* join them */
295  }
296  lua_saveline(L, 1);
297  lua_remove(L, 1); /* remove line */
298  return status;
299 }
300 
301 
302 static void dotty (lua_State *L) {
303  int status;
304  const char *oldprogname = progname;
305  progname = NULL;
306  while ((status = loadline(L)) != -1) {
307  if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET);
308  report(L, status);
309  if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */
310  luaL_checkstack(L, LUA_MINSTACK, "too many results to print");
311  lua_getglobal(L, "print");
312  lua_insert(L, 1);
313  if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK)
315  "error calling " LUA_QL("print") " (%s)",
316  lua_tostring(L, -1)));
317  }
318  }
319  lua_settop(L, 0); /* clear stack */
320  luai_writeline();
321  progname = oldprogname;
322 }
323 
324 
325 static int handle_script (lua_State *L, char **argv, int n) {
326  int status;
327  const char *fname;
328  int narg = getargs(L, argv, n); /* collect arguments */
329  lua_setglobal(L, "arg");
330  fname = argv[n];
331  if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0)
332  fname = NULL; /* stdin */
333  status = luaL_loadfile(L, fname);
334  lua_insert(L, -(narg+1));
335  if (status == LUA_OK)
336  status = docall(L, narg, LUA_MULTRET);
337  else
338  lua_pop(L, narg);
339  return report(L, status);
340 }
341 
342 
343 /* check that argument has no extra characters at the end */
344 #define noextrachars(x) {if ((x)[2] != '\0') return -1;}
345 
346 
347 /* indices of various argument indicators in array args */
348 #define has_i 0 /* -i */
349 #define has_v 1 /* -v */
350 #define has_e 2 /* -e */
351 #define has_E 3 /* -E */
352 
353 #define num_has 4 /* number of 'has_*' */
354 
355 
356 static int collectargs (char **argv, int *args) {
357  int i;
358  for (i = 1; argv[i] != NULL; i++) {
359  if (argv[i][0] != '-') /* not an option? */
360  return i;
361  switch (argv[i][1]) { /* option */
362  case '-':
363  noextrachars(argv[i]);
364  return (argv[i+1] != NULL ? i+1 : 0);
365  case '\0':
366  return i;
367  case 'E':
368  args[has_E] = 1;
369  break;
370  case 'i':
371  noextrachars(argv[i]);
372  args[has_i] = 1; /* go through */
373  case 'v':
374  noextrachars(argv[i]);
375  args[has_v] = 1;
376  break;
377  case 'e':
378  args[has_e] = 1; /* go through */
379  case 'l': /* both options need an argument */
380  if (argv[i][2] == '\0') { /* no concatenated argument? */
381  i++; /* try next 'argv' */
382  if (argv[i] == NULL || argv[i][0] == '-')
383  return -(i - 1); /* no next argument or it is another option */
384  }
385  break;
386  default: /* invalid option; return its index... */
387  return -i; /* ...as a negative value */
388  }
389  }
390  return 0;
391 }
392 
393 
394 static int runargs (lua_State *L, char **argv, int n) {
395  int i;
396  for (i = 1; i < n; i++) {
397  lua_assert(argv[i][0] == '-');
398  switch (argv[i][1]) { /* option */
399  case 'e': {
400  const char *chunk = argv[i] + 2;
401  if (*chunk == '\0') chunk = argv[++i];
402  lua_assert(chunk != NULL);
403  if (dostring(L, chunk, "=(command line)") != LUA_OK)
404  return 0;
405  break;
406  }
407  case 'l': {
408  const char *filename = argv[i] + 2;
409  if (*filename == '\0') filename = argv[++i];
410  lua_assert(filename != NULL);
411  if (dolibrary(L, filename) != LUA_OK)
412  return 0; /* stop if file fails */
413  break;
414  }
415  default: break;
416  }
417  }
418  return 1;
419 }
420 
421 
422 static int handle_luainit (lua_State *L) {
423  const char *name = "=" LUA_INITVERSION;
424  const char *init = getenv(name + 1);
425  if (init == NULL) {
426  name = "=" LUA_INIT;
427  init = getenv(name + 1); /* try alternative name */
428  }
429  if (init == NULL) return LUA_OK;
430  else if (init[0] == '@')
431  return dofile(L, init+1);
432  else
433  return dostring(L, init, name);
434 }
435 
436 
437 static int pmain (lua_State *L) {
438  int argc = (int)lua_tointeger(L, 1);
439  char **argv = (char **)lua_touserdata(L, 2);
440  int script;
441  int args[num_has];
442  args[has_i] = args[has_v] = args[has_e] = args[has_E] = 0;
443  if (argv[0] && argv[0][0]) progname = argv[0];
444  script = collectargs(argv, args);
445  if (script < 0) { /* invalid arg? */
446  print_usage(argv[-script]);
447  return 0;
448  }
449  if (args[has_v]) print_version();
450  if (args[has_E]) { /* option '-E'? */
451  lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
452  lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
453  }
454  /* open standard libraries */
456  lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
457  luaL_openlibs(L); /* open libraries */
458  lua_gc(L, LUA_GCRESTART, 0);
459  if (!args[has_E] && handle_luainit(L) != LUA_OK)
460  return 0; /* error running LUA_INIT */
461  /* execute arguments -e and -l */
462  if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
463  /* execute main script (if there is one) */
464  if (script && handle_script(L, argv, script) != LUA_OK) return 0;
465  if (args[has_i]) /* -i option? */
466  dotty(L);
467  else if (script == 0 && !args[has_e] && !args[has_v]) { /* no arguments? */
468  if (lua_stdin_is_tty()) {
469  print_version();
470  dotty(L);
471  }
472  else dofile(L, NULL); /* executes stdin as a file */
473  }
474  lua_pushboolean(L, 1); /* signal no errors */
475  return 1;
476 }
477 
478 
479 int main (int argc, char **argv) {
480  int status, result;
481  lua_State *L = luaL_newstate(); /* create state */
482  if (L == NULL) {
483  l_message(argv[0], "cannot create state: not enough memory");
484  return EXIT_FAILURE;
485  }
486  /* call 'pmain' in protected mode */
488  lua_pushinteger(L, argc); /* 1st argument */
489  lua_pushlightuserdata(L, argv); /* 2nd argument */
490  status = lua_pcall(L, 2, 1, 0);
491  result = lua_toboolean(L, -1); /* get result */
492  finalreport(L, status);
493  lua_close(L);
494  return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
495 }
496 
LUALIB_API void luaL_openlibs(lua_State *L)
Definition: linit.cpp:51
static void l_message(const char *pname, const char *msg)
Definition: lua.cpp:128
#define lua_isnoneornil(L, n)
Definition: lua.h:337
Definition: lua.h:398
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
Definition: lapi.cpp:579
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
Definition: lapi.cpp:667
#define lua_pushcfunction(L, f)
Definition: lua.h:328
static void print_usage(const char *badoption)
Definition: lua.cpp:107
static int handle_script(lua_State *L, char **argv, int n)
Definition: lua.cpp:325
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1806
LUALIB_API lua_State * luaL_newstate(void)
Definition: lauxlib.cpp:939
static lua_State * globalL
Definition: lua.cpp:87
LUA_API void lua_settop(lua_State *L, int idx)
Definition: lapi.cpp:159
LUA_API int lua_type(lua_State *L, int idx)
Definition: lapi.cpp:243
static int runargs(lua_State *L, char **argv, int n)
Definition: lua.cpp:394
static void lstop(lua_State *L, lua_Debug *ar)
Definition: lua.cpp:93
LUA_API void lua_pushboolean(lua_State *L, int b)
Definition: lapi.cpp:571
static int docall(lua_State *L, int narg, int nres)
Definition: lua.cpp:171
#define LUA_MULTRET
Definition: lua.h:33
#define LUA_MASKRET
Definition: lua.h:370
#define LUA_MASKCOUNT
Definition: lua.h:372
#define LUA_MASKCALL
Definition: lua.h:369
LUA_API void lua_getglobal(lua_State *L, const char *var)
Definition: lapi.cpp:602
static int report(lua_State *L, int status)
Definition: lua.cpp:134
#define LUA_PROMPT2
Definition: lua.cpp:22
LUA_API int lua_gettop(lua_State *L)
Definition: lapi.cpp:154
static int dofile(lua_State *L, const char *name)
Definition: lua.cpp:209
#define lua_tointeger(L, i)
Definition: lua.h:319
#define LUA_MAXINPUT
Definition: lua.cpp:30
static int dolibrary(lua_State *L, const char *name)
Definition: lua.cpp:223
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
Definition: lauxlib.cpp:335
#define lua_freeline(L, b)
Definition: lua.cpp:80
#define LUA_PROMPT
Definition: lua.cpp:21
#define lua_saveline(L, idx)
Definition: lua.cpp:79
#define LUA_PROGNAME
Definition: lua.cpp:26
#define lua_pop(L, n)
Definition: lua.h:322
GLdouble l
Definition: glew.h:6966
#define luaL_loadbuffer(L, s, sz, n)
Definition: lauxlib.h:134
#define luaL_loadfile(L, f)
Definition: lauxlib.h:78
#define has_e
Definition: lua.cpp:350
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
LUA_API int lua_gc(lua_State *L, int what, int data)
Definition: lapi.cpp:1015
#define LUA_GCSTOP
Definition: lua.h:280
#define lua_stdin_is_tty()
Definition: lua.cpp:53
static const char * get_prompt(lua_State *L, int firstline)
Definition: lua.cpp:234
#define lua_pcall(L, n, r, f)
Definition: lua.h:258
#define EOFMARK
Definition: lua.cpp:243
#define LUA_TSTRING
Definition: lua.h:81
LUA_API void lua_setglobal(lua_State *L, const char *var)
Definition: lapi.cpp:728
GLuint64EXT * result
Definition: glew.h:10727
static int loadline(lua_State *L)
Definition: lua.cpp:280
#define LUA_QL(x)
Definition: luaconf.h:198
LUA_API int lua_toboolean(lua_State *L, int idx)
Definition: lapi.cpp:377
LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count)
Definition: ldebug.cpp:52
LUA_API void lua_close(lua_State *L)
Definition: lstate.cpp:316
#define noextrachars(x)
Definition: lua.cpp:344
static int pushline(lua_State *L, int firstline)
Definition: lua.cpp:259
static int getargs(lua_State *L, char **argv, int n)
Definition: lua.cpp:191
LUA_API void lua_remove(lua_State *L, int idx)
Definition: lapi.cpp:176
LUA_API const char * lua_tolstring(lua_State *L, int idx, size_t *len)
Definition: lapi.cpp:383
int main(int argc, char **argv)
Definition: lua.cpp:479
LUALIB_API int luaL_callmeta(lua_State *L, int obj, const char *event)
Definition: lauxlib.cpp:717
GLfloat GLfloat p
Definition: glew.h:12766
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
Definition: lauxlib.cpp:115
void init()
Initializes the gui subsystems.
Definition: registry.cpp:482
#define LUA_COPYRIGHT
Definition: lua.h:25
#define lua_pushliteral(L, s)
Definition: lua.h:339
GLuint buffer
Definition: glew.h:1648
#define LUA_INITVERSION
Definition: lua.cpp:37
#define LUA_INIT
Definition: lua.cpp:34
LUA_API void * lua_touserdata(lua_State *L, int idx)
Definition: lapi.cpp:421
#define luaL_checkversion(L)
Definition: lauxlib.h:29
#define lua_isnil(L, n)
Definition: lua.h:333
#define lua_assert(c)
Definition: llimits.h:65
#define lua_readline(L, b, p)
Definition: lua.cpp:76
static int traceback(lua_State *L)
Definition: lua.cpp:159
static void dotty(lua_State *L)
Definition: lua.cpp:302
#define LUA_GCCOLLECT
Definition: lua.h:282
#define has_v
Definition: lua.cpp:349
#define num_has
Definition: lua.cpp:353
size_t i
Definition: function.cpp:1057
#define LUA_ERRSYNTAX
Definition: lua.h:47
#define lua_tostring(L, i)
Definition: lua.h:345
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
Definition: lapi.cpp:778
#define LUA_MINSTACK
Definition: lua.h:92
LUA_API void lua_insert(lua_State *L, int idx)
Definition: lapi.cpp:187
#define has_i
Definition: lua.cpp:348
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
Definition: lauxlib.cpp:198
#define luai_writestringerror(s, p)
Definition: luaconf.h:232
GLuint const GLchar * name
Definition: glew.h:1782
static int pmain(lua_State *L)
Definition: lua.cpp:437
#define LUA_REGISTRYINDEX
Definition: lua.h:39
GLclampd n
Definition: glew.h:5903
#define LUA_OK
Definition: lua.h:44
LUA_API void lua_concat(lua_State *L, int n)
Definition: lapi.cpp:1125
GLenum pname
Definition: glew.h:1656
static void finalreport(lua_State *L, int status)
Definition: lua.cpp:148
static int collectargs(char **argv, int *args)
Definition: lua.cpp:356
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
Definition: lapi.cpp:536
#define LUA_GCRESTART
Definition: lua.h:281
static int incomplete(lua_State *L, int status)
Definition: lua.cpp:246
static void laction(int i)
Definition: lua.cpp:100
#define has_E
Definition: lua.cpp:351
GLdouble s
Definition: glew.h:1358
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
Definition: lapi.cpp:477
static int handle_luainit(lua_State *L)
Definition: lua.cpp:422
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
Definition: lapi.cpp:507
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
Definition: lapi.cpp:752
static void print_version(void)
Definition: lua.cpp:185
static int dostring(lua_State *L, const char *s, const char *name)
Definition: lua.cpp:216
#define marklen
Definition: lua.cpp:244
static const char * progname
Definition: lua.cpp:89