'require' returns where module was found

The function 'require' returns the *loader data* as a second result.
For file searchers, this data is the path where they found the module.
This commit is contained in:
Roberto Ierusalimschy
2019-04-17 14:57:29 -03:00
parent 2d3f095448
commit ed2872cd3b
4 changed files with 66 additions and 34 deletions

View File

@@ -271,8 +271,8 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
#define checksize(S,t) fchecksize(S,sizeof(t),#t)
static void checkHeader (LoadState *S) {
/* 1st char already checked */
checkliteral(S, LUA_SIGNATURE + 1, "not a binary chunk");
/* skip 1st char (already read and checked) */
checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk");
if (LoadInt(S) != LUAC_VERSION)
error(S, "version mismatch");
if (LoadByte(S) != LUAC_FORMAT)