diff options
-rw-r--r-- | ldo.c | 34 | ||||
-rw-r--r-- | linit.c | 4 | ||||
-rw-r--r-- | llimits.h | 45 | ||||
-rw-r--r-- | loadlib.c | 39 | ||||
-rw-r--r-- | loslib.c | 24 | ||||
-rw-r--r-- | lstate.c | 11 | ||||
-rw-r--r-- | lstrlib.c | 11 | ||||
-rw-r--r-- | ltests.h | 10 | ||||
-rw-r--r-- | lua.c | 65 | ||||
-rw-r--r-- | luaconf.h | 239 |
10 files changed, 215 insertions, 267 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.75 2009/12/08 18:59:24 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.76 2009/12/10 18:20:07 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -40,6 +40,38 @@ | |||
40 | ** ======================================================= | 40 | ** ======================================================= |
41 | */ | 41 | */ |
42 | 42 | ||
43 | /* | ||
44 | ** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By | ||
45 | ** default, Lua handles errors with exceptions when compiling as | ||
46 | ** C++ code, with _longjmp/_setjmp when asked to use them, and with | ||
47 | ** longjmp/setjmp otherwise. | ||
48 | */ | ||
49 | #if !defined(LUAI_THROW) | ||
50 | |||
51 | #if defined(__cplusplus) | ||
52 | /* C++ exceptions */ | ||
53 | #define LUAI_THROW(L,c) throw(c) | ||
54 | #define LUAI_TRY(L,c,a) \ | ||
55 | try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } | ||
56 | #define luai_jmpbuf int /* dummy variable */ | ||
57 | |||
58 | #elif defined(LUA_USE_ULONGJMP) | ||
59 | /* in Unix, try _longjmp/_setjmp (more efficient) */ | ||
60 | #define LUAI_THROW(L,c) _longjmp((c)->b, 1) | ||
61 | #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } | ||
62 | #define luai_jmpbuf jmp_buf | ||
63 | |||
64 | #else | ||
65 | /* default handling with long jumps */ | ||
66 | #define LUAI_THROW(L,c) longjmp((c)->b, 1) | ||
67 | #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } | ||
68 | #define luai_jmpbuf jmp_buf | ||
69 | |||
70 | #endif | ||
71 | |||
72 | #endif | ||
73 | |||
74 | |||
43 | 75 | ||
44 | /* chain list of long jump buffers */ | 76 | /* chain list of long jump buffers */ |
45 | struct lua_longjmp { | 77 | struct lua_longjmp { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: linit.c,v 1.20 2009/09/05 12:39:29 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.21 2009/12/11 13:40:44 roberto Exp roberto $ |
3 | ** Initialization of libraries for lua.c and other clients | 3 | ** Initialization of libraries for lua.c and other clients |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -63,7 +63,7 @@ LUALIB_API void luaL_openlibs (lua_State *L) { | |||
63 | lua_setfield(L, -2, lib->name); | 63 | lua_setfield(L, -2, lib->name); |
64 | } | 64 | } |
65 | lua_pop(L, 1); /* remove package.preload table */ | 65 | lua_pop(L, 1); /* remove package.preload table */ |
66 | #ifdef LUA_COMPAT_DEBUGLIB | 66 | #if defined(LUA_COMPAT_DEBUGLIB) |
67 | lua_getfield(L, LUA_GLOBALSINDEX, "require"); | 67 | lua_getfield(L, LUA_GLOBALSINDEX, "require"); |
68 | lua_pushliteral(L, LUA_DBLIBNAME); | 68 | lua_pushliteral(L, LUA_DBLIBNAME); |
69 | lua_call(L, 1, 0); /* call 'require"debug"' */ | 69 | lua_call(L, 1, 0); /* call 'require"debug"' */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.74 2009/08/31 14:26:28 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.75 2009/11/17 11:56:03 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,6 +44,10 @@ typedef unsigned char lu_byte; | |||
44 | 44 | ||
45 | 45 | ||
46 | /* type to ensure maximum alignment */ | 46 | /* type to ensure maximum alignment */ |
47 | #if !defined(LUAI_USER_ALIGNMENT_T) | ||
48 | #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } | ||
49 | #endif | ||
50 | |||
47 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; | 51 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; |
48 | 52 | ||
49 | 53 | ||
@@ -52,36 +56,47 @@ typedef LUAI_UACNUMBER l_uacNumber; | |||
52 | 56 | ||
53 | 57 | ||
54 | /* internal assertions for in-house debugging */ | 58 | /* internal assertions for in-house debugging */ |
55 | #ifdef lua_assert | 59 | #if defined(lua_assert) |
56 | |||
57 | #define check_exp(c,e) (lua_assert(c), (e)) | 60 | #define check_exp(c,e) (lua_assert(c), (e)) |
58 | #undef luai_apicheck | ||
59 | #define luai_apicheck(L,e) lua_assert(e) | ||
60 | |||
61 | #else | 61 | #else |
62 | |||
63 | #define lua_assert(c) ((void)0) | 62 | #define lua_assert(c) ((void)0) |
64 | #define check_exp(c,e) (e) | 63 | #define check_exp(c,e) (e) |
64 | #endif | ||
65 | 65 | ||
66 | /* | ||
67 | ** assertion for checking API calls | ||
68 | */ | ||
69 | #if defined(LUA_USE_APICHECK) | ||
70 | #include <assert.h> | ||
71 | #define luai_apicheck(L,e) { (void)L; assert(e); } | ||
72 | #elif !defined(luai_apicheck) | ||
73 | #define luai_apicheck(L,e) lua_assert(e) | ||
66 | #endif | 74 | #endif |
67 | 75 | ||
68 | #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) | 76 | #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) |
69 | 77 | ||
70 | 78 | ||
71 | #ifndef UNUSED | 79 | #if !defined(UNUSED) |
72 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ | 80 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ |
73 | #endif | 81 | #endif |
74 | 82 | ||
75 | 83 | ||
76 | #ifndef cast | ||
77 | #define cast(t, exp) ((t)(exp)) | 84 | #define cast(t, exp) ((t)(exp)) |
78 | #endif | ||
79 | 85 | ||
80 | #define cast_byte(i) cast(lu_byte, (i)) | 86 | #define cast_byte(i) cast(lu_byte, (i)) |
81 | #define cast_num(i) cast(lua_Number, (i)) | 87 | #define cast_num(i) cast(lua_Number, (i)) |
82 | #define cast_int(i) cast(int, (i)) | 88 | #define cast_int(i) cast(int, (i)) |
83 | 89 | ||
84 | 90 | ||
91 | /* | ||
92 | ** maximum depth for nested C calls and syntactical nested non-terminals | ||
93 | ** in a program. (Value must fit in an unsigned short int.) | ||
94 | */ | ||
95 | #if !defined(LUAI_MAXCCALLS) | ||
96 | #define LUAI_MAXCCALLS 200 | ||
97 | #endif | ||
98 | |||
99 | |||
85 | 100 | ||
86 | /* | 101 | /* |
87 | ** type for virtual-machine instructions | 102 | ** type for virtual-machine instructions |
@@ -97,23 +112,23 @@ typedef lu_int32 Instruction; | |||
97 | 112 | ||
98 | 113 | ||
99 | /* minimum size for the string table (must be power of 2) */ | 114 | /* minimum size for the string table (must be power of 2) */ |
100 | #ifndef MINSTRTABSIZE | 115 | #if !defined(MINSTRTABSIZE) |
101 | #define MINSTRTABSIZE 32 | 116 | #define MINSTRTABSIZE 32 |
102 | #endif | 117 | #endif |
103 | 118 | ||
104 | 119 | ||
105 | /* minimum size for string buffer */ | 120 | /* minimum size for string buffer */ |
106 | #ifndef LUA_MINBUFFER | 121 | #if !defined(LUA_MINBUFFER) |
107 | #define LUA_MINBUFFER 32 | 122 | #define LUA_MINBUFFER 32 |
108 | #endif | 123 | #endif |
109 | 124 | ||
110 | 125 | ||
111 | #ifndef lua_lock | 126 | #if !defined(lua_lock) |
112 | #define lua_lock(L) ((void) 0) | 127 | #define lua_lock(L) ((void) 0) |
113 | #define lua_unlock(L) ((void) 0) | 128 | #define lua_unlock(L) ((void) 0) |
114 | #endif | 129 | #endif |
115 | 130 | ||
116 | #ifndef luai_threadyield | 131 | #if !defined(luai_threadyield) |
117 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} | 132 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} |
118 | #endif | 133 | #endif |
119 | 134 | ||
@@ -121,7 +136,7 @@ typedef lu_int32 Instruction; | |||
121 | /* | 136 | /* |
122 | ** macro to control inclusion of some hard tests on stack reallocation | 137 | ** macro to control inclusion of some hard tests on stack reallocation |
123 | */ | 138 | */ |
124 | #ifndef HARDSTACKTESTS | 139 | #if !defined(HARDSTACKTESTS) |
125 | #define condmovestack(L) ((void)0) | 140 | #define condmovestack(L) ((void)0) |
126 | #else | 141 | #else |
127 | /* realloc stack keeping its size */ | 142 | /* realloc stack keeping its size */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.67 2009/11/16 15:51:19 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.68 2009/11/24 12:05:44 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -22,6 +22,43 @@ | |||
22 | #include "lualib.h" | 22 | #include "lualib.h" |
23 | 23 | ||
24 | 24 | ||
25 | /* | ||
26 | ** LUA_PATH and LUA_CPATH are the names of the environment variables that | ||
27 | ** Lua check to set its paths. | ||
28 | */ | ||
29 | #if !defined(LUA_PATH) | ||
30 | #define LUA_PATH "LUA_PATH" | ||
31 | #endif | ||
32 | |||
33 | #if !defined(LUA_CPATH) | ||
34 | #define LUA_CPATH "LUA_CPATH" | ||
35 | #endif | ||
36 | |||
37 | |||
38 | /* | ||
39 | ** LUA_PATHSEP is the character that separates templates in a path. | ||
40 | ** LUA_PATH_MARK is the string that marks the substitution points in a | ||
41 | ** template. | ||
42 | ** LUA_EXECDIR in a Windows path is replaced by the executable's | ||
43 | ** directory. | ||
44 | ** LUA_IGMARK is a mark to ignore all before it when building the | ||
45 | ** luaopen_ function name. | ||
46 | */ | ||
47 | #if !defined (LUA_PATHSEP) | ||
48 | #define LUA_PATHSEP ";" | ||
49 | #endif | ||
50 | #if !defined (LUA_PATH_MARK) | ||
51 | #define LUA_PATH_MARK "?" | ||
52 | #endif | ||
53 | #if !defined (LUA_EXECDIR) | ||
54 | #define LUA_EXECDIR "!" | ||
55 | #endif | ||
56 | #if !defined (LUA_IGMARK) | ||
57 | #define LUA_IGMARK "-" | ||
58 | #endif | ||
59 | |||
60 | |||
61 | |||
25 | /* prefix for open functions in C libraries */ | 62 | /* prefix for open functions in C libraries */ |
26 | #define LUA_POF "luaopen_" | 63 | #define LUA_POF "luaopen_" |
27 | 64 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.26 2009/11/23 18:20:38 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.27 2009/11/24 12:05:44 roberto Exp roberto $ |
3 | ** Standard Operating System library | 3 | ** Standard Operating System library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -20,6 +20,28 @@ | |||
20 | #include "lualib.h" | 20 | #include "lualib.h" |
21 | 21 | ||
22 | 22 | ||
23 | /* | ||
24 | ** By default, Lua uses tmpnam except when POSIX is available, where it | ||
25 | ** uses mkstemp. | ||
26 | */ | ||
27 | #if defined(LUA_USE_MKSTEMP) | ||
28 | #include <unistd.h> | ||
29 | #define LUA_TMPNAMBUFSIZE 32 | ||
30 | #define lua_tmpnam(b,e) { \ | ||
31 | strcpy(b, "/tmp/lua_XXXXXX"); \ | ||
32 | e = mkstemp(b); \ | ||
33 | if (e != -1) close(e); \ | ||
34 | e = (e == -1); } | ||
35 | |||
36 | #elif !defined(lua_tmpnam) | ||
37 | |||
38 | #define LUA_TMPNAMBUFSIZE L_tmpnam | ||
39 | #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } | ||
40 | |||
41 | #endif | ||
42 | |||
43 | |||
44 | |||
23 | static int os_pushresult (lua_State *L, int i, const char *filename) { | 45 | static int os_pushresult (lua_State *L, int i, const char *filename) { |
24 | int en = errno; /* calls to Lua API may change this value */ | 46 | int en = errno; /* calls to Lua API may change this value */ |
25 | if (i) { | 47 | if (i) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.65 2009/12/14 15:27:30 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.66 2009/12/16 16:42:58 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -25,6 +25,15 @@ | |||
25 | #include "ltm.h" | 25 | #include "ltm.h" |
26 | 26 | ||
27 | 27 | ||
28 | #if !defined(LUAI_GCPAUSE) | ||
29 | #define LUAI_GCPAUSE 162 /* 162% (wait memory to double before next GC) */ | ||
30 | #endif | ||
31 | |||
32 | #if !defined(LUAI_GCMUL) | ||
33 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ | ||
34 | #endif | ||
35 | |||
36 | |||
28 | /* | 37 | /* |
29 | ** thread state + extra space | 38 | ** thread state + extra space |
30 | */ | 39 | */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.144 2009/11/24 12:05:44 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.145 2009/11/26 16:49:28 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -20,6 +20,15 @@ | |||
20 | #include "lualib.h" | 20 | #include "lualib.h" |
21 | 21 | ||
22 | 22 | ||
23 | /* | ||
24 | ** maximum number of captures that a pattern can do during | ||
25 | ** pattern-matching. This limit is arbitrary. | ||
26 | */ | ||
27 | #if !defined(LUA_MAXCAPTURES) | ||
28 | #define LUA_MAXCAPTURES 32 | ||
29 | #endif | ||
30 | |||
31 | |||
23 | /* macro to `unsign' a character */ | 32 | /* macro to `unsign' a character */ |
24 | #define uchar(c) ((unsigned char)(c)) | 33 | #define uchar(c) ((unsigned char)(c)) |
25 | 34 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.h,v 2.27 2009/12/14 15:27:30 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.28 2009/12/16 16:42:58 roberto Exp roberto $ |
3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,10 +44,6 @@ void *l_Trick; | |||
44 | 44 | ||
45 | void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize); | 45 | void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize); |
46 | 46 | ||
47 | #ifdef lua_c | ||
48 | #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) | ||
49 | #endif | ||
50 | |||
51 | 47 | ||
52 | typedef struct CallInfo *pCallInfo; | 48 | typedef struct CallInfo *pCallInfo; |
53 | 49 | ||
@@ -72,7 +68,9 @@ struct L_EXTRA { int lock; int *plock; }; | |||
72 | 68 | ||
73 | int luaB_opentests (lua_State *L); | 69 | int luaB_opentests (lua_State *L); |
74 | 70 | ||
75 | #ifdef lua_c | 71 | |
72 | #if defined(lua_c) | ||
73 | #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) | ||
76 | #define luaL_openlibs(L) { (luaL_openlibs)(L); luaB_opentests(L); } | 74 | #define luaL_openlibs(L) { (luaL_openlibs)(L); luaB_opentests(L); } |
77 | #endif | 75 | #endif |
78 | 76 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.176 2009/11/24 18:05:12 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.177 2009/12/11 13:40:44 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -18,6 +18,69 @@ | |||
18 | #include "lualib.h" | 18 | #include "lualib.h" |
19 | 19 | ||
20 | 20 | ||
21 | #if !defined(LUA_PROMPT) | ||
22 | #define LUA_PROMPT "> " | ||
23 | #define LUA_PROMPT2 ">> " | ||
24 | #endif | ||
25 | |||
26 | #if !defined(LUA_PROGNAME) | ||
27 | #define LUA_PROGNAME "lua" | ||
28 | #endif | ||
29 | |||
30 | #if !defined(LUA_MAXINPUT) | ||
31 | #define LUA_MAXINPUT 512 | ||
32 | #endif | ||
33 | |||
34 | #if !defined(LUA_INIT) | ||
35 | #define LUA_INIT "LUA_INIT" | ||
36 | #endif | ||
37 | |||
38 | |||
39 | /* | ||
40 | ** lua_stdin_is_tty detects whether the standard input is a 'tty' (that | ||
41 | ** is, whether we're running lua interactively). | ||
42 | */ | ||
43 | #if defined(LUA_USE_ISATTY) | ||
44 | #include <unistd.h> | ||
45 | #define lua_stdin_is_tty() isatty(0) | ||
46 | #elif defined(LUA_WIN) | ||
47 | #include <io.h> | ||
48 | #include <stdio.h> | ||
49 | #define lua_stdin_is_tty() _isatty(_fileno(stdin)) | ||
50 | #else | ||
51 | #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ | ||
52 | #endif | ||
53 | |||
54 | |||
55 | /* | ||
56 | ** lua_readline defines how to show a prompt and then read a line from | ||
57 | ** the standard input. | ||
58 | ** lua_saveline defines how to "save" a read line in a "history". | ||
59 | ** lua_freeline defines how to free a line read by lua_readline. | ||
60 | */ | ||
61 | #if defined(LUA_USE_READLINE) | ||
62 | |||
63 | #include <stdio.h> | ||
64 | #include <readline/readline.h> | ||
65 | #include <readline/history.h> | ||
66 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) | ||
67 | #define lua_saveline(L,idx) \ | ||
68 | if (lua_objlen(L,idx) > 0) /* non-empty line? */ \ | ||
69 | add_history(lua_tostring(L, idx)); /* add it to history */ | ||
70 | #define lua_freeline(L,b) ((void)L, free(b)) | ||
71 | |||
72 | #elif !defined(lua_readline) | ||
73 | |||
74 | #define lua_readline(L,b,p) \ | ||
75 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ | ||
76 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ | ||
77 | #define lua_saveline(L,idx) { (void)L; (void)idx; } | ||
78 | #define lua_freeline(L,b) { (void)L; (void)b; } | ||
79 | |||
80 | #endif | ||
81 | |||
82 | |||
83 | |||
21 | 84 | ||
22 | static lua_State *globalL = NULL; | 85 | static lua_State *globalL = NULL; |
23 | 86 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.120 2009/12/10 19:00:33 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.121 2009/12/14 15:27:30 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -65,17 +65,6 @@ | |||
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
68 | /* | ||
69 | @@ LUA_PATH and LUA_CPATH are the names of the environment variables that | ||
70 | @* Lua check to set its paths. | ||
71 | @@ LUA_INIT is the name of the environment variable that Lua | ||
72 | @* checks for initialization code. | ||
73 | ** CHANGE them if you want different names. | ||
74 | */ | ||
75 | #define LUA_PATH "LUA_PATH" | ||
76 | #define LUA_CPATH "LUA_CPATH" | ||
77 | #define LUA_INIT "LUA_INIT" | ||
78 | |||
79 | 68 | ||
80 | /* | 69 | /* |
81 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for | 70 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for |
@@ -124,24 +113,6 @@ | |||
124 | 113 | ||
125 | 114 | ||
126 | /* | 115 | /* |
127 | @@ LUA_PATHSEP is the character that separates templates in a path. | ||
128 | @@ LUA_PATH_MARK is the string that marks the substitution points in a | ||
129 | @* template. | ||
130 | @@ LUA_EXECDIR in a Windows path is replaced by the executable's | ||
131 | @* directory. | ||
132 | @@ LUA_IGMARK is a mark to ignore all before it when building the | ||
133 | @* luaopen_ function name. | ||
134 | ** CHANGE them if for some reason your system cannot use those | ||
135 | ** characters. (E.g., if one of those characters is a common character | ||
136 | ** in file/directory names.) Probably you do not need to change them. | ||
137 | */ | ||
138 | #define LUA_PATHSEP ";" | ||
139 | #define LUA_PATH_MARK "?" | ||
140 | #define LUA_EXECDIR "!" | ||
141 | #define LUA_IGMARK "-" | ||
142 | |||
143 | |||
144 | /* | ||
145 | @@ LUA_API is a mark for all core API functions. | 116 | @@ LUA_API is a mark for all core API functions. |
146 | @@ LUALIB_API is a mark for all auxiliary library functions. | 117 | @@ LUALIB_API is a mark for all auxiliary library functions. |
147 | @@ LUAMOD_API is a mark for all standard library opening functions. | 118 | @@ LUAMOD_API is a mark for all standard library opening functions. |
@@ -225,106 +196,6 @@ | |||
225 | #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) | 196 | #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) |
226 | 197 | ||
227 | 198 | ||
228 | /* | ||
229 | ** {================================================================== | ||
230 | ** Stand-alone configuration | ||
231 | ** =================================================================== | ||
232 | */ | ||
233 | |||
234 | #if defined(lua_c) || defined(luaall_c) | ||
235 | |||
236 | /* | ||
237 | @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that | ||
238 | @* is, whether we're running lua interactively). | ||
239 | ** CHANGE it if you have a better definition for non-POSIX/non-Windows | ||
240 | ** systems. | ||
241 | */ | ||
242 | #if defined(LUA_USE_ISATTY) | ||
243 | #include <unistd.h> | ||
244 | #define lua_stdin_is_tty() isatty(0) | ||
245 | #elif defined(LUA_WIN) | ||
246 | #include <io.h> | ||
247 | #include <stdio.h> | ||
248 | #define lua_stdin_is_tty() _isatty(_fileno(stdin)) | ||
249 | #else | ||
250 | #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ | ||
251 | #endif | ||
252 | |||
253 | |||
254 | /* | ||
255 | @@ LUA_PROMPT is the default prompt used by stand-alone Lua. | ||
256 | @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. | ||
257 | ** CHANGE them if you want different prompts. (You can also change the | ||
258 | ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) | ||
259 | */ | ||
260 | #define LUA_PROMPT "> " | ||
261 | #define LUA_PROMPT2 ">> " | ||
262 | |||
263 | |||
264 | /* | ||
265 | @@ LUA_PROGNAME is the default name for the stand-alone Lua program. | ||
266 | ** CHANGE it if your stand-alone interpreter has a different name and | ||
267 | ** your system is not able to detect that name automatically. | ||
268 | */ | ||
269 | #define LUA_PROGNAME "lua" | ||
270 | |||
271 | |||
272 | /* | ||
273 | @@ LUA_MAXINPUT is the maximum length for an input line in the | ||
274 | @* stand-alone interpreter. | ||
275 | ** CHANGE it if you need longer lines. | ||
276 | */ | ||
277 | #define LUA_MAXINPUT 512 | ||
278 | |||
279 | |||
280 | /* | ||
281 | @@ lua_readline defines how to show a prompt and then read a line from | ||
282 | @* the standard input. | ||
283 | @@ lua_saveline defines how to "save" a read line in a "history". | ||
284 | @@ lua_freeline defines how to free a line read by lua_readline. | ||
285 | ** CHANGE them if you want to improve/adapt this functionality. | ||
286 | */ | ||
287 | #if defined(LUA_USE_READLINE) | ||
288 | #include <stdio.h> | ||
289 | #include <readline/readline.h> | ||
290 | #include <readline/history.h> | ||
291 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) | ||
292 | #define lua_saveline(L,idx) \ | ||
293 | if (lua_objlen(L,idx) > 0) /* non-empty line? */ \ | ||
294 | add_history(lua_tostring(L, idx)); /* add it to history */ | ||
295 | #define lua_freeline(L,b) ((void)L, free(b)) | ||
296 | #else | ||
297 | #define lua_readline(L,b,p) \ | ||
298 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ | ||
299 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ | ||
300 | #define lua_saveline(L,idx) { (void)L; (void)idx; } | ||
301 | #define lua_freeline(L,b) { (void)L; (void)b; } | ||
302 | #endif | ||
303 | |||
304 | #endif | ||
305 | |||
306 | /* }================================================================== */ | ||
307 | |||
308 | |||
309 | /* | ||
310 | @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles | ||
311 | @* as a percentage. | ||
312 | ** CHANGE it if you want the GC to run faster or slower (higher values | ||
313 | ** mean larger pauses which mean slower collection.) You can also change | ||
314 | ** this value dynamically. | ||
315 | */ | ||
316 | #define LUAI_GCPAUSE 162 /* 162% (wait memory to double before next GC) */ | ||
317 | |||
318 | |||
319 | /* | ||
320 | @@ LUAI_GCMUL defines the default speed of garbage collection relative to | ||
321 | @* memory allocation as a percentage. | ||
322 | ** CHANGE it if you want to change the granularity of the garbage | ||
323 | ** collection. (Higher values mean coarser collections. 0 represents | ||
324 | ** infinity, where each step performs a full collection.) You can also | ||
325 | ** change this value dynamically. | ||
326 | */ | ||
327 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ | ||
328 | 199 | ||
329 | 200 | ||
330 | 201 | ||
@@ -373,22 +244,6 @@ | |||
373 | 244 | ||
374 | 245 | ||
375 | 246 | ||
376 | |||
377 | /* | ||
378 | @@ luai_apicheck is the assert macro used by the Lua-C API. | ||
379 | ** CHANGE luai_apicheck if you want Lua to perform some checks in the | ||
380 | ** parameters it gets from API calls. This may slow down the interpreter | ||
381 | ** a bit, but may be quite useful when debugging C code that interfaces | ||
382 | ** with Lua. A useful redefinition is to use assert.h. | ||
383 | */ | ||
384 | #if defined(LUA_USE_APICHECK) | ||
385 | #include <assert.h> | ||
386 | #define luai_apicheck(L,o) { (void)L; assert(o); } | ||
387 | #else | ||
388 | #define luai_apicheck(L,o) { (void)L; } | ||
389 | #endif | ||
390 | |||
391 | |||
392 | /* | 247 | /* |
393 | @@ LUAI_BITSINT defines the number of bits in an int. | 248 | @@ LUAI_BITSINT defines the number of bits in an int. |
394 | ** CHANGE here if Lua cannot automatically detect the number of bits of | 249 | ** CHANGE here if Lua cannot automatically detect the number of bits of |
@@ -459,14 +314,6 @@ | |||
459 | 314 | ||
460 | 315 | ||
461 | /* | 316 | /* |
462 | @@ LUAI_MAXCCALLS is the maximum depth for nested C calls and | ||
463 | @* syntactical nested non-terminals in a program. (Value must | ||
464 | @* fit in an unsigned short int.) | ||
465 | */ | ||
466 | #define LUAI_MAXCCALLS 200 | ||
467 | |||
468 | |||
469 | /* | ||
470 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. | 317 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. |
471 | */ | 318 | */ |
472 | #define LUAL_BUFFERSIZE BUFSIZ | 319 | #define LUAL_BUFFERSIZE BUFSIZ |
@@ -616,81 +463,6 @@ union luai_Cast { double l_d; long l_l; }; | |||
616 | 463 | ||
617 | 464 | ||
618 | /* | 465 | /* |
619 | @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. | ||
620 | ** CHANGE it if your system requires alignments larger than double. (For | ||
621 | ** instance, if your system supports long doubles and they must be | ||
622 | ** aligned in 16-byte boundaries, then you should add long double in the | ||
623 | ** union.) Probably you do not need to change this. | ||
624 | */ | ||
625 | #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } | ||
626 | |||
627 | |||
628 | /* | ||
629 | @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. | ||
630 | ** CHANGE them if you prefer to use longjmp/setjmp even with C++ | ||
631 | ** or if want/don't to use _longjmp/_setjmp instead of regular | ||
632 | ** longjmp/setjmp. By default, Lua handles errors with exceptions when | ||
633 | ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, | ||
634 | ** and with longjmp/setjmp otherwise. | ||
635 | */ | ||
636 | #if defined(__cplusplus) | ||
637 | /* C++ exceptions */ | ||
638 | #define LUAI_THROW(L,c) throw(c) | ||
639 | #define LUAI_TRY(L,c,a) try { a } catch(...) \ | ||
640 | { if ((c)->status == 0) (c)->status = -1; } | ||
641 | #define luai_jmpbuf int /* dummy variable */ | ||
642 | |||
643 | #elif defined(LUA_USE_ULONGJMP) | ||
644 | /* in Unix, try _longjmp/_setjmp (more efficient) */ | ||
645 | #define LUAI_THROW(L,c) _longjmp((c)->b, 1) | ||
646 | #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } | ||
647 | #define luai_jmpbuf jmp_buf | ||
648 | |||
649 | #else | ||
650 | /* default handling with long jumps */ | ||
651 | #define LUAI_THROW(L,c) longjmp((c)->b, 1) | ||
652 | #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } | ||
653 | #define luai_jmpbuf jmp_buf | ||
654 | |||
655 | #endif | ||
656 | |||
657 | |||
658 | /* | ||
659 | @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern | ||
660 | @* can do during pattern-matching. | ||
661 | ** CHANGE it if you need more captures. This limit is arbitrary. | ||
662 | */ | ||
663 | #define LUA_MAXCAPTURES 32 | ||
664 | |||
665 | |||
666 | /* | ||
667 | @@ lua_tmpnam is the function that the OS library uses to create a | ||
668 | @* temporary name. | ||
669 | @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. | ||
670 | ** CHANGE them if you have an alternative to tmpnam (which is considered | ||
671 | ** insecure) or if you want the original tmpnam anyway. By default, Lua | ||
672 | ** uses tmpnam except when POSIX is available, where it uses mkstemp. | ||
673 | */ | ||
674 | #if defined(loslib_c) || defined(luaall_c) | ||
675 | |||
676 | #if defined(LUA_USE_MKSTEMP) | ||
677 | #include <unistd.h> | ||
678 | #define LUA_TMPNAMBUFSIZE 32 | ||
679 | #define lua_tmpnam(b,e) { \ | ||
680 | strcpy(b, "/tmp/lua_XXXXXX"); \ | ||
681 | e = mkstemp(b); \ | ||
682 | if (e != -1) close(e); \ | ||
683 | e = (e == -1); } | ||
684 | |||
685 | #else | ||
686 | #define LUA_TMPNAMBUFSIZE L_tmpnam | ||
687 | #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } | ||
688 | #endif | ||
689 | |||
690 | #endif | ||
691 | |||
692 | |||
693 | /* | ||
694 | @@ LUA_STRFTIMEOPTIONS is the list of valid conversion specifiers | 466 | @@ LUA_STRFTIMEOPTIONS is the list of valid conversion specifiers |
695 | @* for the 'strftime' function; | 467 | @* for the 'strftime' function; |
696 | ** CHANGE it if you want to use non-ansi options specific to your system. | 468 | ** CHANGE it if you want to use non-ansi options specific to your system. |
@@ -753,15 +525,6 @@ union luai_Cast { double l_d; long l_l; }; | |||
753 | 525 | ||
754 | 526 | ||
755 | /* | 527 | /* |
756 | @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State. | ||
757 | @* (This data goes just *before* the lua_State pointer.) | ||
758 | ** CHANGE (define) this if you really need that. If defined, this value | ||
759 | ** cannot be zero. | ||
760 | */ | ||
761 | /* #define LUAI_EXTRASPACE ?? */ | ||
762 | |||
763 | |||
764 | /* | ||
765 | @@ luai_userstate* allow user-specific actions on threads. | 528 | @@ luai_userstate* allow user-specific actions on threads. |
766 | ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something | 529 | ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something |
767 | ** extra when a thread is created/deleted/resumed/yielded. | 530 | ** extra when a thread is created/deleted/resumed/yielded. |