aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lapi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lapi.c b/lapi.c
index a5e94507..0c88751a 100644
--- a/lapi.c
+++ b/lapi.c
@@ -440,7 +440,7 @@ LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) {
440 case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen); 440 case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen);
441 case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen); 441 case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen);
442 case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len); 442 case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len);
443 case LUA_VTABLE: return luaH_getn(hvalue(o)); 443 case LUA_VTABLE: return luaH_getn(L, hvalue(o));
444 default: return 0; 444 default: return 0;
445 } 445 }
446} 446}
@@ -593,12 +593,8 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
593 const char *ret; 593 const char *ret;
594 va_list argp; 594 va_list argp;
595 lua_lock(L); 595 lua_lock(L);
596 va_start(argp, fmt); 596 pushvfstring(L, argp, fmt, ret);
597 ret = luaO_pushvfstring(L, fmt, argp);
598 va_end(argp);
599 luaC_checkGC(L); 597 luaC_checkGC(L);
600 if (ret == NULL) /* error? */
601 luaD_throw(L, LUA_ERRMEM);
602 lua_unlock(L); 598 lua_unlock(L);
603 return ret; 599 return ret;
604} 600}
@@ -681,6 +677,11 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
681} 677}
682 678
683 679
680/*
681** The following function assumes that the registry cannot be a weak
682** table; so, an emergency collection while using the global table
683** cannot collect it.
684*/
684static void getGlobalTable (lua_State *L, TValue *gt) { 685static void getGlobalTable (lua_State *L, TValue *gt) {
685 Table *registry = hvalue(&G(L)->l_registry); 686 Table *registry = hvalue(&G(L)->l_registry);
686 lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt); 687 lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt);
@@ -883,9 +884,8 @@ LUA_API void lua_settable (lua_State *L, int idx) {
883 api_checkpop(L, 2); 884 api_checkpop(L, 2);
884 t = index2value(L, idx); 885 t = index2value(L, idx);
885 luaV_fastset(t, s2v(L->top.p - 2), s2v(L->top.p - 1), hres, luaH_pset); 886 luaV_fastset(t, s2v(L->top.p - 2), s2v(L->top.p - 1), hres, luaH_pset);
886 if (hres == HOK) { 887 if (hres == HOK)
887 luaV_finishfastset(L, t, s2v(L->top.p - 1)); 888 luaV_finishfastset(L, t, s2v(L->top.p - 1));
888 }
889 else 889 else
890 luaV_finishset(L, t, s2v(L->top.p - 2), s2v(L->top.p - 1), hres); 890 luaV_finishset(L, t, s2v(L->top.p - 2), s2v(L->top.p - 1), hres);
891 L->top.p -= 2; /* pop index and value */ 891 L->top.p -= 2; /* pop index and value */