History

Lua 5.3.0-rc1

Lua Team committed 11 years ago

Commit 39602181 parent 17ba7315 files · +61 −49Browse files

Showing the changes to src (2 of 5 files). Show all

Unified · Split

2 files
  1. src/lauxlib.c +11 −2
  2. src/luaconf.h +27 −26
src/lauxlib.c+11−2
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -66,11 +66,20 @@ static int findfield (lua_State *L, int objidx, int level) { · 60 unmodified lines
6666 }
6767
6868
69+/*
70+** Search for a name for a function in all loaded modules
71+** (registry._LOADED).
72+*/
6973 static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
7074 int top = lua_gettop(L);
7175 lua_getinfo(L, "f", ar); /* push function */
72− lua_pushglobaltable(L);
76+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
7377 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+ }
7483 lua_copy(L, -1, top + 1); /* move name to proper place */
7584 lua_pop(L, 2); /* remove pushed values */
7685 return 1;
src/luaconf.h+27−26
@@ -1,12 +1,12 @@
11 /*
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 $
33 ** Configuration file for Lua
44 ** See Copyright Notice in lua.h
55 */
66
77
8−#ifndef lconfig_h
9−#define lconfig_h
8+#ifndef luaconf_h
9+#define luaconf_h
1010
1111 #include <limits.h>
1212 #include <stddef.h>
@@ -20,18 +20,18 @@ · 7 unmodified lines
2020
2121
2222 /*
23−** {==================================================================
23+** {====================================================================
2424 ** 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+** =====================================================================
2828 */
2929
3030 /*
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.
3535 */
3636 /* #define LUA_32BITS */
3737
@@ -74,8 +74,8 @@ · 36 unmodified lines
7474
7575 /*
7676 @@ 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.
7979 */
8080 #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
8181 #define LUA_C89_NUMBERS
@@ -102,8 +102,8 @@ · 20 unmodified lines
102102 ** the type for Lua floats.
103103 ** Lua should work fine with any mix of these options (if supported
104104 ** 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
107107 ** compliant with C99, which may not have support for 'long long').
108108 */
109109
@@ -127,8 +127,7 @@ · 17 unmodified lines
127127
128128 #else /* }{ */
129129 /*
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')
132131 */
133132 #define LUA_INT_LONGLONG
134133 #define LUA_REAL_DOUBLE
@@ -565,7 +564,17 @@ · 430 unmodified lines
565564
566565 #elif defined(LUA_INT_LONGLONG) /* }{ long long */
567566
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 */
569578
570579 #define LUA_INTEGER __int64
571580 #define LUA_INTEGER_FRMLEN "I64"
@@ -575,16 +584,8 @@ · 3 unmodified lines
575584
576585 #else /* }{ */
577586
578−#if !defined(LLONG_MAX)
579587 #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
580588 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
588589
589590 #endif /* } */
590591