27#if defined(__STRICT_ANSI__)
32#if !defined(LUA_ANSI) && defined(_WIN32)
36#if defined(LUA_USE_LINUX)
39#define LUA_USE_READLINE
42#if defined(LUA_USE_MACOSX)
54#if defined(LUA_USE_POSIX)
55#define LUA_USE_MKSTEMP
58#define LUA_USE_ULONGJMP
69#define LUA_PATH "LUA_PATH"
70#define LUA_CPATH "LUA_CPATH"
71#define LUA_INIT "LUA_INIT"
88#define LUA_LDIR "!\\lua\\"
90#define LUA_PATH_DEFAULT \
91 ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
92 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
93#define LUA_CPATH_DEFAULT \
94 ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
97#define LUA_ROOT "/usr/local/"
98#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
99#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
100#define LUA_PATH_DEFAULT \
101 "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
102 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
103#define LUA_CPATH_DEFAULT \
104 "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
114#define LUA_DIRSEP "\\"
116#define LUA_DIRSEP "/"
132#define LUA_PATHSEP ";"
133#define LUA_PATH_MARK "?"
134#define LUA_EXECDIR "!"
135#define LUA_IGMARK "-"
143#define LUA_INTEGER ptrdiff_t
154#if defined(LUA_BUILD_AS_DLL)
156#if defined(LUA_CORE) || defined(LUA_LIB)
157#define LUA_API __declspec(dllexport)
159#define LUA_API __declspec(dllimport)
164#define LUA_API extern
169#define LUALIB_API LUA_API
182#define LUAI_FUNC static
185#elif defined(__GNUC__) && defined(__ELF__)
186#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
187#define LUAI_DATA LUAI_FUNC
190#define LUAI_FUNC extern
191#define LUAI_DATA extern
200#define LUA_QL(x) "'" x "'"
201#define LUA_QS LUA_QL("%s")
218#if defined(lua_c) || defined(luaall_c)
226#if defined(LUA_USE_ISATTY)
228#define lua_stdin_is_tty() isatty(0)
229#elif defined(LUA_WIN)
232#define lua_stdin_is_tty() _isatty(_fileno(stdin))
234#define lua_stdin_is_tty() 1
244#define LUA_PROMPT "> "
245#define LUA_PROMPT2 ">> "
253#define LUA_PROGNAME "lua"
261#define LUA_MAXINPUT 512
272#if defined(LUA_USE_READLINE)
274#include <readline/readline.h>
275#include <readline/history.h>
276#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
277#define lua_saveline(L,idx) \
278 if (lua_strlen(L,idx) > 0) \
279 add_history(lua_tostring(L, idx));
280#define lua_freeline(L,b) ((void)L, free(b))
282#define lua_readline(L,b,p) \
283 ((void)L, fputs(p, stdout), fflush(stdout), \
284 fgets(b, LUA_MAXINPUT, stdin) != NULL)
285#define lua_saveline(L,idx) { (void)L; (void)idx; }
286#define lua_freeline(L,b) { (void)L; (void)b; }
301#define LUAI_GCPAUSE 200
312#define LUAI_GCMUL 200
321#define LUA_COMPAT_GETN
328#undef LUA_COMPAT_LOADLIB
335#define LUA_COMPAT_VARARG
342#define LUA_COMPAT_MOD
350#define LUA_COMPAT_LSTR 1
357#define LUA_COMPAT_GFIND
365#define LUA_COMPAT_OPENLIB
376#if defined(LUA_USE_APICHECK)
378#define luai_apicheck(L,o) { (void)L; assert(o); }
380#define luai_apicheck(L,o) { (void)L; }
390#if INT_MAX-20 < 32760
391#define LUAI_BITSINT 16
392#elif INT_MAX > 2147483640L
394#define LUAI_BITSINT 32
396#error "you must define LUA_BITSINT with number of bits in an integer"
412#if LUAI_BITSINT >= 32
413#define LUAI_UINT32 unsigned int
414#define LUAI_INT32 int
415#define LUAI_MAXINT32 INT_MAX
416#define LUAI_UMEM size_t
417#define LUAI_MEM ptrdiff_t
420#define LUAI_UINT32 unsigned long
421#define LUAI_INT32 long
422#define LUAI_MAXINT32 LONG_MAX
423#define LUAI_UMEM unsigned long
434#define LUAI_MAXCALLS 20000
445#define LUAI_MAXCSTACK 8000
467#define LUAI_MAXCCALLS 200
474#define LUAI_MAXVARS 200
481#define LUAI_MAXUPVALUES 60
487#define LUAL_BUFFERSIZE BUFSIZ
503#define LUA_NUMBER_DOUBLE
504#define LUA_NUMBER double
510#define LUAI_UACNUMBER double
520#define LUA_NUMBER_SCAN "%lf"
521#define LUA_NUMBER_FMT "%.14g"
522#define lua_number2str(s,n) snprintf((s), LUAI_MAXNUMBER2STR, LUA_NUMBER_FMT, (n))
523#define LUAI_MAXNUMBER2STR 32
524#define lua_str2number(s,p) strtod((s), (p))
532#define luai_numadd(a,b) ((a)+(b))
533#define luai_numsub(a,b) ((a)-(b))
534#define luai_nummul(a,b) ((a)*(b))
535#define luai_numdiv(a,b) ((a)/(b))
536#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
537#define luai_numpow(a,b) (pow(a,b))
538#define luai_numunm(a) (-(a))
539#define luai_numeq(a,b) ((a)==(b))
540#define luai_numlt(a,b) ((a)<(b))
541#define luai_numle(a,b) ((a)<=(b))
542#define luai_numisnan(a) (!luai_numeq((a), (a)))
556#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
557 (defined(__i386) || defined (_M_IX86) || defined(__i386__))
562#define lua_number2int(i,d) __asm fld d __asm fistp i
563#define lua_number2integer(i,n) lua_number2int(i, n)
569union luai_Cast {
double l_d;
long l_l; };
570#define lua_number2int(i,d) \
571 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
572#define lua_number2integer(i,n) lua_number2int(i, n)
579#define lua_number2int(i,d) ((i)=(int)(d))
580#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
594#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
607#define LUAI_THROW(L,c) throw(c)
608#define LUAI_TRY(L,c,a) try { a } catch(...) \
609 { if ((c)->status == 0) (c)->status = -1; }
610#define luai_jmpbuf int
612#elif defined(LUA_USE_ULONGJMP)
614#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
615#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
616#define luai_jmpbuf jmp_buf
620#define LUAI_THROW(L,c) longjmp((c)->b, 1)
621#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
622#define luai_jmpbuf jmp_buf
632#define LUA_MAXCAPTURES 32
640#define lua_popen(L,c,m) ((void)((void)c, m), \
641 luaL_error(L, LUA_QL("popen") " not supported"), (FILE *)0)
642#define lua_pclose(L,file) ((void)((void)L, file), 0)
658#if defined(LUA_USE_DLOPEN)
673#define LUAI_EXTRASPACE 0
681#define luai_userstateopen(L) ((void)L)
682#define luai_userstateclose(L) ((void)L)
683#define luai_userstatethread(L,L1) ((void)L)
684#define luai_userstatefree(L) ((void)L)
685#define luai_userstateresume(L,n) ((void)L)
686#define luai_userstateyield(L,n) ((void)L)
697#if defined(LUA_USELONGLONG)
699#define LUA_INTFRMLEN "ll"
700#define LUA_INTFRM_T long long
704#define LUA_INTFRMLEN "l"
705#define LUA_INTFRM_T long