26#define PROGNAME "luac"
27#define OUTPUT PROGNAME ".out"
36static void fatal(
const char* message)
38 fprintf(stderr,
"%s: %s\n",
progname,message);
44 fprintf(stderr,
"%s: cannot %s %s: %s\n",
progname,what,
output,strerror(errno));
48static void usage(
const char* message)
51 fprintf(stderr,
"%s: unrecognized option " LUA_QS "\n",
progname,message);
53 fprintf(stderr,
"%s: %s\n",
progname,message);
55 "usage: %s [options] [filenames].\n"
56 "Available options are:\n"
59 " -o name output to file " LUA_QL(
"name")
" (default is \"%s\")\n"
61 " -s strip debug information\n"
62 " -v show version information\n"
63 " -- stop handling options\n",
68#define IS(s) (strcmp(argv[i],s)==0)
70static int doargs(
int argc,
char* argv[])
75 for (i=1; i<argc; i++)
82 if (version) ++version;
112 if (version==argc-1) exit(EXIT_SUCCESS);
117#define toproto(L,i) (clvalue(L->top+(i))->l.p)
150 return (
fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
166 for (i=0; i<
argc; i++)
168 const char* filename=
IS(
"-") ?
NULL :
argv[i];
180 if (ferror(D))
cannot(
"write");
181 if (fclose(D))
cannot(
"close");
192 if (
argc<=0)
usage(
"no input files given");
194 if (L==
NULL)
fatal(
"not enough memory for state");
LUA_API void * lua_touserdata(lua_State *L, int idx)
LUA_API int lua_checkstack(lua_State *L, int size)
LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud)
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
Proto * luaF_newproto(lua_State *L)
#define luaM_newvector(L, n, t)
#define CREATE_ABx(o, a, bc)
#define CREATE_ABC(o, a, b, c)
LUA_API void lua_close(lua_State *L)
#define luaS_newliteral(L, s)
#define lua_tostring(L, i)
static int doargs(int argc, char *argv[])
static const char * output
static const Proto * combine(lua_State *L, int n)
static void fatal(const char *message)
static void usage(const char *message)
static int writer(lua_State *L, const void *p, size_t size, void *u)
static int pmain(lua_State *L)
static void cannot(const char *what)
static const char * progname
#define luaL_loadfile(L, f)
CURL_EXTERN CURLMcode curl_socket_t s