mirror of
https://github.com/lua/lua.git
synced 2026-06-07 23:53:48 +00:00
Some compilation options configurable from makefile
Compilation options LUA_COMPAT_GLOBAL, LUA_COMPAT_LOOPVAR, and LUA_READLINELIB do not affect the API, so they can be changed through the make file.
This commit is contained in:
2
llex.c
2
llex.c
@@ -188,7 +188,7 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
|
|||||||
so they cannot be collected */
|
so they cannot be collected */
|
||||||
ls->envn = luaS_newliteral(L, LUA_ENV); /* get env string */
|
ls->envn = luaS_newliteral(L, LUA_ENV); /* get env string */
|
||||||
ls->brkn = luaS_newliteral(L, "break"); /* get "break" string */
|
ls->brkn = luaS_newliteral(L, "break"); /* get "break" string */
|
||||||
#if defined(LUA_COMPAT_GLOBAL)
|
#if LUA_COMPAT_GLOBAL
|
||||||
/* compatibility mode: "global" is not a reserved word */
|
/* compatibility mode: "global" is not a reserved word */
|
||||||
ls->glbn = luaS_newliteral(L, "global"); /* get "global" string */
|
ls->glbn = luaS_newliteral(L, "global"); /* get "global" string */
|
||||||
ls->glbn->extra = 0; /* mark it as not reserved */
|
ls->glbn->extra = 0; /* mark it as not reserved */
|
||||||
|
|||||||
@@ -1685,7 +1685,7 @@ static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {
|
|||||||
/*
|
/*
|
||||||
** Control whether for-loop control variables are read-only
|
** Control whether for-loop control variables are read-only
|
||||||
*/
|
*/
|
||||||
#if defined(LUA_COMPAT_LOOPVAR)
|
#if LUA_COMPAT_LOOPVAR
|
||||||
#define LOOPVARKIND VDKREG
|
#define LOOPVARKIND VDKREG
|
||||||
#else /* by default, these variables are read only */
|
#else /* by default, these variables are read only */
|
||||||
#define LOOPVARKIND RDKCONST
|
#define LOOPVARKIND RDKCONST
|
||||||
@@ -2120,7 +2120,7 @@ static void statement (LexState *ls) {
|
|||||||
gotostat(ls, line);
|
gotostat(ls, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(LUA_COMPAT_GLOBAL)
|
#if LUA_COMPAT_GLOBAL
|
||||||
case TK_NAME: {
|
case TK_NAME: {
|
||||||
/* compatibility code to parse global keyword when "global"
|
/* compatibility code to parse global keyword when "global"
|
||||||
is not reserved */
|
is not reserved */
|
||||||
|
|||||||
1
ltests.h
1
ltests.h
@@ -14,6 +14,7 @@
|
|||||||
/* test Lua with compatibility code */
|
/* test Lua with compatibility code */
|
||||||
#define LUA_COMPAT_MATHLIB
|
#define LUA_COMPAT_MATHLIB
|
||||||
#undef LUA_COMPAT_GLOBAL
|
#undef LUA_COMPAT_GLOBAL
|
||||||
|
#define LUA_COMPAT_GLOBAL 0
|
||||||
|
|
||||||
|
|
||||||
#define LUA_DEBUG
|
#define LUA_DEBUG
|
||||||
|
|||||||
12
luaconf.h
12
luaconf.h
@@ -70,15 +70,19 @@
|
|||||||
#if defined(LUA_USE_LINUX)
|
#if defined(LUA_USE_LINUX)
|
||||||
#define LUA_USE_POSIX
|
#define LUA_USE_POSIX
|
||||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||||
|
#if !defined(LUA_READLINELIB)
|
||||||
#define LUA_READLINELIB "libreadline.so"
|
#define LUA_READLINELIB "libreadline.so"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(LUA_USE_MACOSX)
|
#if defined(LUA_USE_MACOSX)
|
||||||
#define LUA_USE_POSIX
|
#define LUA_USE_POSIX
|
||||||
#define LUA_USE_DLOPEN /* macOS does not need -ldl */
|
#define LUA_USE_DLOPEN /* macOS does not need -ldl */
|
||||||
|
#if !defined(LUA_READLINELIB)
|
||||||
#define LUA_READLINELIB "libedit.dylib"
|
#define LUA_READLINELIB "libedit.dylib"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(LUA_USE_IOS)
|
#if defined(LUA_USE_IOS)
|
||||||
@@ -339,14 +343,18 @@
|
|||||||
/*
|
/*
|
||||||
@@ LUA_COMPAT_GLOBAL avoids 'global' being a reserved word
|
@@ LUA_COMPAT_GLOBAL avoids 'global' being a reserved word
|
||||||
*/
|
*/
|
||||||
#define LUA_COMPAT_GLOBAL
|
#if !defined(LUA_COMPAT_GLOBAL)
|
||||||
|
#define LUA_COMPAT_GLOBAL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUA_COMPAT_LOOPVAR makes for-loop control variables not read-only,
|
@@ LUA_COMPAT_LOOPVAR makes for-loop control variables not read-only,
|
||||||
** as they were in previous versions.
|
** as they were in previous versions.
|
||||||
*/
|
*/
|
||||||
/* #define LUA_COMPAT_LOOPVAR */
|
#if !defined(LUA_COMPAT_LOOPVAR)
|
||||||
|
#define LUA_COMPAT_LOOPVAR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9594,12 +9594,18 @@ change between versions.
|
|||||||
@item{
|
@item{
|
||||||
The word @Rw{global} is a reserved word.
|
The word @Rw{global} is a reserved word.
|
||||||
Do not use it as a regular name.
|
Do not use it as a regular name.
|
||||||
|
|
||||||
|
The compilation option @id{LUA_COMPAT_GLOBAL} (see @id{luaconf.h})
|
||||||
|
makes @id{global} a regular word.
|
||||||
}
|
}
|
||||||
|
|
||||||
@item{
|
@item{
|
||||||
The control variable in @Rw{for} loops is read only.
|
The control variable in @Rw{for} loops is read only.
|
||||||
If you need to change it,
|
If you need to change it,
|
||||||
declare a local variable with the same name in the loop body.
|
declare a local variable with the same name in the loop body.
|
||||||
|
|
||||||
|
The compilation option @id{LUA_COMPAT_LOOPVAR} (see @id{luaconf.h})
|
||||||
|
makes these variables regular (writable).
|
||||||
}
|
}
|
||||||
|
|
||||||
@item{
|
@item{
|
||||||
|
|||||||
Reference in New Issue
Block a user