File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*
2- ** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp roberto $
2+ ** $Id: lauxlib.c,v 1.290 2017/04/24 18:06:12 roberto Exp roberto $
33** Auxiliary functions for building Lua libraries
44** See Copyright Notice in lua.h
55*/
@@ -76,7 +76,7 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
7676 lua_getfield (L , LUA_REGISTRYINDEX , LUA_LOADED_TABLE );
7777 if (findfield (L , top + 1 , 2 )) {
7878 const char * name = lua_tostring (L , -1 );
79- if (strncmp (name , "_G ." , 3 ) == 0 ) { /* name start with '_G.'? */
79+ if (strncmp (name , LUA_GNAME " ." , 3 ) == 0 ) { /* name start with '_G.'? */
8080 lua_pushstring (L , name + 3 ); /* push name without prefix */
8181 lua_remove (L , -2 ); /* remove original name */
8282 }
Original file line number Diff line number Diff line change 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*/
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)
Original file line number Diff line number Diff line change 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" );
Original file line number Diff line number Diff line change 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*/
4040** program
4141*/
4242static 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 },
Original file line number Diff line number Diff line change 11/*
2- ** $Id: ltests.c,v 2.220 2017/06/12 14:21:44 roberto Exp roberto $
2+ ** $Id: ltests.c,v 2.221 2017/06/27 11:35:31 roberto Exp roberto $
33** Internal Module for Debugging of the Lua Implementation
44** See Copyright Notice in lua.h
55*/
@@ -960,7 +960,7 @@ static lua_State *getstate (lua_State *L) {
960960
961961static int loadlib (lua_State * L ) {
962962 static const luaL_Reg libs [] = {
963- {"_G" , luaopen_base },
963+ {LUA_GNAME , luaopen_base },
964964 {"coroutine" , luaopen_coroutine },
965965 {"debug" , luaopen_debug },
966966 {"io" , luaopen_io },
You can’t perform that action at this time.
0 commit comments