diff options
author | Mike Pall <mike> | 2011-02-20 21:17:49 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-02-20 21:17:49 +0100 |
commit | 8d0b073ff0506b94fd0586f96ae6967cf8167290 (patch) | |
tree | e490346d70cba1aa6ad5214634dd4df04dc837be | |
parent | 2bae11a49a4b69b9f0b51dfd33c703f261b789cd (diff) | |
download | luajit-8d0b073ff0506b94fd0586f96ae6967cf8167290.tar.gz luajit-8d0b073ff0506b94fd0586f96ae6967cf8167290.tar.bz2 luajit-8d0b073ff0506b94fd0586f96ae6967cf8167290.zip |
From Lua 5.2: Support load(string).
-rw-r--r-- | src/lib_base.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index bac49a0b..2672a076 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
@@ -373,8 +373,11 @@ static const char *reader_func(lua_State *L, void *ud, size_t *size) | |||
373 | 373 | ||
374 | LJLIB_CF(load) | 374 | LJLIB_CF(load) |
375 | { | 375 | { |
376 | GCstr *name = lj_lib_optstr(L, 2); | 376 | GCstr *name; |
377 | if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base))) | ||
378 | return lj_cf_loadstring(L); | ||
377 | lj_lib_checkfunc(L, 1); | 379 | lj_lib_checkfunc(L, 1); |
380 | name = lj_lib_optstr(L, 2); | ||
378 | lua_settop(L, 3); /* Reserve a slot for the string from the reader. */ | 381 | lua_settop(L, 3); /* Reserve a slot for the string from the reader. */ |
379 | return load_aux(L, | 382 | return load_aux(L, |
380 | lua_load(L, reader_func, NULL, name ? strdata(name) : "=(load)")); | 383 | lua_load(L, reader_func, NULL, name ? strdata(name) : "=(load)")); |