Showing the changes to src (2 of 5 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lauxlib.c,v 1.277 2014/12/10 11:31:32 roberto Exp $ | |
| 2 | +** $Id: lauxlib.c,v 1.279 2014/12/14 18:32:26 roberto Exp $ | |
| 3 | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -66,11 +66,20 @@ static int findfield (lua_State *L, int objidx, int level) { · 60 unmodified lines | ||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | +/* | |
| 70 | +** Search for a name for a function in all loaded modules | |
| 71 | +** (registry._LOADED). | |
| 72 | +*/ | |
| 69 | 73 | static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { |
| 70 | 74 | int top = lua_gettop(L); |
| 71 | 75 | lua_getinfo(L, "f", ar); /* push function */ |
| 72 | − lua_pushglobaltable(L); | |
| 76 | + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); | |
| 73 | 77 | if (findfield(L, top + 1, 2)) { |
| 78 | + const char *name = lua_tostring(L, -1); | |
| 79 | + if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */ | |
| 80 | + lua_pushstring(L, name + 3); /* push name without prefix */ | |
| 81 | + lua_remove(L, -2); /* remove original name */ | |
| 82 | + } | |
| 74 | 83 | lua_copy(L, -1, top + 1); /* move name to proper place */ |
| 75 | 84 | lua_pop(L, 2); /* remove pushed values */ |
| 76 | 85 | return 1; |
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: luaconf.h,v 1.231 2014/12/10 11:56:55 roberto Exp $ | |
| 2 | +** $Id: luaconf.h,v 1.235 2014/12/16 17:17:30 roberto Exp $ | |
| 3 | 3 | ** Configuration file for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | |
| 8 | −#ifndef lconfig_h | |
| 9 | −#define lconfig_h | |
| 8 | +#ifndef luaconf_h | |
| 9 | +#define luaconf_h | |
| 10 | 10 | |
| 11 | 11 | #include <limits.h> |
| 12 | 12 | #include <stddef.h> |
| @@ -20,18 +20,18 @@ · 7 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /* |
| 23 | −** {================================================================== | |
| 23 | +** {==================================================================== | |
| 24 | 24 | ** System Configuration: macros to adapt (if needed) Lua to some |
| 25 | −** particular platform, for instance compiling it as Small Lua (32 | |
| 26 | −** bits) or restricting it to C89. | |
| 27 | −** =================================================================== | |
| 25 | +** particular platform, for instance compiling it with 32-bit numbers or | |
| 26 | +** restricting it to C89. | |
| 27 | +** ===================================================================== | |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | /* |
| 31 | −@@ LUA_32BITS enables Small Lua (that is, Lua with 32-bit integers | |
| 32 | −** and 32-bit floats). You can also define LUA_32BITS in the make file, | |
| 33 | −** but changing here you ensure that all software connected to Lua will | |
| 34 | −** be compiled with the same configuration. | |
| 31 | +@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You | |
| 32 | +** can also define LUA_32BITS in the make file, but changing here you | |
| 33 | +** ensure that all software connected to Lua will be compiled with the | |
| 34 | +** same configuration. | |
| 35 | 35 | */ |
| 36 | 36 | /* #define LUA_32BITS */ |
| 37 | 37 | |
| @@ -74,8 +74,8 @@ · 36 unmodified lines | ||
| 74 | 74 | |
| 75 | 75 | /* |
| 76 | 76 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for |
| 77 | −** C89 ('long' and 'double'); Windows has '__int64', so it does not need | |
| 78 | −** to use this case. | |
| 77 | +** C89 ('long' and 'double'); Windows always has '__int64', so it does | |
| 78 | +** not need to use this case. | |
| 79 | 79 | */ |
| 80 | 80 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) |
| 81 | 81 | #define LUA_C89_NUMBERS |
| @@ -102,8 +102,8 @@ · 20 unmodified lines | ||
| 102 | 102 | ** the type for Lua floats. |
| 103 | 103 | ** Lua should work fine with any mix of these options (if supported |
| 104 | 104 | ** by your C compiler). The usual configurations are 64-bit integers |
| 105 | −** and 'double' (the default), 32-bit integers and 'float' (Small Lua, | |
| 106 | −** for restricted platforms), and 'long'/'double' (for C compilers not | |
| 105 | +** and 'double' (the default), 32-bit integers and 'float' (for | |
| 106 | +** restricted platforms), and 'long'/'double' (for C compilers not | |
| 107 | 107 | ** compliant with C99, which may not have support for 'long long'). |
| 108 | 108 | */ |
| 109 | 109 | |
| @@ -127,8 +127,7 @@ · 17 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | #else /* }{ */ |
| 129 | 129 | /* |
| 130 | −** default configuration for 64-bit Lua ('long long' and 'double'); | |
| 131 | −** Windows will use '__int64' | |
| 130 | +** default configuration for 64-bit Lua ('long long' and 'double') | |
| 132 | 131 | */ |
| 133 | 132 | #define LUA_INT_LONGLONG |
| 134 | 133 | #define LUA_REAL_DOUBLE |
| @@ -565,7 +564,17 @@ · 430 unmodified lines | ||
| 565 | 564 | |
| 566 | 565 | #elif defined(LUA_INT_LONGLONG) /* }{ long long */ |
| 567 | 566 | |
| 568 | −#if defined(LUA_USE_WINDOWS) /* { */ | |
| 567 | +#if defined(LLONG_MAX) /* { */ | |
| 568 | +/* use ISO C99 stuff */ | |
| 569 | + | |
| 570 | +#define LUA_INTEGER long long | |
| 571 | +#define LUA_INTEGER_FRMLEN "ll" | |
| 572 | + | |
| 573 | +#define LUA_MAXINTEGER LLONG_MAX | |
| 574 | +#define LUA_MININTEGER LLONG_MIN | |
| 575 | + | |
| 576 | +#elif defined(LUA_USE_WINDOWS) /* }{ */ | |
| 577 | +/* in Windows, can use specific Windows types */ | |
| 569 | 578 | |
| 570 | 579 | #define LUA_INTEGER __int64 |
| 571 | 580 | #define LUA_INTEGER_FRMLEN "I64" |
| @@ -575,16 +584,8 @@ · 3 unmodified lines | ||
| 575 | 584 | |
| 576 | 585 | #else /* }{ */ |
| 577 | 586 | |
| 578 | −#if !defined(LLONG_MAX) | |
| 579 | 587 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ |
| 580 | 588 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" |
| 581 | −#endif | |
| 582 | − | |
| 583 | −#define LUA_INTEGER long long | |
| 584 | −#define LUA_INTEGER_FRMLEN "ll" | |
| 585 | − | |
| 586 | −#define LUA_MAXINTEGER LLONG_MAX | |
| 587 | −#define LUA_MININTEGER LLONG_MIN | |
| 588 | 589 | |
| 589 | 590 | #endif /* } */ |
| 590 | 591 | |