new constant 'LUA_GNAME' for the name of the global table "_G" · lua/lua@5a1c8d8 · GitHub
Skip to content

Commit 5a1c8d8

Browse files
committed
new constant 'LUA_GNAME' for the name of the global table "_G"
1 parent 124bfd2 commit 5a1c8d8

5 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎lauxlib.c‎

Lines changed: 2 additions & 2 deletions

‎lauxlib.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp roberto $
2+
** $Id: lauxlib.h,v 1.132 2017/04/24 18:06:12 roberto Exp roberto $
33
** Auxiliary functions for building Lua libraries
44
** See Copyright Notice in lua.h
55
*/
@@ -15,6 +15,10 @@
1515
#include "lua.h"
1616

1717

18+
/* global table */
19+
#define LUA_GNAME "_G"
20+
21+
1822

1923
/* extra error code for 'luaL_loadfilex' */
2024
#define LUA_ERRFILE (LUA_ERRERR+1)

‎lbaselib.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lbaselib.c,v 1.315 2017/02/23 21:07:34 roberto Exp roberto $
2+
** $Id: lbaselib.c,v 1.316 2017/05/26 19:14:29 roberto Exp roberto $
33
** Basic library
44
** See Copyright Notice in lua.h
55
*/
@@ -504,7 +504,7 @@ static const luaL_Reg base_funcs[] = {
504504
{"type", luaB_type},
505505
{"xpcall", luaB_xpcall},
506506
/* placeholders */
507-
{"_G", NULL},
507+
{LUA_GNAME, NULL},
508508
{"_VERSION", NULL},
509509
{NULL, NULL}
510510
};
@@ -516,7 +516,7 @@ LUAMOD_API int luaopen_base (lua_State *L) {
516516
luaL_setfuncs(L, base_funcs, 0);
517517
/* set global _G */
518518
lua_pushvalue(L, -1);
519-
lua_setfield(L, -2, "_G");
519+
lua_setfield(L, -2, LUA_GNAME);
520520
/* set global _VERSION */
521521
lua_pushliteral(L, LUA_VERSION);
522522
lua_setfield(L, -2, "_VERSION");

‎linit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp roberto $
2+
** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp roberto $
33
** Initialization of libraries for lua.c and other clients
44
** See Copyright Notice in lua.h
55
*/
@@ -40,7 +40,7 @@
4040
** program
4141
*/
4242
static const luaL_Reg loadedlibs[] = {
43-
{"_G", luaopen_base},
43+
{LUA_GNAME, luaopen_base},
4444
{LUA_LOADLIBNAME, luaopen_package},
4545
{LUA_COLIBNAME, luaopen_coroutine},
4646
{LUA_TABLIBNAME, luaopen_table},

‎ltests.c‎

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)