]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
From Lua 5.2: Support load(string).
authorMike Pall <mike>
Sun, 20 Feb 2011 20:17:49 +0000 (21:17 +0100)
committerMike Pall <mike>
Sun, 20 Feb 2011 20:17:49 +0000 (21:17 +0100)
src/lib_base.c

index bac49a0bfbf5849b0ff10e855611713719528621..2672a0764911d3163ab8e3dbd34d1731020498c6 100644 (file)
@@ -373,8 +373,11 @@ static const char *reader_func(lua_State *L, void *ud, size_t *size)
 
 LJLIB_CF(load)
 {
-  GCstr *name = lj_lib_optstr(L, 2);
+  GCstr *name;
+  if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base)))
+    return lj_cf_loadstring(L);
   lj_lib_checkfunc(L, 1);
+  name = lj_lib_optstr(L, 2);
   lua_settop(L, 3);  /* Reserve a slot for the string from the reader. */
   return load_aux(L,
           lua_load(L, reader_func, NULL, name ? strdata(name) : "=(load)"));