#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
gehe zum Quellcode dieser Datei
|
static void | lstop (lua_State *L, lua_Debug *ar) |
|
static void | laction (int i) |
|
static void | print_usage (void) |
|
static void | l_message (const char *pname, const char *msg) |
|
static int | report (lua_State *L, int status) |
|
static int | traceback (lua_State *L) |
|
static int | docall (lua_State *L, int narg, int clear) |
|
static void | print_version (void) |
|
static int | getargs (lua_State *L, char **argv, int n) |
|
static int | dofile (lua_State *L, const char *name) |
|
static int | dostring (lua_State *L, const char *s, const char *name) |
|
static int | dolibrary (lua_State *L, const char *name) |
|
static const char * | get_prompt (lua_State *L, int firstline) |
|
static int | incomplete (lua_State *L, int status) |
|
static int | pushline (lua_State *L, int firstline) |
|
static int | loadline (lua_State *L) |
|
static void | dotty (lua_State *L) |
|
static int | handle_script (lua_State *L, char **argv, int n) |
|
static int | collectargs (char **argv, int *pi, int *pv, int *pe) |
|
static int | runargs (lua_State *L, char **argv, int n) |
|
static int | handle_luainit (lua_State *L) |
|
static int | pmain (lua_State *L) |
|
int | main (int argc, char **argv) |
|
Definiert in Zeile 13 der Datei lua.c.
#define notail |
( |
|
x) | |
{if ((x)[2] != '\0') return -1;} |
static int collectargs |
( |
char ** |
argv, |
|
|
int * |
pi, |
|
|
int * |
pv, |
|
|
int * |
pe |
|
) |
| |
|
static |
Definiert in Zeile 261 der Datei lua.c.
263 for (i = 1; argv[i] !=
NULL; i++) {
264 if (argv[i][0] !=
'-')
266 switch (argv[i][1]) {
269 return (argv[i+1] !=
NULL ? i+1 : 0);
282 if (argv[i][2] ==
'\0') {
284 if (argv[i] ==
NULL)
return -1;
static int docall |
( |
lua_State * |
L, |
|
|
int |
narg, |
|
|
int |
clear |
|
) |
| |
|
static |
Definiert in Zeile 96 der Datei lua.c.
103 signal(SIGINT, SIG_DFL);
Definiert in Zeile 216 der Datei lua.c.
220 while ((status =
loadline(L)) != -1) {
221 if (status == 0) status =
docall(L, 0, 0);
228 "error calling " LUA_QL(
"print")
" (%s)",
Definiert in Zeile 153 der Datei lua.c.
157 if (p ==
NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2);
static int getargs |
( |
lua_State * |
L, |
|
|
char ** |
argv, |
|
|
int |
n |
|
) |
| |
|
static |
Definiert in Zeile 116 der Datei lua.c.
120 while (argv[argc]) argc++;
121 narg = argc - (
n + 1);
123 for (i=
n+1; i < argc; i++)
126 for (i=0; i < argc; i++) {
Definiert in Zeile 323 der Datei lua.c.
324 const char *init = getenv(
LUA_INIT);
325 if (init ==
NULL)
return 0;
326 else if (init[0] ==
'@')
static int handle_script |
( |
lua_State * |
L, |
|
|
char ** |
argv, |
|
|
int |
n |
|
) |
| |
|
static |
Definiert in Zeile 239 der Datei lua.c.
250 status =
docall(L, narg, 0);
static int incomplete |
( |
lua_State * |
L, |
|
|
int |
status |
|
) |
| |
|
static |
Definiert in Zeile 163 der Datei lua.c.
167 const char *tp = msg + lmsg - (
sizeof(
LUA_QL(
"<eof>")) - 1);
static void l_message |
( |
const char * |
pname, |
|
|
const char * |
msg |
|
) |
| |
|
static |
Definiert in Zeile 58 der Datei lua.c.
59 if (pname) fprintf(stderr,
"%s: ", pname);
60 fprintf(stderr,
"%s\n", msg);
static void laction |
( |
int |
i) | |
|
|
static |
Definiert in Zeile 35 der Datei lua.c.
Definiert in Zeile 28 der Datei lua.c.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definiert in Zeile 377 der Datei lua.c.
382 l_message(
argv[0],
"cannot create state: not enough memory");
390 return (status ||
s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
Definiert in Zeile 340 der Datei lua.c.
344 int has_i = 0, has_v = 0, has_e = 0;
346 if (argv[0] && argv[0][0])
progname = argv[0];
351 if (s->
status != 0)
return 0;
352 script =
collectargs(argv, &has_i, &has_v, &has_e);
360 if (s->
status != 0)
return 0;
363 if (s->
status != 0)
return 0;
366 else if (script == 0 && !has_e && !has_v) {
367 if (lua_stdin_is_tty()) {
static void print_usage |
( |
void |
) | |
|
|
static |
Definiert in Zeile 42 der Datei lua.c.
44 "usage: %s [options] [script [args]].\n"
45 "Available options are:\n"
46 " -e stat execute string " LUA_QL(
"stat")
"\n"
47 " -l name require library " LUA_QL(
"name")
"\n"
48 " -i enter interactive mode after executing " LUA_QL(
"script")
"\n"
49 " -v show version information\n"
50 " -- stop handling options\n"
51 " - execute stdin and stop handling options\n"
static void print_version |
( |
void |
) | |
|
|
static |
static int pushline |
( |
lua_State * |
L, |
|
|
int |
firstline |
|
) |
| |
|
static |
Definiert in Zeile 177 der Datei lua.c.
178 char buffer[LUA_MAXINPUT];
182 if (lua_readline(L, b, prmt) == 0)
185 if (l > 0 && b[l-1] ==
'\n')
187 if (firstline && b[0] ==
'=')
static int report |
( |
lua_State * |
L, |
|
|
int |
status |
|
) |
| |
|
static |
Definiert in Zeile 65 der Datei lua.c.
68 if (msg ==
NULL) msg =
"(error object is not a string)";
static int runargs |
( |
lua_State * |
L, |
|
|
char ** |
argv, |
|
|
int |
n |
|
) |
| |
|
static |
Definiert in Zeile 294 der Datei lua.c.
296 for (i = 1; i <
n; i++) {
299 switch (
argv[i][1]) {
302 if (*chunk ==
'\0') chunk =
argv[++i];
304 if (
dostring(L, chunk,
"=(command line)") != 0)
309 const char *filename =
argv[i] + 2;
310 if (*filename ==
'\0') filename =
argv[++i];
Definiert in Zeile 76 der Datei lua.c.
Definiert in Zeile 22 der Datei lua.c.
const char* progname = LUA_PROGNAME |
|
static |
Definiert in Zeile 24 der Datei lua.c.